VSE: Fix meta strip boundary can not be changed

In e1f3996d74, logic for changing metastrip start and end frame based
on contained strips was removed. This was done intentionally and
incorrect functionality wasn't noticed as drawing code reflected
seemingly correct state.

Original code was mostly correct, because meta strip doesn't store its
internal start and end points. This code was restored with minor
modifications so function `SEQ_time_update_sequence()` is fully self
contained as it is used not only by transform operator.

In addition, drawing glitches that happen when meta content is outside
of meta boundaries were fixed. These glitches were not caused by
e1f3996d74.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D11215
This commit is contained in:
Richard Antalik 2021-05-11 12:25:54 +02:00
parent d4783e019e
commit 41c0c79e31
2 changed files with 49 additions and 2 deletions

View File

@ -885,10 +885,12 @@ static void draw_seq_background(Scene *scene,
immUniformColor4ubv(col);
if (seq->startstill) {
immRectf(pos, seq->startdisp, y1, (float)(seq->start), y2);
const float content_start = min_ff(seq->enddisp, seq->start);
immRectf(pos, seq->startdisp, y1, content_start, y2);
}
if (seq->endstill) {
immRectf(pos, (float)(seq->start + seq->len), y1, seq->enddisp, y2);
const float content_end = max_ff(seq->startdisp, seq->start + seq->len);
immRectf(pos, content_end, y1, seq->enddisp, y2);
}
}
@ -1105,6 +1107,10 @@ static void draw_seq_strip(const bContext *C,
x2 = (seq->endstill) ? (seq->start + seq->len) : seq->enddisp;
y2 = seq->machine + SEQ_STRIP_OFSTOP;
/* Limit body to strip bounds. Meta strip can end up with content outside of strip range. */
x1 = min_ff(x1, seq->enddisp);
x2 = max_ff(x2, seq->startdisp);
float text_margin_y;
bool y_threshold;
if ((sseq->flag & SEQ_SHOW_STRIP_NAME) || (sseq->flag & SEQ_SHOW_STRIP_SOURCE) ||

View File

@ -39,6 +39,7 @@
#include "SEQ_render.h"
#include "SEQ_sequencer.h"
#include "SEQ_time.h"
#include "SEQ_transform.h"
#include "strip_time.h"
#include "utils.h"
@ -161,6 +162,36 @@ void SEQ_time_update_sequence_bounds(Scene *scene, Sequence *seq)
}
}
static void seq_time_update_meta_strip(Scene *scene, Sequence *seq_meta)
{
if (BLI_listbase_is_empty(&seq_meta->seqbase)) {
return;
}
int min = MAXFRAME * 2;
int max = -MAXFRAME * 2;
LISTBASE_FOREACH (Sequence *, seq, &seq_meta->seqbase) {
min = min_ii(seq->startdisp, min);
max = max_ii(seq->enddisp, max);
}
seq_meta->start = min + seq_meta->anim_startofs;
seq_meta->len = max - min;
seq_meta->len -= seq_meta->anim_startofs;
seq_meta->len -= seq_meta->anim_endofs;
seq_update_sound_bounds_recursive(scene, seq_meta);
}
static void seq_time_update_meta_strip_range(Scene *scene, Sequence *seq_meta)
{
seq_time_update_meta_strip(scene, seq_meta);
/* Prevent metastrip to move in timeline. */
SEQ_transform_set_left_handle_frame(seq_meta, seq_meta->startdisp);
SEQ_transform_set_right_handle_frame(seq_meta, seq_meta->enddisp);
}
void SEQ_time_update_sequence(Scene *scene, Sequence *seq)
{
Sequence *seqm;
@ -211,6 +242,16 @@ void SEQ_time_update_sequence(Scene *scene, Sequence *seq)
}
}
else {
if (seq->type == SEQ_TYPE_META) {
seq_time_update_meta_strip(scene, seq);
}
Editing *ed = SEQ_editing_get(scene, false);
MetaStack *ms = SEQ_meta_stack_active_get(ed);
if (ms != NULL) {
seq_time_update_meta_strip_range(scene, ms->parseq);
}
SEQ_time_update_sequence_bounds(scene, seq);
}
}