diff --git a/scripts/startup/bl_ui/space_sequencer.py b/scripts/startup/bl_ui/space_sequencer.py index 7d85168df95..4354154df1d 100644 --- a/scripts/startup/bl_ui/space_sequencer.py +++ b/scripts/startup/bl_ui/space_sequencer.py @@ -2764,6 +2764,7 @@ class SEQUENCER_PT_snapping(Panel): col = layout.column(heading="Snap to", align=True) col.prop(sequencer_tool_settings, "snap_to_current_frame") col.prop(sequencer_tool_settings, "snap_to_hold_offset") + col.prop(sequencer_tool_settings, "snap_to_markers") col = layout.column(heading="Ignore", align=True) col.prop(sequencer_tool_settings, "snap_ignore_muted", text="Muted Strips") diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index cd89861a079..a5d0ee90faf 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -29,7 +29,7 @@ extern "C" { /* Blender file format version. */ #define BLENDER_FILE_VERSION BLENDER_VERSION -#define BLENDER_FILE_SUBVERSION 19 +#define BLENDER_FILE_SUBVERSION 20 /* Minimum Blender version that supports reading file written with the current * version. Older Blender versions will test this and cancel loading the file, showing a warning to diff --git a/source/blender/blenloader/intern/versioning_400.cc b/source/blender/blenloader/intern/versioning_400.cc index 4c77556af0b..95f55a0b96b 100644 --- a/source/blender/blenloader/intern/versioning_400.cc +++ b/source/blender/blenloader/intern/versioning_400.cc @@ -63,6 +63,7 @@ #include "BKE_tracking.h" #include "SEQ_iterator.hh" +#include "SEQ_sequencer.hh" #include "ANIM_armature_iter.hh" #include "ANIM_bone_collections.hh" @@ -3184,6 +3185,13 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain) } } + if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 20)) { + LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { + SequencerToolSettings *sequencer_tool_settings = SEQ_tool_settings_ensure(scene); + sequencer_tool_settings->snap_mode |= SEQ_SNAP_TO_MARKERS; + } + } + /** * Always bump subversion in BKE_blender_version.h when adding versioning * code here, and wrap it inside a MAIN_VERSION_FILE_ATLEAST check. diff --git a/source/blender/editors/transform/transform_snap_sequencer.cc b/source/blender/editors/transform/transform_snap_sequencer.cc index ec3d19d0f23..9741f2a741e 100644 --- a/source/blender/editors/transform/transform_snap_sequencer.cc +++ b/source/blender/editors/transform/transform_snap_sequencer.cc @@ -152,7 +152,8 @@ static blender::VectorSet query_snap_targets(Scene *scene, return snap_targets; } -static int seq_get_snap_target_points_count(short snap_mode, +static int seq_get_snap_target_points_count(const Scene *scene, + short snap_mode, blender::Span snap_targets) { int count = 2; /* Strip start and end are always used. */ @@ -167,6 +168,10 @@ static int seq_get_snap_target_points_count(short snap_mode, count++; } + if (snap_mode & SEQ_SNAP_TO_MARKERS) { + count += BLI_listbase_count(&scene->markers); + } + return count; } @@ -175,7 +180,8 @@ static bool seq_snap_target_points_build(Scene *scene, TransSeqSnapData *snap_data, blender::Span snap_targets) { - const size_t point_count_target = seq_get_snap_target_points_count(snap_mode, snap_targets); + const size_t point_count_target = seq_get_snap_target_points_count( + scene, snap_mode, snap_targets); if (point_count_target == 0) { return false; } @@ -188,6 +194,13 @@ static bool seq_snap_target_points_build(Scene *scene, i++; } + if (snap_mode & SEQ_SNAP_TO_MARKERS) { + LISTBASE_FOREACH (TimeMarker *, marker, &scene->markers) { + snap_data->target_snap_points[i] = marker->frame; + i++; + } + } + for (Sequence *seq : snap_targets) { snap_data->target_snap_points[i] = SEQ_time_left_handle_frame_get(scene, seq); snap_data->target_snap_points[i + 1] = SEQ_time_right_handle_frame_get(scene, seq); diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index ae083e7a6fb..c8515fdd985 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -2416,6 +2416,7 @@ enum { SEQ_SNAP_TO_STRIPS = 1 << 0, SEQ_SNAP_TO_CURRENT_FRAME = 1 << 1, SEQ_SNAP_TO_STRIP_HOLD = 1 << 2, + SEQ_SNAP_TO_MARKERS = 1 << 3, }; /** #SequencerToolSettings::snap_flag */ diff --git a/source/blender/makesrna/intern/rna_scene.cc b/source/blender/makesrna/intern/rna_scene.cc index 35668cf1e94..08edfb782ce 100644 --- a/source/blender/makesrna/intern/rna_scene.cc +++ b/source/blender/makesrna/intern/rna_scene.cc @@ -4174,6 +4174,11 @@ static void rna_def_sequencer_tool_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Hold Offset", "Snap to strip hold offsets"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, nullptr); /* header redraw */ + prop = RNA_def_property(srna, "snap_to_markers", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, nullptr, "snap_mode", SEQ_SNAP_TO_MARKERS); + 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_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"); diff --git a/source/blender/sequencer/intern/sequencer.cc b/source/blender/sequencer/intern/sequencer.cc index df2bff14546..969e6ac9f9b 100644 --- a/source/blender/sequencer/intern/sequencer.cc +++ b/source/blender/sequencer/intern/sequencer.cc @@ -331,7 +331,7 @@ SequencerToolSettings *SEQ_tool_settings_init() MEM_callocN(sizeof(SequencerToolSettings), "Sequencer tool settings")); tool_settings->fit_method = SEQ_SCALE_TO_FIT; tool_settings->snap_mode = SEQ_SNAP_TO_STRIPS | SEQ_SNAP_TO_CURRENT_FRAME | - SEQ_SNAP_TO_STRIP_HOLD; + SEQ_SNAP_TO_STRIP_HOLD | SEQ_SNAP_TO_MARKERS; tool_settings->snap_distance = 15; tool_settings->overlap_mode = SEQ_OVERLAP_SHUFFLE; tool_settings->pivot_point = V3D_AROUND_LOCAL_ORIGINS;