diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-04-27 14:50:26 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-06-13 16:22:34 +0300 |
commit | 7a10cfe7fe01bbeb7588239a9fd743ecc6af6c39 (patch) | |
tree | 05b5b281f0aef36fc27bcaf4b8b9aa9e14d193e3 /release/scripts/startup/bl_ui/properties_data_camera.py | |
parent | 1664ccb6752adf1bcf326b72d1230aa9b667a1fb (diff) |
UI: preset popover buttons in panel headers.
Moves the preset into a menu for the panel header, so it can be changed
without opening the panel and takes up less space. Two remaining issues:
* For long lists the add new preset button can be scrolled off screen.
* We should support showing the name of the chosen preset in the panel
header, but the current preset system does not support detecting which
preset is used.
Differential Revision: https://developer.blender.org/D3366
Diffstat (limited to 'release/scripts/startup/bl_ui/properties_data_camera.py')
-rw-r--r-- | release/scripts/startup/bl_ui/properties_data_camera.py | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_camera.py b/release/scripts/startup/bl_ui/properties_data_camera.py index 132a226f287..22c7964173b 100644 --- a/release/scripts/startup/bl_ui/properties_data_camera.py +++ b/release/scripts/startup/bl_ui/properties_data_camera.py @@ -20,6 +20,7 @@ import bpy from bpy.types import Panel, Menu from rna_prop_ui import PropertyPanel +from bl_operators.presets import PresetMenu class CameraButtonsPanel: @@ -33,20 +34,20 @@ class CameraButtonsPanel: return context.camera and (engine in cls.COMPAT_ENGINES) -class CAMERA_MT_presets(Menu): +class CAMERA_MT_presets(PresetMenu): bl_label = "Camera Presets" preset_subdir = "camera" preset_operator = "script.execute_preset" + preset_add_operator = "camera.preset_add" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} - draw = Menu.draw_preset -class SAFE_AREAS_MT_presets(Menu): +class SAFE_AREAS_MT_presets(PresetMenu): bl_label = "Camera Presets" preset_subdir = "safe_areas" preset_operator = "script.execute_preset" + preset_add_operator = "safe_areas.preset_add" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} - draw = Menu.draw_preset class DATA_PT_context_camera(CameraButtonsPanel, Panel): @@ -185,17 +186,14 @@ class DATA_PT_camera(CameraButtonsPanel, Panel): bl_label = "Camera" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + def draw_header_preset(self, context): + CAMERA_MT_presets.draw_panel_header(self.layout) + def draw(self, context): layout = self.layout cam = context.camera - row = layout.row(align=True) - - row.menu("CAMERA_MT_presets", text=bpy.types.CAMERA_MT_presets.bl_label) - row.operator("camera.preset_add", text="", icon='ZOOMIN') - row.operator("camera.preset_add", text="", icon='ZOOMOUT').remove_active = True - layout.use_property_split = True col = layout.column() @@ -410,6 +408,9 @@ class DATA_PT_camera_safe_areas(CameraButtonsPanel, Panel): self.layout.prop(cam, "show_safe_areas", text="") + def draw_header_preset(self, context): + SAFE_AREAS_MT_presets.draw_panel_header(self.layout) + def draw(self, context): layout = self.layout safe_data = context.scene.safe_areas @@ -430,13 +431,6 @@ def draw_display_safe_settings(layout, safe_data, settings): layout.use_property_split = True - row = layout.row(align=True) - row.menu("SAFE_AREAS_MT_presets", text=bpy.types.SAFE_AREAS_MT_presets.bl_label) - row.operator("safe_areas.preset_add", text="", icon='ZOOMIN') - row.operator("safe_areas.preset_add", text="", icon='ZOOMOUT').remove_active = True - - layout.separator() - col = layout.column() col.active = show_safe_areas |