From 4158405c0b9d32dd0c6cc1844bc06561b8513766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix?= Date: Fri, 19 Mar 2021 23:36:28 +0100 Subject: VSE: Add move_to_meta RNA API function This function can be used to move strips into meta strips with no side effects like change of selection state. Reviewed By: ISS Differential Revision: https://developer.blender.org/D10759 --- source/blender/makesrna/intern/rna_sequencer_api.c | 22 ++++++++++++++++++++++ source/blender/sequencer/SEQ_edit.h | 3 +++ source/blender/sequencer/intern/strip_edit.c | 22 ++++++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c index 00d8c43a111..04ca3cfdb32 100644 --- a/source/blender/makesrna/intern/rna_sequencer_api.c +++ b/source/blender/makesrna/intern/rna_sequencer_api.c @@ -81,6 +81,23 @@ static void rna_Sequence_swap_internal(Sequence *seq_self, } } +static void rna_Sequences_move_strip_to_meta(ID *id, + Sequence *seq_self, + Main *bmain, + Sequence *meta_dst) +{ + Scene *scene = (Scene *)id; + + /* Move strip to meta */ + SEQ_edit_move_strip_to_meta(scene, seq_self, meta_dst); + + /* Udate 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); +} + static Sequence *rna_Sequences_new_clip(ID *id, ListBase *seqbase, Main *bmain, @@ -607,6 +624,11 @@ void RNA_api_sequence_strip(StructRNA *srna) parm = RNA_def_pointer(func, "other", "Sequence", "Other", ""); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + func = RNA_def_function(srna, "move_to_meta", "rna_Sequences_move_strip_to_meta"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN); + parm = RNA_def_pointer(func, "meta_sequence", "Sequence", "Destination Meta Sequence", "Meta to move the strip into"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + func = RNA_def_function(srna, "invalidate_cache", "rna_Sequence_invalidate_cache_rnafunc"); RNA_def_function_flag(func, FUNC_USE_SELF_ID); RNA_def_function_ui_description(func, diff --git a/source/blender/sequencer/SEQ_edit.h b/source/blender/sequencer/SEQ_edit.h index c8f11803ca8..38ce665563c 100644 --- a/source/blender/sequencer/SEQ_edit.h +++ b/source/blender/sequencer/SEQ_edit.h @@ -33,6 +33,9 @@ struct Scene; struct Sequence; int SEQ_edit_sequence_swap(struct Sequence *seq_a, struct Sequence *seq_b, const char **error_str); +int SEQ_edit_move_strip_to_meta(struct Scene *scene, + struct Sequence *src_seq, + struct Sequence *dst_seqm); void SEQ_edit_flag_for_removal(struct Scene *scene, struct ListBase *seqbase, struct Sequence *seq); diff --git a/source/blender/sequencer/intern/strip_edit.c b/source/blender/sequencer/intern/strip_edit.c index bba026057d2..e21a25a7e4f 100644 --- a/source/blender/sequencer/intern/strip_edit.c +++ b/source/blender/sequencer/intern/strip_edit.c @@ -43,9 +43,11 @@ #include "SEQ_add.h" #include "SEQ_edit.h" #include "SEQ_effects.h" +#include "SEQ_relations.h" #include "SEQ_sequencer.h" #include "SEQ_time.h" #include "SEQ_transform.h" +#include "SEQ_utils.h" int SEQ_edit_sequence_swap(Sequence *seq_a, Sequence *seq_b, const char **error_str) { @@ -102,6 +104,26 @@ int SEQ_edit_sequence_swap(Sequence *seq_a, Sequence *seq_b, const char **error_ return 1; } +int SEQ_edit_move_strip_to_meta(Scene *scene, Sequence *src_seq, Sequence *dst_seqm) +{ + /* Find the appropriate seqbase */ + Editing *ed = SEQ_editing_get(scene, false); + ListBase *seqbase = SEQ_get_seqbase_by_seq(&ed->seqbase, src_seq); + + /* Move to meta */ + BLI_remlink(seqbase, src_seq); + BLI_addtail(&dst_seqm->seqbase, src_seq); + SEQ_relations_invalidate_cache_preprocessed(scene, src_seq); + + /* Update meta */ + SEQ_time_update_sequence(scene, dst_seqm); + if (SEQ_transform_test_overlap(&dst_seqm->seqbase, src_seq)) { + SEQ_transform_seqbase_shuffle(&dst_seqm->seqbase, src_seq, scene); + } + + return 0; +} + static void seq_update_muting_recursive(ListBase *seqbasep, Sequence *metaseq, int mute) { Sequence *seq; -- cgit v1.2.3