Anim: Common Playhead snapping for all editors
This patch adds snapping options for the playhead to all animation editors. The options can be modified through a new dropdown in the editor header. All editors will show all those options, and they are shared, so toggling the option in on editor will change it for all other editors too. Some options are not working/relevant in some editors for example Strips in the Dope Sheet. However for consistency the option is still shown. This is a separate menu from the transform snapping menu because you can toggle the snapping for transform and playhead separately. Putting it in the existing snapping transform menu would imply that it can be turned off with the magnet which is not the case. Playhead snapping is explicitly disabled for the drivers editor because there is no playhead to drag around. Snapping to Frame/Second intervals takes the scene start as a starting point. That means you can snap to the n-th second of the animation even though it might not start at frame 1. The preview range is NOT taken into account by design since the use case is working on a sub-section of the animation in which case the snap target should not change. Snapping is toggled by pressing CTRL as indicated by the status bar. Snapping to Frames/Seconds is absolute, meaning no matter how far away your cursor it will snap to the closest snap point. All others only snap to things if they are close to the cursor in pixel values. When mixing those two behaviors, it prefers relative snapping. If no point is close enough to snap relative, it will fall back to absolute snapping. Based on the prototype #135913 Part of #135794 Pull Request: https://projects.blender.org/blender/blender/pulls/137278
This commit is contained in:
committed by
Christoph Lendenfeld
parent
b734eae387
commit
87a28fa117
@@ -16,6 +16,8 @@ from bl_ui.properties_data_grease_pencil import (
|
||||
GreasePencil_LayerAdjustmentsPanel,
|
||||
GreasePencil_LayerDisplayPanel,
|
||||
)
|
||||
from bl_ui.space_toolsystem_common import PlayheadSnappingPanel
|
||||
|
||||
|
||||
from rna_prop_ui import PropertyPanel
|
||||
|
||||
@@ -216,6 +218,10 @@ class DOPESHEET_HT_header(Header):
|
||||
DOPESHEET_HT_editor_buttons.draw_header(context, layout)
|
||||
|
||||
|
||||
class DOPESHEET_PT_playhead_snapping(PlayheadSnappingPanel, Panel):
|
||||
bl_space_type = 'DOPESHEET_EDITOR'
|
||||
|
||||
|
||||
# Header for "normal" dopesheet editor modes (e.g. Dope Sheet, Action, Shape Keys, etc.)
|
||||
class DOPESHEET_HT_editor_buttons:
|
||||
|
||||
@@ -277,6 +283,8 @@ class DOPESHEET_HT_editor_buttons:
|
||||
text="",
|
||||
)
|
||||
|
||||
layout.popover(panel="DOPESHEET_PT_playhead_snapping")
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(tool_settings, "use_proportional_action", text="", icon_only=True)
|
||||
sub = row.row(align=True)
|
||||
@@ -1004,6 +1012,7 @@ classes = (
|
||||
DOPESHEET_PT_grease_pencil_layer_adjustments,
|
||||
DOPESHEET_PT_grease_pencil_layer_relations,
|
||||
DOPESHEET_PT_grease_pencil_layer_display,
|
||||
DOPESHEET_PT_playhead_snapping,
|
||||
)
|
||||
|
||||
if __name__ == "__main__": # only for live edit.
|
||||
|
||||
@@ -9,6 +9,12 @@ from bl_ui.space_dopesheet import (
|
||||
dopesheet_filter,
|
||||
)
|
||||
|
||||
from bl_ui.space_toolsystem_common import PlayheadSnappingPanel
|
||||
|
||||
|
||||
class GRAPH_PT_playhead_snapping(PlayheadSnappingPanel, Panel):
|
||||
bl_space_type = 'GRAPH_EDITOR'
|
||||
|
||||
|
||||
class GRAPH_HT_header(Header):
|
||||
bl_space_type = 'GRAPH_EDITOR'
|
||||
@@ -65,6 +71,7 @@ class GRAPH_HT_header(Header):
|
||||
panel="GRAPH_PT_snapping",
|
||||
text="",
|
||||
)
|
||||
layout.popover(panel="GRAPH_PT_playhead_snapping")
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(tool_settings, "use_proportional_fcurve", text="", icon_only=True)
|
||||
@@ -561,6 +568,7 @@ classes = (
|
||||
GRAPH_PT_filters,
|
||||
GRAPH_PT_snapping,
|
||||
GRAPH_PT_driver_snapping,
|
||||
GRAPH_PT_playhead_snapping,
|
||||
)
|
||||
|
||||
if __name__ == "__main__": # only for live edit.
|
||||
|
||||
@@ -10,6 +10,12 @@ from bl_ui.space_dopesheet import (
|
||||
dopesheet_filter,
|
||||
)
|
||||
|
||||
from bl_ui.space_toolsystem_common import PlayheadSnappingPanel
|
||||
|
||||
|
||||
class NLA_PT_playhead_snapping(PlayheadSnappingPanel, Panel):
|
||||
bl_space_type = 'NLA_EDITOR'
|
||||
|
||||
|
||||
class NLA_HT_header(Header):
|
||||
bl_space_type = 'NLA_EDITOR'
|
||||
@@ -39,6 +45,7 @@ class NLA_HT_header(Header):
|
||||
panel="NLA_PT_snapping",
|
||||
text="",
|
||||
)
|
||||
layout.popover(panel="NLA_PT_playhead_snapping")
|
||||
|
||||
|
||||
class NLA_PT_snapping(Panel):
|
||||
@@ -408,6 +415,7 @@ classes = (
|
||||
NLA_PT_filters,
|
||||
NLA_PT_action,
|
||||
NLA_PT_snapping,
|
||||
NLA_PT_playhead_snapping,
|
||||
)
|
||||
|
||||
if __name__ == "__main__": # only for live edit.
|
||||
|
||||
@@ -18,6 +18,7 @@ from bl_ui.properties_grease_pencil_common import (
|
||||
)
|
||||
from bl_ui.space_toolsystem_common import (
|
||||
ToolActivePanelHelper,
|
||||
PlayheadSnappingPanel,
|
||||
)
|
||||
from rna_prop_ui import PropertyPanel
|
||||
|
||||
@@ -185,6 +186,7 @@ class SEQUENCER_HT_header(Header):
|
||||
row.prop(tool_settings, "use_snap_sequencer", text="")
|
||||
sub = row.row(align=True)
|
||||
sub.popover(panel="SEQUENCER_PT_snapping")
|
||||
layout.popover(panel="SEQUENCER_PT_playhead_snapping")
|
||||
layout.separator_spacer()
|
||||
|
||||
if st.view_type in {'PREVIEW', 'SEQUENCER_PREVIEW'}:
|
||||
@@ -3028,6 +3030,10 @@ class SEQUENCER_PT_custom_props(SequencerButtonsPanel, PropertyPanel, Panel):
|
||||
bl_category = "Strip"
|
||||
|
||||
|
||||
class SEQUENCER_PT_playhead_snapping(PlayheadSnappingPanel, Panel):
|
||||
bl_space_type = 'SEQUENCE_EDITOR'
|
||||
|
||||
|
||||
class SEQUENCER_PT_snapping(Panel):
|
||||
bl_space_type = 'SEQUENCE_EDITOR'
|
||||
bl_region_type = 'HEADER'
|
||||
@@ -3093,9 +3099,6 @@ class SEQUENCER_PT_sequencer_snapping(Panel):
|
||||
col.prop(sequencer_tool_settings, "snap_ignore_muted", text="Muted Strips")
|
||||
col.prop(sequencer_tool_settings, "snap_ignore_sound", text="Sound Strips")
|
||||
|
||||
col = layout.column(heading="Current Frame", align=True)
|
||||
col.prop(sequencer_tool_settings, "use_snap_current_frame_to_strips", text="Snap to Strips")
|
||||
|
||||
|
||||
classes = (
|
||||
SEQUENCER_MT_change,
|
||||
@@ -3192,6 +3195,7 @@ classes = (
|
||||
SEQUENCER_PT_snapping,
|
||||
SEQUENCER_PT_preview_snapping,
|
||||
SEQUENCER_PT_sequencer_snapping,
|
||||
SEQUENCER_PT_playhead_snapping,
|
||||
)
|
||||
|
||||
if __name__ == "__main__": # only for live edit.
|
||||
|
||||
@@ -1239,6 +1239,32 @@ def _keymap_from_item(context, item):
|
||||
return None
|
||||
|
||||
|
||||
class PlayheadSnappingPanel:
|
||||
bl_region_type = 'HEADER'
|
||||
bl_label = "Playhead"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return True
|
||||
|
||||
def draw(self, context):
|
||||
tool_settings = context.tool_settings
|
||||
layout = self.layout
|
||||
col = layout.column()
|
||||
|
||||
col.prop(tool_settings, "use_snap_playhead")
|
||||
col.prop(tool_settings, "playhead_snap_distance")
|
||||
col.separator()
|
||||
col.label(text="Snap Target")
|
||||
col.prop(tool_settings, "snap_playhead_element", expand=True)
|
||||
col.separator()
|
||||
|
||||
if 'FRAME' in tool_settings.snap_playhead_element:
|
||||
col.prop(tool_settings, "snap_playhead_frame_step")
|
||||
if 'SECOND' in tool_settings.snap_playhead_element:
|
||||
col.prop(tool_settings, "snap_playhead_second_step")
|
||||
|
||||
|
||||
classes = (
|
||||
WM_MT_toolsystem_submenu,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user