forked from bartvdbraak/blender
UI: rename PresetMenu to PresetPanel, move to bl_ui.utils
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.
This commit is contained in:
parent
88fe48b56a
commit
100854c17c
@ -18,12 +18,12 @@
|
||||
|
||||
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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -20,17 +20,17 @@
|
||||
# <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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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,
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
56
release/scripts/startup/bl_ui/utils.py
Normal file
56
release/scripts/startup/bl_ui/utils.py
Normal file
@ -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)
|
Loading…
Reference in New Issue
Block a user