VSE: Implement Snapping to Markers #120450
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -152,7 +152,8 @@ static blender::VectorSet<Sequence *> 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,
|
||||
linen marked this conversation as resolved
Outdated
|
||||
short snap_mode,
|
||||
blender::Span<Sequence *> 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<Sequence *> 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);
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Minor: could this be
const Scene *
?I'm in agreement with this suggestion. I modeled the function parameters off of
seq_snap_target_points_build()
and theScene *
there is notconst
even though it probably could be as well. Let's wait and see what @iss has to say on the matter.The policy is: If it can be
const
, it should be. It is older code, so at the time it either wasn't policy, or I didn't notice...Sounds good! I have made it
const
.