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/space_clip.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/space_clip.py')
-rw-r--r-- | release/scripts/startup/bl_ui/space_clip.py | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index a865eab1dbe..91e725b451d 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -21,6 +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 .properties_grease_pencil_common import ( GreasePencilDrawingToolsPanel, GreasePencilStrokeEditPanel, @@ -277,6 +278,9 @@ class CLIP_PT_tracking_settings(CLIP_PT_tracking_panel, Panel): bl_label = "Tracking Settings" bl_category = "Track" + def draw_header_preset(self, context): + CLIP_MT_tracking_settings_presets.draw_panel_header(self.layout) + def draw(self, context): sc = context.space_data @@ -286,14 +290,6 @@ class CLIP_PT_tracking_settings(CLIP_PT_tracking_panel, Panel): col = layout.column() row = col.row(align=True) - label = CLIP_MT_tracking_settings_presets.bl_label - row.menu('CLIP_MT_tracking_settings_presets', text=label) - row.operator("clip.tracking_settings_preset_add", - text="", icon='ZOOMIN') - row.operator("clip.tracking_settings_preset_add", - text="", icon='ZOOMOUT').remove_active = True - - row = col.row(align=True) row.prop(settings, "use_default_red_channel", text="R", toggle=True) row.prop(settings, "use_default_green_channel", @@ -625,12 +621,8 @@ class CLIP_PT_track(CLIP_PT_tracking_panel, Panel): layout.separator() row = layout.row(align=True) - label = bpy.types.CLIP_MT_track_color_presets.bl_label - row.menu('CLIP_MT_track_color_presets', text=label) + CLIP_MT_track_color_presets.draw_menu(row, 'Color Presets') row.menu('CLIP_MT_track_color_specials', text="", icon='DOWNARROW_HLT') - row.operator("clip.track_color_preset_add", text="", icon='ZOOMIN') - row.operator("clip.track_color_preset_add", - text="", icon='ZOOMOUT').remove_active = True row = layout.row() row.prop(act_track, "use_custom_color") @@ -720,19 +712,15 @@ class CLIP_PT_tracking_camera(Panel): return False + def draw_header_preset(self, context): + CLIP_MT_camera_presets.draw_panel_header(self.layout) + def draw(self, context): layout = self.layout sc = context.space_data clip = sc.clip - row = layout.row(align=True) - label = bpy.types.CLIP_MT_camera_presets.bl_label - row.menu('CLIP_MT_camera_presets', text=label) - row.operator("clip.camera_preset_add", text="", icon='ZOOMIN') - row.operator("clip.camera_preset_add", text="", - icon='ZOOMOUT').remove_active = True - col = layout.column(align=True) col.label(text="Sensor:") col.prop(clip.tracking.camera, "sensor_width", text="Width") @@ -1431,28 +1419,28 @@ class CLIP_MT_tracking_specials(Menu): text="Unlock Tracks").action = 'UNLOCK' -class CLIP_MT_camera_presets(Menu): +class CLIP_MT_camera_presets(PresetMenu): """Predefined tracking camera intrinsics""" bl_label = "Camera Presets" preset_subdir = "tracking_camera" preset_operator = "script.execute_preset" - draw = Menu.draw_preset + preset_add_operator = "clip.camera_preset_add" -class CLIP_MT_track_color_presets(Menu): +class CLIP_MT_track_color_presets(PresetMenu): """Predefined track color""" bl_label = "Color Presets" preset_subdir = "tracking_track_color" preset_operator = "script.execute_preset" - draw = Menu.draw_preset + preset_add_operator = "clip.track_color_preset_add" -class CLIP_MT_tracking_settings_presets(Menu): +class CLIP_MT_tracking_settings_presets(PresetMenu): """Predefined tracking settings""" bl_label = "Tracking Presets" preset_subdir = "tracking_settings" preset_operator = "script.execute_preset" - draw = Menu.draw_preset + preset_add_operator = "clip.tracking_settings_preset_add" class CLIP_MT_track_color_specials(Menu): |