UI: rename PresetMenu to PresetPanel, move to bl_ui.utils
authorCampbell Barton <ideasman42@gmail.com>
Wed, 13 Mar 2019 01:41:22 +0000 (12:41 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 13 Mar 2019 02:32:10 +0000 (13:32 +1100)
Confusing to call a menu a panel when subclasses need to define
panel specific variables.

Avoid having bl_ui depend on bl_operator module too.
Since this isn't an operator, add utils modules for shared types.

13 files changed:
intern/cycles/blender/addon/ui.py
release/scripts/startup/bl_operators/presets.py
release/scripts/startup/bl_ui/properties_data_camera.py
release/scripts/startup/bl_ui/properties_material_gpencil.py
release/scripts/startup/bl_ui/properties_output.py
release/scripts/startup/bl_ui/properties_particle.py
release/scripts/startup/bl_ui/properties_physics_cloth.py
release/scripts/startup/bl_ui/properties_physics_fluid.py
release/scripts/startup/bl_ui/properties_scene.py
release/scripts/startup/bl_ui/space_clip.py
release/scripts/startup/bl_ui/space_node.py
release/scripts/startup/bl_ui/space_view3d_toolbar.py
release/scripts/startup/bl_ui/utils.py [new file with mode: 0644]

index 93b1672..aea0a07 100644 (file)
 
 import bpy
 from bpy_extras.node_utils import find_node_input
-from bl_operators.presets import PresetMenu
+from bl_ui.utils import PresetPanel
 
 from bpy.types import Panel
 
 
-class CYCLES_PT_sampling_presets(PresetMenu):
+class CYCLES_PT_sampling_presets(PresetPanel, Panel):
     bl_label = "Sampling Presets"
     preset_subdir = "cycles/sampling"
     preset_operator = "script.execute_preset"
@@ -31,7 +31,7 @@ class CYCLES_PT_sampling_presets(PresetMenu):
     COMPAT_ENGINES = {'CYCLES'}
 
 
-class CYCLES_PT_integrator_presets(PresetMenu):
+class CYCLES_PT_integrator_presets(PresetPanel, Panel):
     bl_label = "Integrator Presets"
     preset_subdir = "cycles/integrator"
     preset_operator = "script.execute_preset"
index 4df0d32..098f5b0 100644 (file)
@@ -263,40 +263,6 @@ class ExecutePreset(Operator):
         return {'FINISHED'}
 
 
-class PresetMenu(Panel):
-    bl_space_type = 'PROPERTIES'
-    bl_region_type = 'HEADER'
-    bl_label = "Presets"
-    path_menu = Menu.path_menu
-
-    @classmethod
-    def draw_panel_header(cls, layout):
-        layout.emboss = 'NONE'
-        layout.popover(
-            panel=cls.__name__,
-            icon='PRESET',
-            text="",
-        )
-
-    @classmethod
-    def draw_menu(cls, layout, text=None):
-        if text is None:
-            text = cls.bl_label
-
-        layout.popover(
-            panel=cls.__name__,
-            icon='PRESET',
-            text=text,
-        )
-
-    def draw(self, context):
-        layout = self.layout
-        layout.emboss = 'PULLDOWN_MENU'
-        layout.operator_context = 'EXEC_DEFAULT'
-
-        Menu.draw_preset(self, context)
-
-
 class AddPresetRender(AddPresetBase, Operator):
     """Add or remove a Render Preset"""
     bl_idname = "render.preset_add"
index d196fe7..3a938cc 100644 (file)
@@ -20,7 +20,7 @@
 import bpy
 from bpy.types import Panel
 from rna_prop_ui import PropertyPanel
-from bl_operators.presets import PresetMenu
+from bl_ui.utils import PresetPanel
 
 
 class CameraButtonsPanel:
@@ -34,7 +34,7 @@ class CameraButtonsPanel:
         return context.camera and (engine in cls.COMPAT_ENGINES)
 
 
-class CAMERA_PT_presets(PresetMenu):
+class CAMERA_PT_presets(PresetPanel, Panel):
     bl_label = "Camera Presets"
     preset_subdir = "camera"
     preset_operator = "script.execute_preset"
@@ -42,7 +42,7 @@ class CAMERA_PT_presets(PresetMenu):
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
 
 
-class SAFE_AREAS_PT_presets(PresetMenu):
+class SAFE_AREAS_PT_presets(PresetPanel, Panel):
     bl_label = "Camera Presets"
     preset_subdir = "safe_areas"
     preset_operator = "script.execute_preset"
index e336286..24ba786 100644 (file)
@@ -20,7 +20,7 @@
 import bpy
 from bpy.types import Menu, Panel, UIList
 from rna_prop_ui import PropertyPanel
-from bl_operators.presets import PresetMenu
+from bl_ui.utils import PresetPanel
 
 from .properties_grease_pencil_common import (
     GreasePencilMaterialsPanel,
@@ -250,7 +250,7 @@ class MATERIAL_PT_gpencil_options(GPMaterialButtonsPanel, Panel):
         layout.prop(gpcolor, "pass_index")
 
 
-class MATERIAL_PT_gpencil_material_presets(PresetMenu):
+class MATERIAL_PT_gpencil_material_presets(PresetPanel, Panel):
     """Material settings"""
     bl_label = "Material Presets"
     preset_subdir = "gpencil_material"
index bd96152..ec7874f 100644 (file)
 # <pep8 compliant>
 import bpy
 from bpy.types import Menu, Panel, UIList
-from bl_operators.presets import PresetMenu
+from bl_ui.utils import PresetPanel
 
 
-class RENDER_PT_presets(PresetMenu):
+class RENDER_PT_presets(PresetPanel, Panel):
     bl_label = "Render Presets"
     preset_subdir = "render"
     preset_operator = "script.execute_preset"
     preset_add_operator = "render.preset_add"
 
 
-class RENDER_PT_ffmpeg_presets(PresetMenu):
+class RENDER_PT_ffmpeg_presets(PresetPanel, Panel):
     bl_label = "FFMPEG Presets"
     preset_subdir = "ffmpeg"
     preset_operator = "script.python_file_run"
index 7d0f6de..c85b800 100644 (file)
@@ -21,7 +21,7 @@ import bpy
 from bpy.types import Panel, Menu
 from rna_prop_ui import PropertyPanel
 from bpy.app.translations import pgettext_iface as iface_
-from bl_operators.presets import PresetMenu
+from bl_ui.utils import PresetPanel
 
 from .properties_physics_common import (
     point_cache_ui,
@@ -95,7 +95,7 @@ class PARTICLE_MT_context_menu(Menu):
         )
 
 
-class PARTICLE_PT_hair_dynamics_presets(PresetMenu):
+class PARTICLE_PT_hair_dynamics_presets(PresetPanel, Panel):
     bl_label = "Hair Dynamics Presets"
     preset_subdir = "hair_dynamics"
     preset_operator = "script.execute_preset"
index 7173164..4c8e056 100644 (file)
@@ -22,7 +22,7 @@ import bpy
 from bpy.types import (
     Panel,
 )
-from bl_operators.presets import PresetMenu
+from bl_ui.utils import PresetPanel
 
 from .properties_physics_common import (
     point_cache_ui,
@@ -34,7 +34,7 @@ def cloth_panel_enabled(md):
     return md.point_cache.is_baked is False
 
 
-class CLOTH_PT_presets(PresetMenu):
+class CLOTH_PT_presets(PresetPanel, Panel):
     bl_label = "Cloth Presets"
     preset_subdir = "cloth"
     preset_operator = "script.execute_preset"
index b3ec45c..17289cf 100644 (file)
@@ -23,10 +23,10 @@ from bpy.types import (
     Panel,
 )
 from bpy.app.translations import pgettext_iface as iface_
-from bl_operators.presets import PresetMenu
+from bl_ui.utils import PresetPanel
 
 
-class FLUID_PT_presets(PresetMenu):
+class FLUID_PT_presets(PresetPanel, Panel):
     bl_label = "Fluid Presets"
     preset_subdir = "fluid"
     preset_operator = "script.execute_preset"
index 49d0b40..f3243d9 100644 (file)
@@ -25,7 +25,6 @@ from bpy.types import (
 )
 
 from rna_prop_ui import PropertyPanel
-from bl_operators.presets import PresetMenu
 
 from .properties_physics_common import (
     point_cache_ui,
index 5895572..39c3597 100644 (file)
@@ -21,7 +21,7 @@
 import bpy
 from bpy.types import Panel, Header, Menu, UIList
 from bpy.app.translations import pgettext_iface as iface_
-from bl_operators.presets import PresetMenu
+from bl_ui.utils import PresetPanel
 from .properties_grease_pencil_common import (
     AnnotationDrawingToolsPanel,
     AnnotationDataPanel,
@@ -1460,7 +1460,7 @@ class CLIP_MT_tracking_context_menu(Menu):
                         text="Unlock Tracks").action = 'UNLOCK'
 
 
-class CLIP_PT_camera_presets(PresetMenu):
+class CLIP_PT_camera_presets(PresetPanel, Panel):
     """Predefined tracking camera intrinsics"""
     bl_label = "Camera Presets"
     preset_subdir = "tracking_camera"
@@ -1468,7 +1468,7 @@ class CLIP_PT_camera_presets(PresetMenu):
     preset_add_operator = "clip.camera_preset_add"
 
 
-class CLIP_PT_track_color_presets(PresetMenu):
+class CLIP_PT_track_color_presets(PresetPanel, Panel):
     """Predefined track color"""
     bl_label = "Color Presets"
     preset_subdir = "tracking_track_color"
@@ -1476,7 +1476,7 @@ class CLIP_PT_track_color_presets(PresetMenu):
     preset_add_operator = "clip.track_color_preset_add"
 
 
-class CLIP_PT_tracking_settings_presets(PresetMenu):
+class CLIP_PT_tracking_settings_presets(PresetPanel, Panel):
     """Predefined tracking settings"""
     bl_label = "Tracking Presets"
     preset_subdir = "tracking_settings"
index ca809a0..c2e5a97 100644 (file)
@@ -21,7 +21,7 @@ import bpy
 import nodeitems_utils
 from bpy.types import Header, Menu, Panel
 from bpy.app.translations import pgettext_iface as iface_
-from bl_operators.presets import PresetMenu
+from bl_ui.utils import PresetPanel
 from .properties_grease_pencil_common import (
     AnnotationDrawingToolsPanel,
     AnnotationDataPanel,
@@ -304,7 +304,7 @@ class NODE_MT_node(Menu):
         layout.operator("node.read_viewlayers")
 
 
-class NODE_PT_node_color_presets(PresetMenu):
+class NODE_PT_node_color_presets(PresetPanel, Panel):
     """Predefined node color"""
     bl_label = "Color Presets"
     preset_subdir = "node_color"
index ae58237..2257108 100644 (file)
@@ -31,7 +31,7 @@ from .properties_paint_common import (
     brush_texpaint_common,
     brush_texture_settings,
 )
-from bl_operators.presets import PresetMenu
+from bl_ui.utils import PresetPanel
 
 
 class View3DPanel:
@@ -1816,7 +1816,7 @@ class VIEW3D_PT_tools_grease_pencil_weight_appearance(GreasePencilAppearancePane
     bl_label = "Appearance"
 
 
-class VIEW3D_PT_gpencil_brush_presets(PresetMenu):
+class VIEW3D_PT_gpencil_brush_presets(PresetPanel, Panel):
     """Brush settings"""
     bl_label = "Brush Presets"
     preset_subdir = "gpencil_brush"
diff --git a/release/scripts/startup/bl_ui/utils.py b/release/scripts/startup/bl_ui/utils.py
new file mode 100644 (file)
index 0000000..8c7ceef
--- /dev/null
@@ -0,0 +1,56 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+
+from bpy.types import Menu
+
+
+# Panel mix-in class (don't register).
+class PresetPanel:
+    bl_space_type = 'PROPERTIES'
+    bl_region_type = 'HEADER'
+    bl_label = "Presets"
+    path_menu = Menu.path_menu
+
+    @classmethod
+    def draw_panel_header(cls, layout):
+        layout.emboss = 'NONE'
+        layout.popover(
+            panel=cls.__name__,
+            icon='PRESET',
+            text="",
+        )
+
+    @classmethod
+    def draw_menu(cls, layout, text=None):
+        if text is None:
+            text = cls.bl_label
+
+        layout.popover(
+            panel=cls.__name__,
+            icon='PRESET',
+            text=text,
+        )
+
+    def draw(self, context):
+        layout = self.layout
+        layout.emboss = 'PULLDOWN_MENU'
+        layout.operator_context = 'EXEC_DEFAULT'
+
+        Menu.draw_preset(self, context)