Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_ui/space_userpref.py
| Show First 20 Lines • Show All 553 Lines • ▼ Show 20 Lines | |||||
| class USERPREF_PT_theme(Panel): | class USERPREF_PT_theme(Panel): | ||||
| bl_space_type = 'USER_PREFERENCES' | bl_space_type = 'USER_PREFERENCES' | ||||
| bl_label = "Themes" | bl_label = "Themes" | ||||
| bl_region_type = 'WINDOW' | bl_region_type = 'WINDOW' | ||||
| bl_options = {'HIDE_HEADER'} | bl_options = {'HIDE_HEADER'} | ||||
| # not essential, hard-coded UI delimiters for the theme layout | |||||
| ui_delimiters = { | |||||
| 'VIEW_3D': { | |||||
| "text_grease_pencil", | |||||
| "text_keyframe", | |||||
| "speaker", | |||||
| "freestyle_face_mark", | |||||
| "split_normal", | |||||
| "bone_solid", | |||||
| "paint_curve_pivot", | |||||
| }, | |||||
| 'GRAPH_EDITOR': { | |||||
| "handle_vertex_select", | |||||
| }, | |||||
| 'IMAGE_EDITOR': { | |||||
| "paint_curve_pivot", | |||||
| }, | |||||
| 'NODE_EDITOR': { | |||||
| "layout_node", | |||||
| }, | |||||
| 'CLIP_EDITOR': { | |||||
| "handle_vertex_select", | |||||
| } | |||||
| } | |||||
| @staticmethod | @staticmethod | ||||
| def _theme_generic(split, themedata): | def _theme_generic(split, themedata, theme_area): | ||||
| col = split.column() | col = split.column() | ||||
| def theme_generic_recurse(data): | def theme_generic_recurse(data): | ||||
| col.label(data.rna_type.name) | col.label(data.rna_type.name) | ||||
| row = col.row() | row = col.row() | ||||
| subsplit = row.split(percentage=0.95) | subsplit = row.split(percentage=0.95) | ||||
| Show All 10 Lines | def _theme_generic(split, themedata, theme_area): | ||||
| props_type = {} | props_type = {} | ||||
| for i, prop in enumerate(data.rna_type.properties): | for i, prop in enumerate(data.rna_type.properties): | ||||
| if prop.identifier == "rna_type": | if prop.identifier == "rna_type": | ||||
| continue | continue | ||||
| props_type.setdefault((prop.type, prop.subtype), []).append(prop) | props_type.setdefault((prop.type, prop.subtype), []).append(prop) | ||||
| th_delimiters = USERPREF_PT_theme.ui_delimiters.get(theme_area) | |||||
| for props_type, props_ls in sorted(props_type.items()): | for props_type, props_ls in sorted(props_type.items()): | ||||
| if props_type[0] == 'POINTER': | if props_type[0] == 'POINTER': | ||||
| for i, prop in enumerate(props_ls): | for i, prop in enumerate(props_ls): | ||||
| theme_generic_recurse(getattr(data, prop.identifier)) | theme_generic_recurse(getattr(data, prop.identifier)) | ||||
| else: | else: | ||||
| if th_delimiters is None: | |||||
| # simple, no delimiters | |||||
| for i, prop in enumerate(props_ls): | for i, prop in enumerate(props_ls): | ||||
| colsub_pair[i % 2].row().prop(data, prop.identifier) | colsub_pair[i % 2].row().prop(data, prop.identifier) | ||||
| else: | |||||
| # add hard coded delimiters | |||||
| i = 0 | |||||
| for prop in props_ls: | |||||
| colsub = colsub_pair[i] | |||||
| colsub.row().prop(data, prop.identifier) | |||||
| i = (i + 1) % 2 | |||||
| if prop.identifier in th_delimiters: | |||||
| if i: | |||||
| colsub = colsub_pair[1] | |||||
| colsub.row().label('') | |||||
| colsub_pair[0].row().label('') | |||||
| colsub_pair[1].row().label('') | |||||
| i = 0 | |||||
campbellbarton: Rather keep separate logic here, so common case can be kept understandable.
if… | |||||
| theme_generic_recurse(themedata) | theme_generic_recurse(themedata) | ||||
| @staticmethod | @staticmethod | ||||
| def _theme_widget_style(layout, widget_style): | def _theme_widget_style(layout, widget_style): | ||||
| row = layout.row() | row = layout.row() | ||||
| subsplit = row.split(percentage=0.95) | subsplit = row.split(percentage=0.95) | ||||
| ▲ Show 20 Lines • Show All 253 Lines • ▼ Show 20 Lines | def draw(self, context): | ||||
| col.label(text="Widget:") | col.label(text="Widget:") | ||||
| self._ui_font_style(col, style.widget) | self._ui_font_style(col, style.widget) | ||||
| col.separator() | col.separator() | ||||
| col.label(text="Widget Label:") | col.label(text="Widget Label:") | ||||
| self._ui_font_style(col, style.widget_label) | self._ui_font_style(col, style.widget_label) | ||||
| else: | else: | ||||
| self._theme_generic(split, getattr(theme, theme.theme_area.lower())) | self._theme_generic(split, getattr(theme, theme.theme_area.lower()), theme.theme_area) | ||||
| class USERPREF_PT_file(Panel): | class USERPREF_PT_file(Panel): | ||||
| bl_space_type = 'USER_PREFERENCES' | bl_space_type = 'USER_PREFERENCES' | ||||
| bl_label = "Files" | bl_label = "Files" | ||||
| bl_region_type = 'WINDOW' | bl_region_type = 'WINDOW' | ||||
| bl_options = {'HIDE_HEADER'} | bl_options = {'HIDE_HEADER'} | ||||
| ▲ Show 20 Lines • Show All 550 Lines • Show Last 20 Lines | |||||
Rather keep separate logic here, so common case can be kept understandable.
if th_delimiters is None: old logic else: new complicated logicThis will help make it more clear whats going on if we ever want to re-work the code later.