VSE: Fix multicam splitting all selected strips
`split_multicam` used split operator, where if more strips than multicam were selected, all would be split, which is undesirable. Add `Sequence.split()` RNA API function. to split individual strips. Function accepts `frame` and `split_method arguments`. Returns right strip after splitting. In case when strip being split have effects, these will be split too, so no invalid state should be created. Selection is not handled, this is by design up to user. Reviewed By: sergey Differential Revision: https://developer.blender.org/D11926
This commit is contained in:
parent
1dcf0f9cf1
commit
53743adc29
|
@ -108,14 +108,13 @@ class SequencerSplitMulticam(Operator):
|
|||
if s.multicam_source == camera or camera >= s.channel:
|
||||
return {'FINISHED'}
|
||||
|
||||
if not s.select:
|
||||
s.select = True
|
||||
|
||||
cfra = context.scene.frame_current
|
||||
bpy.ops.sequencer.split(frame=cfra, type='SOFT', side='RIGHT')
|
||||
for s in context.scene.sequence_editor.sequences_all:
|
||||
if s.select and s.type == 'MULTICAM' and s.frame_final_start <= cfra and cfra < s.frame_final_end:
|
||||
context.scene.sequence_editor.active_strip = s
|
||||
right_strip = s.split(frame=cfra, split_method='SOFT')
|
||||
|
||||
if right_strip:
|
||||
s.select = False
|
||||
right_strip.select = True
|
||||
context.scene.sequence_editor.active_strip = right_strip
|
||||
|
||||
context.scene.sequence_editor.active_strip.multicam_source = camera
|
||||
return {'FINISHED'}
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include "RNA_access.h"
|
||||
#include "RNA_define.h"
|
||||
|
||||
#include "SEQ_edit.h"
|
||||
|
||||
#include "rna_internal.h"
|
||||
|
||||
#ifdef RNA_RUNTIME
|
||||
|
@ -99,6 +101,24 @@ static void rna_Sequences_move_strip_to_meta(
|
|||
WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene);
|
||||
}
|
||||
|
||||
static Sequence *rna_Sequence_split(
|
||||
ID *id, Sequence *seq, Main *bmain, int frame, int split_method)
|
||||
{
|
||||
Scene *scene = (Scene *)id;
|
||||
Editing *ed = SEQ_editing_get(scene, false);
|
||||
ListBase *seqbase = SEQ_get_seqbase_by_seq(&ed->seqbase, seq);
|
||||
|
||||
Sequence *r_seq = SEQ_edit_strip_split(bmain, scene, seqbase, seq, frame, split_method);
|
||||
|
||||
/* Update depsgraph. */
|
||||
DEG_relations_tag_update(bmain);
|
||||
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
|
||||
|
||||
WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene);
|
||||
|
||||
return r_seq;
|
||||
}
|
||||
|
||||
static Sequence *rna_Sequences_new_clip(ID *id,
|
||||
ListBase *seqbase,
|
||||
Main *bmain,
|
||||
|
@ -635,6 +655,12 @@ void RNA_api_sequence_strip(StructRNA *srna)
|
|||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
static const EnumPropertyItem seq_split_method_items[] = {
|
||||
{SEQ_SPLIT_SOFT, "SOFT", 0, "Soft", ""},
|
||||
{SEQ_SPLIT_HARD, "HARD", 0, "Hard", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
func = RNA_def_function(srna, "update", "rna_Sequence_update_rnafunc");
|
||||
RNA_def_function_flag(func, FUNC_USE_SELF_ID);
|
||||
RNA_def_function_ui_description(func, "Update the strip dimensions");
|
||||
|
@ -676,6 +702,18 @@ void RNA_api_sequence_strip(StructRNA *srna)
|
|||
"Invalidate cached images for strip and all dependent strips");
|
||||
parm = RNA_def_enum(func, "type", seq_cahce_type_items, 0, "Type", "Cache Type");
|
||||
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
||||
|
||||
func = RNA_def_function(srna, "split", "rna_Sequence_split");
|
||||
RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
|
||||
RNA_def_function_ui_description(func, "Split Sequence");
|
||||
parm = RNA_def_int(
|
||||
func, "frame", 0, INT_MIN, INT_MAX, "", "Frame where to split the strip", INT_MIN, INT_MAX);
|
||||
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
||||
parm = RNA_def_enum(func, "split_method", seq_split_method_items, 0, "", "");
|
||||
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
||||
/* Retirn type. */
|
||||
parm = RNA_def_pointer(func, "sequence", "Sequence", "", "Right side Sequence");
|
||||
RNA_def_function_return(func, parm);
|
||||
}
|
||||
|
||||
void RNA_api_sequence_elements(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
|
|
|
@ -407,6 +407,8 @@ Sequence *SEQ_edit_strip_split(Main *bmain,
|
|||
BLI_addtail(&left_strips, seq);
|
||||
}
|
||||
|
||||
SEQ_collection_free(collection);
|
||||
|
||||
/* Sort list, so that no strip can depend on next strip in list.
|
||||
* This is important for SEQ_time_update_sequence functionality. */
|
||||
SEQ_sort(&left_strips);
|
||||
|
|
Loading…
Reference in New Issue