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
This commit is contained in:
@@ -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
|
||||
@@ -285,14 +289,6 @@ class CLIP_PT_tracking_settings(CLIP_PT_tracking_panel, Panel):
|
||||
layout = self.layout
|
||||
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)
|
||||
@@ -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):
|
||||
|
Reference in New Issue
Block a user