diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-03-13 05:24:46 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-03-13 05:32:10 +0300 |
commit | fac39dc160e4212d2fd11a5e9d73944f5b311734 (patch) | |
tree | 13eb4c6a520715a7a4a89a8b80a64a69488e2ebe /release | |
parent | 100854c17c057823aa9e8720369a2940be9138f4 (diff) |
UI: avoid sub-classing mix-ins for user-prefs
Also remove redundant staticmethod use.
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/startup/bl_ui/space_userpref.py | 115 |
1 files changed, 57 insertions, 58 deletions
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 562429aebeb..f20141bb13d 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -83,7 +83,8 @@ class USERPREF_PT_save_preferences(Panel): layout.operator("wm.save_userpref") -class PreferencePanel(Panel): +# Panel mix-in. +class PreferencePanel: """ Base class for panels to center align contents with some horizontal margin. Deriving classes need to implement a ``draw_props(context, layout)`` function. @@ -114,7 +115,7 @@ class PreferencePanel(Panel): row.label() # Needed so col above is centered. -class USERPREF_PT_interface_display(PreferencePanel): +class USERPREF_PT_interface_display(PreferencePanel, Panel): bl_label = "Display" @classmethod @@ -142,7 +143,7 @@ class USERPREF_PT_interface_display(PreferencePanel): flow.prop(view, "show_large_cursors") -class USERPREF_PT_interface_text(PreferencePanel): +class USERPREF_PT_interface_text(PreferencePanel, Panel): bl_label = "Text Rendering" bl_options = {'DEFAULT_CLOSED'} @@ -166,7 +167,7 @@ class USERPREF_PT_interface_text(PreferencePanel): flow.prop(view, "font_path_ui_mono") -class USERPREF_PT_interface_translation(PreferencePanel): +class USERPREF_PT_interface_translation(PreferencePanel, Panel): bl_label = "Translation" @classmethod @@ -195,7 +196,7 @@ class USERPREF_PT_interface_translation(PreferencePanel): flow.prop(view, "use_translate_new_dataname", text="New Data") -class USERPREF_PT_interface_editors(PreferencePanel): +class USERPREF_PT_interface_editors(PreferencePanel, Panel): bl_label = "Editors" @classmethod @@ -231,7 +232,7 @@ class USERPREF_PT_interface_menus(Panel): pass -class USERPREF_PT_interface_menus_mouse_over(PreferencePanel): +class USERPREF_PT_interface_menus_mouse_over(PreferencePanel, Panel): bl_label = "Open on Mouse Over" bl_parent_id = "USERPREF_PT_interface_menus" @@ -253,7 +254,7 @@ class USERPREF_PT_interface_menus_mouse_over(PreferencePanel): flow.prop(view, "open_sublevel_delay", text="Sub Level") -class USERPREF_PT_interface_menus_pie(PreferencePanel): +class USERPREF_PT_interface_menus_pie(PreferencePanel, Panel): bl_label = "Pie Menus" bl_parent_id = "USERPREF_PT_interface_menus" @@ -284,7 +285,7 @@ class USERPREF_PT_edit_objects(Panel): def draw(self, context): pass -class USERPREF_PT_edit_objects_new(PreferencePanel): +class USERPREF_PT_edit_objects_new(PreferencePanel, Panel): bl_label = "New Objects" bl_parent_id = "USERPREF_PT_edit_objects" @@ -299,7 +300,7 @@ class USERPREF_PT_edit_objects_new(PreferencePanel): flow.prop(edit, "use_enter_edit_mode", text="Enter Edit Mode") -class USERPREF_PT_edit_objects_duplicate_data(PreferencePanel): +class USERPREF_PT_edit_objects_duplicate_data(PreferencePanel, Panel): bl_label = "Duplicate Data" bl_parent_id = "USERPREF_PT_edit_objects" @@ -326,7 +327,7 @@ class USERPREF_PT_edit_objects_duplicate_data(PreferencePanel): col.prop(edit, "use_duplicate_texture", text="Texture") -class USERPREF_PT_edit_cursor(PreferencePanel): +class USERPREF_PT_edit_cursor(PreferencePanel, Panel): bl_label = "3D Cursor" @classmethod @@ -344,7 +345,7 @@ class USERPREF_PT_edit_cursor(PreferencePanel): flow.prop(edit, "use_cursor_lock_adjust") -class USERPREF_PT_edit_gpencil(PreferencePanel): +class USERPREF_PT_edit_gpencil(PreferencePanel, Panel): bl_label = "Grease Pencil" bl_options = {'DEFAULT_CLOSED'} @@ -363,7 +364,7 @@ class USERPREF_PT_edit_gpencil(PreferencePanel): flow.prop(edit, "grease_pencil_euclidean_distance", text="Euclidean Distance") -class USERPREF_PT_edit_annotations(PreferencePanel): +class USERPREF_PT_edit_annotations(PreferencePanel, Panel): bl_label = "Annotations" @classmethod @@ -381,7 +382,7 @@ class USERPREF_PT_edit_annotations(PreferencePanel): flow.prop(edit, "grease_pencil_eraser_radius", text="Eraser Radius") flow.prop(edit, "use_grease_pencil_simplify_stroke", text="Simplify Stroke") -class USERPREF_PT_edit_weight_paint(PreferencePanel): +class USERPREF_PT_edit_weight_paint(PreferencePanel, Panel): bl_label = "Weight Paint" bl_options = {'DEFAULT_CLOSED'} @@ -401,7 +402,7 @@ class USERPREF_PT_edit_weight_paint(PreferencePanel): col.template_color_ramp(view, "weight_color_range", expand=True) -class USERPREF_PT_edit_misc(PreferencePanel): +class USERPREF_PT_edit_misc(PreferencePanel, Panel): bl_label = "Miscellaneous" bl_options = {'DEFAULT_CLOSED'} @@ -420,7 +421,7 @@ class USERPREF_PT_edit_misc(PreferencePanel): flow.prop(edit, "node_margin", text="Node Auto-offset Margin") -class USERPREF_PT_animation_timeline(PreferencePanel): +class USERPREF_PT_animation_timeline(PreferencePanel, Panel): bl_label = "Timeline" @classmethod @@ -449,7 +450,7 @@ class USERPREF_PT_animation_timeline(PreferencePanel): flow.prop(view, "view_frame_keyframes") -class USERPREF_PT_animation_keyframes(PreferencePanel): +class USERPREF_PT_animation_keyframes(PreferencePanel, Panel): bl_label = "Keyframes" @classmethod @@ -467,7 +468,7 @@ class USERPREF_PT_animation_keyframes(PreferencePanel): flow.prop(edit, "use_keyframe_insert_needed", text="Only Insert Needed") -class USERPREF_PT_animation_autokey(PreferencePanel): +class USERPREF_PT_animation_autokey(PreferencePanel, Panel): bl_label = "Auto-Keyframing" bl_parent_id = "USERPREF_PT_animation_keyframes" @@ -482,7 +483,7 @@ class USERPREF_PT_animation_autokey(PreferencePanel): flow.prop(edit, "use_auto_keying", text="Enable in New Scenes") -class USERPREF_PT_animation_fcurves(PreferencePanel): +class USERPREF_PT_animation_fcurves(PreferencePanel, Panel): bl_label = "F-Curves" @classmethod @@ -502,7 +503,7 @@ class USERPREF_PT_animation_fcurves(PreferencePanel): flow.prop(edit, "use_insertkey_xyz_to_rgb", text="XYZ to RGB") -class USERPREF_PT_system_sound(PreferencePanel): +class USERPREF_PT_system_sound(PreferencePanel, Panel): bl_label = "Sound" @classmethod @@ -524,7 +525,7 @@ class USERPREF_PT_system_sound(PreferencePanel): sub.prop(system, "audio_sample_format", text="Sample Format") -class USERPREF_PT_system_cycles_devices(PreferencePanel): +class USERPREF_PT_system_cycles_devices(PreferencePanel, Panel): bl_label = "Cycles Render Devices" @classmethod @@ -551,7 +552,7 @@ class USERPREF_PT_system_cycles_devices(PreferencePanel): # col.row().prop(system, "opensubdiv_compute_type", text="") -class USERPREF_PT_viewport_display(PreferencePanel): +class USERPREF_PT_viewport_display(PreferencePanel, Panel): bl_label = "Display" @classmethod @@ -590,7 +591,7 @@ class USERPREF_PT_viewport_display(PreferencePanel): sub.prop(view, "mini_axis_brightness", text="Brightness") -class USERPREF_PT_viewport_quality(PreferencePanel): +class USERPREF_PT_viewport_quality(PreferencePanel, Panel): bl_label = "Quality" @classmethod @@ -611,7 +612,7 @@ class USERPREF_PT_viewport_quality(PreferencePanel): flow.prop(system, "use_edit_mode_smooth_wire") -class USERPREF_PT_viewport_textures(PreferencePanel): +class USERPREF_PT_viewport_textures(PreferencePanel, Panel): bl_label = "Textures" @classmethod @@ -631,7 +632,7 @@ class USERPREF_PT_viewport_textures(PreferencePanel): flow.prop(system, "image_draw_method", text="Image Display Method") -class USERPREF_PT_viewport_selection(PreferencePanel): +class USERPREF_PT_viewport_selection(PreferencePanel, Panel): bl_label = "Selection" bl_options = {'DEFAULT_CLOSED'} @@ -649,7 +650,7 @@ class USERPREF_PT_viewport_selection(PreferencePanel): flow.prop(system, "use_select_pick_depth") -class USERPREF_PT_system_memory(PreferencePanel): +class USERPREF_PT_system_memory(PreferencePanel, Panel): bl_label = "Memory & Limits" @classmethod @@ -724,7 +725,7 @@ class USERPREF_PT_theme(Panel): row.operator("preferences.reset_default_theme", text="Reset", icon='LOOP_BACK') -class USERPREF_PT_theme_user_interface(PreferencePanel): +class USERPREF_PT_theme_user_interface(PreferencePanel, Panel): bl_space_type = 'PREFERENCES' bl_region_type = 'WINDOW' bl_label = "User Interface" @@ -745,12 +746,11 @@ class USERPREF_PT_theme_user_interface(PreferencePanel): # Base class for dynamically defined widget color panels. -class PreferenceThemeWidgetColorPanel(Panel): +class PreferenceThemeWidgetColorPanel: bl_space_type = 'PREFERENCES' bl_region_type = 'WINDOW' bl_parent_id = "USERPREF_PT_theme_user_interface" - @staticmethod def draw(self, context): theme = context.preferences.themes[0] ui = theme.user_interface @@ -786,7 +786,7 @@ class PreferenceThemeWidgetColorPanel(Panel): return (prefs.active_section == 'THEMES') -class USERPREF_PT_theme_interface_state(PreferencePanel): +class USERPREF_PT_theme_interface_state(PreferencePanel, Panel): bl_label = "State" bl_options = {'DEFAULT_CLOSED'} bl_parent_id = "USERPREF_PT_theme_user_interface" @@ -821,7 +821,7 @@ class USERPREF_PT_theme_interface_state(PreferencePanel): col.prop(ui_state, "blend") -class USERPREF_PT_theme_interface_styles(PreferencePanel): +class USERPREF_PT_theme_interface_styles(PreferencePanel, Panel): bl_label = "Styles" bl_options = {'DEFAULT_CLOSED'} bl_parent_id = "USERPREF_PT_theme_user_interface" @@ -840,7 +840,7 @@ class USERPREF_PT_theme_interface_styles(PreferencePanel): flow.prop(ui, "widget_emboss") -class USERPREF_PT_theme_interface_gizmos(PreferencePanel): +class USERPREF_PT_theme_interface_gizmos(PreferencePanel, Panel): bl_label = "Axis & Gizmo Colors" bl_options = {'DEFAULT_CLOSED'} bl_parent_id = "USERPREF_PT_theme_user_interface" @@ -865,7 +865,7 @@ class USERPREF_PT_theme_interface_gizmos(PreferencePanel): col.prop(ui, "gizmo_b") -class USERPREF_PT_theme_interface_icons(PreferencePanel): +class USERPREF_PT_theme_interface_icons(PreferencePanel, Panel): bl_label = "Icon Colors" bl_options = {'DEFAULT_CLOSED'} bl_parent_id = "USERPREF_PT_theme_user_interface" @@ -883,7 +883,7 @@ class USERPREF_PT_theme_interface_icons(PreferencePanel): flow.prop(ui, "icon_shading") -class USERPREF_PT_theme_text_style(PreferencePanel): +class USERPREF_PT_theme_text_style(PreferencePanel, Panel): bl_label = "Text Style" bl_options = {'DEFAULT_CLOSED'} @@ -932,7 +932,7 @@ class USERPREF_PT_theme_text_style(PreferencePanel): self._ui_font_style(layout, style.widget_label) -class USERPREF_PT_theme_bone_color_sets(PreferencePanel): +class USERPREF_PT_theme_bone_color_sets(PreferencePanel, Panel): bl_label = "Bone Color Sets" bl_options = {'DEFAULT_CLOSED'} @@ -963,7 +963,7 @@ class USERPREF_PT_theme_bone_color_sets(PreferencePanel): # Base class for dynamically defined theme-space panels. -class PreferenceThemeSpacePanel(Panel): +class PreferenceThemeSpacePanel: bl_space_type = 'PREFERENCES' bl_region_type = 'WINDOW' @@ -1022,13 +1022,11 @@ class PreferenceThemeSpacePanel(Panel): for prop in props_ls: flow.prop(themedata, prop.identifier) - @staticmethod def draw_header(self, _context): if hasattr(self, "icon") and self.icon != 'NONE': layout = self.layout layout.label(icon=self.icon) - @staticmethod def draw(self, context): layout = self.layout theme = context.preferences.themes[0] @@ -1075,7 +1073,7 @@ class ThemeGenericClassGenerator(): for (name, wcol) in wcols: panel_id = "USERPREF_PT_theme_interface_" + wcol - paneltype = type(panel_id, (PreferenceThemeWidgetColorPanel,), { + paneltype = type(panel_id, (PreferenceThemeWidgetColorPanel, Panel), { "bl_label": name, "bl_options": {'DEFAULT_CLOSED'}, "draw": PreferenceThemeWidgetColorPanel.draw, @@ -1100,7 +1098,7 @@ class ThemeGenericClassGenerator(): for prop in props_ls: new_datapath = datapath + "." + prop.identifier if datapath else prop.identifier panel_id = parent_id + "_" + prop.identifier - paneltype = type(panel_id, (PreferenceThemeSpacePanel,), { + paneltype = type(panel_id, (PreferenceThemeSpacePanel, Panel), { "bl_label": rna_type.properties[prop.identifier].name, "bl_parent_id": parent_id, "bl_options": {'DEFAULT_CLOSED'}, @@ -1124,7 +1122,7 @@ class ThemeGenericClassGenerator(): panel_id = "USERPREF_PT_theme_" + theme_area.identifier.lower() # Generate panel-class from theme_area - paneltype = type(panel_id, (PreferenceThemeSpacePanel,), { + paneltype = type(panel_id, (PreferenceThemeSpacePanel, Panel), { "bl_label": theme_area.name, "bl_options": {'DEFAULT_CLOSED'}, "draw_header": PreferenceThemeSpacePanel.draw_header, @@ -1140,7 +1138,8 @@ class ThemeGenericClassGenerator(): theme_area, theme_area.identifier.lower()) -class FilePathsPanel(Panel): +# Panel mix-in. +class FilePathsPanel: bl_space_type = 'PREFERENCES' bl_region_type = 'WINDOW' @@ -1158,7 +1157,7 @@ class FilePathsPanel(Panel): self.draw_props(context, layout) -class USERPREF_PT_file_paths_data(FilePathsPanel): +class USERPREF_PT_file_paths_data(FilePathsPanel, Panel): bl_label = "Data" def draw_props(self, context, layout): @@ -1172,7 +1171,7 @@ class USERPREF_PT_file_paths_data(FilePathsPanel): col.prop(paths, "temporary_directory", text="Temporary Files") -class USERPREF_PT_file_paths_render(FilePathsPanel): +class USERPREF_PT_file_paths_render(FilePathsPanel, Panel): bl_label = "Render" def draw_props(self, context, layout): @@ -1183,7 +1182,7 @@ class USERPREF_PT_file_paths_render(FilePathsPanel): col.prop(paths, "render_cache_directory", text="Render Cache") -class USERPREF_PT_file_paths_applications(FilePathsPanel): +class USERPREF_PT_file_paths_applications(FilePathsPanel, Panel): bl_label = "Applications" def draw_props(self, context, layout): @@ -1196,7 +1195,7 @@ class USERPREF_PT_file_paths_applications(FilePathsPanel): col.prop(paths, "animation_player", text="Player") -class USERPREF_PT_file_paths_development(FilePathsPanel): +class USERPREF_PT_file_paths_development(FilePathsPanel, Panel): bl_label = "Development" @classmethod @@ -1209,7 +1208,7 @@ class USERPREF_PT_file_paths_development(FilePathsPanel): layout.prop(paths, "i18n_branches_directory", text="I18n Branches") -class USERPREF_PT_saveload_autorun(PreferencePanel): +class USERPREF_PT_saveload_autorun(PreferencePanel, Panel): bl_label = "Auto Run Python Scripts" bl_parent_id = "USERPREF_PT_saveload_blend" @@ -1240,7 +1239,7 @@ class USERPREF_PT_saveload_autorun(PreferencePanel): row.operator("wm.userpref_autoexec_path_remove", text="", icon='X', emboss=False).index = i -class USERPREF_PT_saveload_blend(PreferencePanel): +class USERPREF_PT_saveload_blend(PreferencePanel, Panel): bl_label = "Blend Files" @classmethod @@ -1270,7 +1269,7 @@ class USERPREF_PT_saveload_blend(PreferencePanel): flow.prop(paths, "recent_files") -class USERPREF_PT_saveload_blend_autosave(PreferencePanel): +class USERPREF_PT_saveload_blend_autosave(PreferencePanel, Panel): bl_label = "Auto Save" bl_parent_id = "USERPREF_PT_saveload_blend" @@ -1286,7 +1285,7 @@ class USERPREF_PT_saveload_blend_autosave(PreferencePanel): sub.prop(paths, "auto_save_time", text="Timer (mins)") -class USERPREF_PT_saveload_file_browser(PreferencePanel): +class USERPREF_PT_saveload_file_browser(PreferencePanel, Panel): bl_label = "File Browser" @classmethod @@ -1354,7 +1353,7 @@ class USERPREF_MT_ndof_settings(Menu): layout.prop(input_prefs, "ndof_lock_horizon", icon='NDOF_DOM') -class USERPREF_PT_input_keyboard(PreferencePanel): +class USERPREF_PT_input_keyboard(PreferencePanel, Panel): bl_label = "Keyboard" @classmethod @@ -1370,7 +1369,7 @@ class USERPREF_PT_input_keyboard(PreferencePanel): layout.prop(inputs, "use_numeric_input_advanced") -class USERPREF_PT_input_mouse(PreferencePanel): +class USERPREF_PT_input_mouse(PreferencePanel, Panel): bl_label = "Mouse" @classmethod @@ -1391,7 +1390,7 @@ class USERPREF_PT_input_mouse(PreferencePanel): flow.prop(inputs, "mouse_double_click_time", text="Double Click Speed") -class USERPREF_PT_navigation_orbit(PreferencePanel): +class USERPREF_PT_navigation_orbit(PreferencePanel, Panel): bl_label = "Orbit & Pan" @classmethod @@ -1420,7 +1419,7 @@ class USERPREF_PT_navigation_orbit(PreferencePanel): flow.prop(view, "rotation_angle") -class USERPREF_PT_navigation_zoom(PreferencePanel): +class USERPREF_PT_navigation_zoom(PreferencePanel, Panel): bl_label = "Zoom" @classmethod @@ -1444,7 +1443,7 @@ class USERPREF_PT_navigation_zoom(PreferencePanel): flow.prop(inputs, "use_zoom_to_mouse") -class USERPREF_PT_navigation_fly_walk(PreferencePanel): +class USERPREF_PT_navigation_fly_walk(PreferencePanel, Panel): bl_label = "Fly & Walk" @classmethod @@ -1462,7 +1461,7 @@ class USERPREF_PT_navigation_fly_walk(PreferencePanel): flow.prop(inputs, "use_camera_lock_parent") -class USERPREF_PT_navigation_fly_walk_navigation(PreferencePanel): +class USERPREF_PT_navigation_fly_walk_navigation(PreferencePanel, Panel): bl_label = "Walk" bl_parent_id = "USERPREF_PT_navigation_fly_walk" bl_options = {'DEFAULT_CLOSED'} @@ -1488,7 +1487,7 @@ class USERPREF_PT_navigation_fly_walk_navigation(PreferencePanel): sub.prop(walk, "walk_speed_factor") -class USERPREF_PT_navigation_fly_walk_gravity(PreferencePanel): +class USERPREF_PT_navigation_fly_walk_gravity(PreferencePanel, Panel): bl_label = "Gravity" bl_parent_id = "USERPREF_PT_navigation_fly_walk" bl_options = {'DEFAULT_CLOSED'} @@ -1518,7 +1517,7 @@ class USERPREF_PT_navigation_fly_walk_gravity(PreferencePanel): flow.prop(walk, "jump_height") -class USERPREF_PT_input_tablet(PreferencePanel): +class USERPREF_PT_input_tablet(PreferencePanel, Panel): bl_label = "Tablet" @classmethod @@ -1542,7 +1541,7 @@ class USERPREF_PT_input_tablet(PreferencePanel): flow.prop(inputs, "pressure_softness") -class USERPREF_PT_input_ndof(PreferencePanel): +class USERPREF_PT_input_ndof(PreferencePanel, Panel): bl_label = "NDOF" bl_options = {'DEFAULT_CLOSED'} |