VSE: Refactor sorting functions

Recently `SEQ_sort()` function was split so functionality is provided
on per-seqbase basis. After discussion about this split, it turned out,
that per-seqbase operation is only that should be provided, because
RNA API functions need to be able to access arbitrary seqbase

Remove recently introduced function `seq_sort_seqbase` and change
`SEQ_sort` function to operate on seqbase.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D11297
This commit is contained in:
Richard Antalik 2021-05-19 22:45:43 +02:00
parent 58893eaef8
commit 97cf2a9fb1
8 changed files with 16 additions and 32 deletions

View File

@ -348,7 +348,7 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op)
}
}
SEQ_sort(scene);
SEQ_sort(SEQ_active_seqbase_get(ed));
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
@ -1443,7 +1443,7 @@ static int sequencer_split_exec(bContext *C, wmOperator *op)
}
}
SEQ_sort(scene);
SEQ_sort(SEQ_active_seqbase_get(ed));
}
if (changed) {
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
@ -1818,7 +1818,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op)
}
}
SEQ_sort(scene);
SEQ_sort(SEQ_active_seqbase_get(ed));
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
@ -2003,7 +2003,7 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op))
}
}
SEQ_sort(scene);
SEQ_sort(active_seqbase);
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
@ -2226,7 +2226,7 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op)
}
}
SEQ_sort(scene);
SEQ_sort(SEQ_active_seqbase_get(ed));
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);

View File

@ -491,7 +491,7 @@ static void freeSeqData(TransInfo *t, TransDataContainer *tc, TransCustomData *c
}
}
SEQ_sort(t->scene);
SEQ_sort(seqbasep);
}
else {
/* Canceled, need to update the strips display */

View File

@ -293,7 +293,7 @@ static void do_sequence_frame_change_update(Scene *scene, Sequence *seq)
if (SEQ_transform_test_overlap(seqbase, seq)) {
SEQ_transform_seqbase_shuffle(seqbase, seq, scene); /* XXX - BROKEN!, uses context seqbasep */
}
SEQ_sort(scene);
SEQ_sort(seqbase);
}
/* A simple wrapper around above func, directly usable as prop update func.
@ -476,7 +476,7 @@ static void rna_Sequence_channel_set(PointerRNA *ptr, int value)
/* XXX - BROKEN!, uses context seqbasep */
SEQ_transform_seqbase_shuffle_ex(seqbase, seq, scene, channel_delta);
}
SEQ_sort(scene);
SEQ_sort(seqbase);
SEQ_relations_invalidate_cache_composite(scene, seq);
}

View File

@ -35,7 +35,7 @@ struct Scene;
struct Sequence;
struct StripElem;
void SEQ_sort(struct Scene *scene);
void SEQ_sort(struct ListBase *seqbase);
void SEQ_sequence_base_unique_name_recursive(struct ListBase *seqbasep, struct Sequence *seq);
const char *SEQ_sequence_give_name(struct Sequence *seq);
struct ListBase *SEQ_get_seqbase_from_sequence(struct Sequence *seq, int *r_offset);

View File

@ -100,7 +100,7 @@ static void seq_add_generic_update(Scene *scene, ListBase *seqbase, Sequence *se
{
SEQ_sequence_base_unique_name_recursive(seqbase, seq);
SEQ_time_update_sequence_bounds(scene, seq);
SEQ_sort(scene);
SEQ_sort(seqbase);
SEQ_relations_invalidate_cache_composite(scene, seq);
}

View File

@ -407,7 +407,7 @@ Sequence *SEQ_edit_strip_split(Main *bmain,
/* Sort list, so that no strip can depend on next strip in list.
* This is important for SEQ_time_update_sequence functionality. */
seq_sort_seqbase(&left_strips);
SEQ_sort(&left_strips);
/* Duplicate ListBase. */
ListBase right_strips = {NULL, NULL};

View File

@ -59,9 +59,12 @@
*
* \param seqbase: ListBase with strips
*/
void seq_sort_seqbase(ListBase *seqbase)
void SEQ_sort(ListBase *seqbase)
{
if (seqbase == NULL) {
return;
}
/* all strips together per kind, and in order of y location ("machine") */
ListBase inputbase, effbase;
Sequence *seq, *seqt;
@ -103,24 +106,6 @@ void seq_sort_seqbase(ListBase *seqbase)
BLI_movelisttolist(seqbase, &effbase);
}
/**
* Sort strips in active seqbase. Effect strips are trailing the list and they are sorted by
* channel position as well.
* This is important for SEQ_time_update_sequence to work properly
*
* \param scene: Scene to look for active seqbase in
*/
void SEQ_sort(Scene *scene)
{
Editing *ed = SEQ_editing_get(scene, false);
if (ed == NULL) {
return;
}
seq_sort_seqbase(SEQ_active_seqbase_get(ed));
}
typedef struct SeqUniqueInfo {
Sequence *seq;
char name_src[SEQ_NAME_MAXSTR];

View File

@ -34,7 +34,6 @@ 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);
void seq_sort_seqbase(ListBase *seqbase);
#ifdef __cplusplus
}