timeline: automate waveform resizing

Now each UndoCommand won't have to handle it (unless it can introduce
specific optimizations).
This commit is contained in:
itsmattkc
2020-06-01 14:54:14 +10:00
parent a62960ecc0
commit 1fce380cc6
7 changed files with 103 additions and 72 deletions
+20
View File
@@ -59,6 +59,26 @@ NodeInput *ClipBlock::texture_input() const
return texture_input_;
}
void ClipBlock::LengthChangedEvent(const rational &old_length, const rational &new_length, const Timeline::MovementMode &mode)
{
// Positive if made longer, negative if made shorter
rational diff = new_length - old_length;
if (diff < rational()) {
if (mode == Timeline::kTrimIn) {
waveform().TrimIn(-diff);
} else {
waveform().TrimOut(-diff);
}
} else {
if (mode == Timeline::kTrimIn) {
waveform().PrependSilence(diff);
} else {
waveform().AppendSilence(diff);
}
}
}
void ClipBlock::InvalidateCache(const TimeRange &range, NodeInput *from, NodeInput *source)
{
// If signal is from texture input, transform all times from media time to sequence time