diff options
author | Paul Golter <paulgolter> | 2021-07-15 16:49:25 +0300 |
---|---|---|
committer | Sebastian Parborg <darkdefende@gmail.com> | 2021-07-15 16:49:25 +0300 |
commit | 3df40cc343f09926c044dd9eeb7f81f5360ff330 (patch) | |
tree | 2806e457008b5f79240cbee1d18e518c2c0d44f1 /source/blender/editors/space_sequencer/sequencer_edit.c | |
parent | 468d59e496eb3263c1b0284459c03b599fe84a2a (diff) |
Fix: Subtitles: Order of channels in the .blend file will be kept in the .rst file.
If text strips have the same start frame but are stacked on top of each
other in different channels the order in which they are written in the
.rst file was random before.
Reviewed By: Richard Antalik
Differential Revision: https://developer.blender.org/D11903
Diffstat (limited to 'source/blender/editors/space_sequencer/sequencer_edit.c')
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_edit.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 75cf8542f67..4b26469aad3 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -2934,6 +2934,23 @@ void SEQUENCER_OT_change_path(struct wmOperatorType *ot) /** \name Export Subtitles Operator * \{ */ +/** Comparison function suitable to be used with BLI_listbase_sort(). */ +static int seq_cmp_time_startdisp_channel(const void *a, const void *b) +{ + Sequence *seq_a = (Sequence *)a; + Sequence *seq_b = (Sequence *)b; + + int seq_a_start = SEQ_transform_get_left_handle_frame(seq_a); + int seq_b_start = SEQ_transform_get_left_handle_frame(seq_b); + + /** If strips have the same start frame favor the one with a higher channel. **/ + if (seq_a_start == seq_b_start) { + return seq_a->machine > seq_b->machine; + } + + return (seq_a_start > seq_b_start); +} + static int sequencer_export_subtitles_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) @@ -3003,7 +3020,7 @@ static int sequencer_export_subtitles_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - BLI_listbase_sort(&text_seq, SEQ_time_cmp_time_startdisp); + BLI_listbase_sort(&text_seq, seq_cmp_time_startdisp_channel); /* Open and write file. */ file = BLI_fopen(filepath, "w"); |