diff options
author | FĂ©lix <Miadim> | 2021-08-24 02:16:22 +0300 |
---|---|---|
committer | Richard Antalik <richardantalik@gmail.com> | 2021-08-24 02:21:08 +0300 |
commit | eec1ea0ccf2a47cbfa67e2cde250e44533c0d573 (patch) | |
tree | 859fbe4efd6243e56765df50b16027b2c8707746 | |
parent | 929d7597b345027b848c2997720e52b89c46a0ff (diff) |
VSE: Add Sequence.parent_meta() python API function
This function can be used to find metastrip parent of nested strip.
Reviewed By: ISS
Differential Revision: https://developer.blender.org/D11985
-rw-r--r-- | source/blender/makesrna/intern/rna_sequencer_api.c | 15 | ||||
-rw-r--r-- | source/blender/sequencer/SEQ_relations.h | 3 | ||||
-rw-r--r-- | source/blender/sequencer/intern/effects.c | 3 | ||||
-rw-r--r-- | source/blender/sequencer/intern/strip_relations.c | 20 | ||||
-rw-r--r-- | source/blender/sequencer/intern/utils.c | 21 | ||||
-rw-r--r-- | source/blender/sequencer/intern/utils.h | 4 |
6 files changed, 41 insertions, 25 deletions
diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c index d98e03785d1..7ddbf450e6a 100644 --- a/source/blender/makesrna/intern/rna_sequencer_api.c +++ b/source/blender/makesrna/intern/rna_sequencer_api.c @@ -124,6 +124,14 @@ static Sequence *rna_Sequence_split( return r_seq; } +static Sequence *rna_Sequence_parent_meta(ID *id, Sequence *seq_self) +{ + Scene *scene = (Scene *)id; + Editing *ed = SEQ_editing_get(scene, false); + + return SEQ_find_metastrip_by_sequence(&ed->seqbase, NULL, seq_self); +} + static Sequence *rna_Sequences_new_clip(ID *id, ListBase *seqbase, Main *bmain, @@ -702,6 +710,13 @@ void RNA_api_sequence_strip(StructRNA *srna) "Meta to move the strip into"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + func = RNA_def_function(srna, "parent_meta", "rna_Sequence_parent_meta"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID); + RNA_def_function_ui_description(func, "Parent meta"); + /* return type */ + parm = RNA_def_pointer(func, "sequence", "Sequence", "", "Parent Meta"); + RNA_def_function_return(func, parm); + 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_relations.h b/source/blender/sequencer/SEQ_relations.h index 366c1002e22..54e53193b48 100644 --- a/source/blender/sequencer/SEQ_relations.h +++ b/source/blender/sequencer/SEQ_relations.h @@ -65,6 +65,9 @@ void SEQ_cache_iterate( void *userdata, bool callback_init(void *userdata, size_t item_count), bool callback_iter(void *userdata, struct Sequence *seq, int timeline_frame, int cache_type)); +struct Sequence *SEQ_find_metastrip_by_sequence(ListBase *seqbase /* = ed->seqbase */, + struct Sequence *meta /* = NULL */, + struct Sequence *seq); #ifdef __cplusplus } #endif diff --git a/source/blender/sequencer/intern/effects.c b/source/blender/sequencer/intern/effects.c index 93ff6b4bf9c..fd686c3a8a0 100644 --- a/source/blender/sequencer/intern/effects.c +++ b/source/blender/sequencer/intern/effects.c @@ -61,6 +61,7 @@ #include "SEQ_effects.h" #include "SEQ_proxy.h" +#include "SEQ_relations.h" #include "SEQ_render.h" #include "SEQ_utils.h" @@ -3023,7 +3024,7 @@ static ImBuf *do_adjustment_impl(const SeqRenderData *context, Sequence *seq, fl if (!i) { Sequence *meta; - meta = seq_find_metastrip_by_sequence(&ed->seqbase, NULL, seq); + meta = SEQ_find_metastrip_by_sequence(&ed->seqbase, NULL, seq); if (meta) { i = do_adjustment_impl(context, meta, timeline_frame); diff --git a/source/blender/sequencer/intern/strip_relations.c b/source/blender/sequencer/intern/strip_relations.c index 409b5f6a2e4..ec70a683da5 100644 --- a/source/blender/sequencer/intern/strip_relations.c +++ b/source/blender/sequencer/intern/strip_relations.c @@ -504,3 +504,23 @@ void SEQ_relations_check_uuids_unique_and_report(const Scene *scene) BLI_gset_free(used_uuids, NULL); } + +/* Return immediate parent meta of sequence */ +struct Sequence *SEQ_find_metastrip_by_sequence(ListBase *seqbase, Sequence *meta, Sequence *seq) +{ + Sequence *iseq; + + for (iseq = seqbase->first; iseq; iseq = iseq->next) { + Sequence *rval; + + if (seq == iseq) { + return meta; + } + if (iseq->seqbase.first && + (rval = SEQ_find_metastrip_by_sequence(&iseq->seqbase, iseq, seq))) { + return rval; + } + } + + return NULL; +}
\ No newline at end of file diff --git a/source/blender/sequencer/intern/utils.c b/source/blender/sequencer/intern/utils.c index 98640ea8a5c..f946affe1d8 100644 --- a/source/blender/sequencer/intern/utils.c +++ b/source/blender/sequencer/intern/utils.c @@ -431,7 +431,7 @@ const Sequence *SEQ_get_topmost_sequence(const Scene *scene, int frame) return best_seq; } -/* in cases where we done know the sequence's listbase */ +/* in cases where we don't know the sequence's listbase */ ListBase *SEQ_get_seqbase_by_seq(ListBase *seqbase, Sequence *seq) { Sequence *iseq; @@ -449,25 +449,6 @@ ListBase *SEQ_get_seqbase_by_seq(ListBase *seqbase, Sequence *seq) return NULL; } -Sequence *seq_find_metastrip_by_sequence(ListBase *seqbase, Sequence *meta, Sequence *seq) -{ - Sequence *iseq; - - for (iseq = seqbase->first; iseq; iseq = iseq->next) { - Sequence *rval; - - if (seq == iseq) { - return meta; - } - if (iseq->seqbase.first && - (rval = seq_find_metastrip_by_sequence(&iseq->seqbase, iseq, seq))) { - return rval; - } - } - - return NULL; -} - /** * Only use as last resort when the StripElem is available but no the Sequence. * (needed for RNA) diff --git a/source/blender/sequencer/intern/utils.h b/source/blender/sequencer/intern/utils.h index 97f33bb3ae0..7aee7d229c9 100644 --- a/source/blender/sequencer/intern/utils.h +++ b/source/blender/sequencer/intern/utils.h @@ -31,10 +31,6 @@ struct Scene; bool sequencer_seq_generates_image(struct Sequence *seq); void seq_open_anim_file(struct Scene *scene, struct Sequence *seq, bool openfile); -struct Sequence *seq_find_metastrip_by_sequence(ListBase *seqbase /* = ed->seqbase */, - struct Sequence *meta /* = NULL */, - struct Sequence *seq); - #ifdef __cplusplus } #endif |