WIP: (Old) Add snapping in VSE Preview #122349

Closed
John Kiril Swenson wants to merge 2 commits from eliphaz:vse-preview-snapping into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
4 changed files with 69 additions and 8 deletions

View File

@ -174,18 +174,16 @@ class SEQUENCER_HT_header(Header):
if st.view_type == 'PREVIEW':
layout.prop(sequencer_tool_settings, "pivot_point", text="", icon_only=True)
layout.separator_spacer()
if st.view_type in {'SEQUENCER', 'SEQUENCER_PREVIEW'}:
row = layout.row(align=True)
row.prop(sequencer_tool_settings, "overlap_mode", text="")
if st.view_type in {'SEQUENCER', 'SEQUENCER_PREVIEW'}:
row = layout.row(align=True)
row.prop(tool_settings, "use_snap_sequencer", text="")
sub = row.row(align=True)
sub.popover(panel="SEQUENCER_PT_snapping")
layout.separator_spacer()
row = layout.row(align=True)
row.prop(tool_settings, "use_snap_sequencer", text="")
sub = row.row(align=True)
sub.popover(panel="SEQUENCER_PT_snapping")
layout.separator_spacer()
if st.view_type in {'PREVIEW', 'SEQUENCER_PREVIEW'}:
layout.prop(st, "display_mode", text="", icon_only=True)
@ -2816,12 +2814,51 @@ class SEQUENCER_PT_custom_props(SequencerButtonsPanel, PropertyPanel, Panel):
_property_type = (bpy.types.Sequence,)
bl_category = "Strip"
class SEQUENCER_PT_snapping(Panel):
bl_space_type = 'SEQUENCE_EDITOR'
bl_region_type = 'HEADER'
bl_label = ""
def draw(self, _context):
pass
class SEQUENCER_PT_preview_snapping(Panel):
bl_space_type = 'SEQUENCE_EDITOR'
bl_region_type = 'HEADER'
bl_parent_id = "SEQUENCER_PT_snapping"
bl_label = "Preview Snapping"
@classmethod
def poll(cls, context):
st = context.space_data
return st.view_type in {'PREVIEW', 'SEQUENCER_PREVIEW'}
def draw(self, context):
tool_settings = context.tool_settings
sequencer_tool_settings = tool_settings.sequencer_tool_settings
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
col = layout.column(heading="Bounds", align=True)
col.prop(sequencer_tool_settings, "snap_bounds_to_borders")
col = layout.column(heading="Pivot", align=True)
col.prop(sequencer_tool_settings, "snap_pivot_to_centers")
class SEQUENCER_PT_sequencer_snapping(Panel):
bl_space_type = 'SEQUENCE_EDITOR'
bl_region_type = 'HEADER'
bl_parent_id = "SEQUENCER_PT_snapping"
bl_label = "Sequencer Snapping"
@classmethod
def poll(cls, context):
st = context.space_data
return st.view_type in {'SEQUENCER', 'SEQUENCER_PREVIEW'}
def draw(self, context):
tool_settings = context.tool_settings
sequencer_tool_settings = tool_settings.sequencer_tool_settings
@ -2843,6 +2880,7 @@ class SEQUENCER_PT_snapping(Panel):
col.prop(sequencer_tool_settings, "use_snap_current_frame_to_strips", text="Snap to Strips")
classes = (
SEQUENCER_MT_change,
SEQUENCER_HT_tool_header,
@ -2931,6 +2969,8 @@ classes = (
SEQUENCER_PT_annotation_onion,
SEQUENCER_PT_snapping,
SEQUENCER_PT_sequencer_snapping,
SEQUENCER_PT_preview_snapping,
)
if __name__ == "__main__": # only for live edit.

View File

@ -3663,6 +3663,13 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
}
}
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 99)) { /* TODO: set subversion once patch is done */
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
SequencerToolSettings *sequencer_tool_settings = SEQ_tool_settings_ensure(scene);
sequencer_tool_settings->snap_mode |= SEQ_SNAP_BOUNDS_TO_BORDERS | SEQ_SNAP_PIVOT_TO_CENTERS;
}
}
/**
* Always bump subversion in BKE_blender_version.h when adding versioning
* code here, and wrap it inside a MAIN_VERSION_FILE_ATLEAST check.

View File

@ -2439,6 +2439,9 @@ enum {
SEQ_SNAP_TO_CURRENT_FRAME = 1 << 1,
SEQ_SNAP_TO_STRIP_HOLD = 1 << 2,
SEQ_SNAP_TO_MARKERS = 1 << 3,
SEQ_SNAP_BOUNDS_TO_BORDERS = 1 << 4,
SEQ_SNAP_PIVOT_TO_CENTERS = 1 << 5,
};
/** #SequencerToolSettings::snap_flag */

View File

@ -4217,6 +4217,17 @@ static void rna_def_sequencer_tool_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Markers", "Snap to markers");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, nullptr); /* header redraw */
prop = RNA_def_property(srna, "snap_bounds_to_borders", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "snap_mode", SEQ_SNAP_BOUNDS_TO_BORDERS);
RNA_def_property_ui_text(prop, "Borders", "Snap bounding boxes to preview borders");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, nullptr); /* header redraw */
prop = RNA_def_property(srna, "snap_pivot_to_centers", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "snap_mode", SEQ_SNAP_PIVOT_TO_CENTERS);
RNA_def_property_ui_text(
prop, "Centers", "Snap pivot to horizontal and vertical preview centers");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, nullptr); /* header redraw */
prop = RNA_def_property(srna, "snap_ignore_muted", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "snap_flag", SEQ_SNAP_IGNORE_MUTED);
RNA_def_property_ui_text(prop, "Ignore Muted Strips", "Don't snap to hidden strips");