FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
edit: a ripple trim that shortens a transition's second clip keeps the transition within it
dotCooCoo209157740ad4
diff --git a/crates/edit/src/lib.rs b/crates/edit/src/lib.rsindex a0e8ef968..2afe38550 100644--- a/crates/edit/src/lib.rs+++ b/crates/edit/src/lib.rs@@ -196,9 +196,10 @@ fn transition_anchor(track: &Track, tr: &Transition) -> Option<Tick> {}/// Keep transitions on their edit points after an edit moved cuts (ripple trim, roll, slide, ripple-/// speed change): each transition shifts by as much as its anchor clip edge moved. A shifted-/// transition between two clips stays within them (shortened when they are now shorter than it),-/// and its stored alignment follows where that leaves it on the cut.+/// speed change): each transition shifts by as much as its anchor clip edge moved. A transition+/// between two clips stays within them, whether its cut moved or one of the clips got shorter+/// (shortened when they are now shorter than it), and its stored alignment follows where that+/// leaves it on the cut.fn transitions_follow_cuts(before: &Sequence, after: &mut Sequence) {let frame = after.settings.frame_rate.frame_duration();for track in after.all_tracks_mut() {@@ -220,8 +221,7 @@ fn transitions_follow_cuts(before: &Sequence, after: &mut Sequence) {.collect();for (tr, (d, within)) in track.transitions.iter_mut().zip(shifts) {tr.start += d;- if d != Tick::ZERO- && let Some((lo, cut, hi)) = within+ if let Some((lo, cut, hi)) = within&& (tr.start < lo || tr.end() > hi){tr.duration = tr.duration.min(hi - lo);diff --git a/crates/edit/src/tests.rs b/crates/edit/src/tests.rsindex ee824cbca..dbace3b41 100644--- a/crates/edit/src/tests.rs+++ b/crates/edit/src/tests.rs@@ -938,6 +938,33 @@ fn edits_that_move_a_cut_keep_its_transition_on_its_clips() {}}+/// A ripple trim that shortens the second clip from its end leaves the cut where it is, and the+/// transition on that cut still stays within its two clips.+#[test]+fn a_ripple_trim_of_the_second_clips_end_keeps_the_transition_within_it() {+ let mut fx = Fx::new();+ let v1 = fx.v(0);+ let a = fx.put(v1, 0, 10, 10);+ let b = fx.put(v1, 10, 10, 10);+ fx.seq.track_mut(v1).unwrap().transitions = vec![Transition {+ id: TransitionId(1),+ effect: filmcraft_project::find_effect("cross_dissolve").unwrap().instance(),+ start: f(8),+ duration: f(4),+ from: Some(a),+ to: Some(b),+ align: TransitionAlign::CenterAtCut,+ reverse: false,+ }];+ let mut n = fx.next;+ trim(&mut fx.seq, b, Edge::Out, TrimMode::Ripple, -f(9), &mut Fx::ctx(&mut n)).unwrap();+ assert_eq!(fx.spans(v1), vec![(0, 10), (10, 1)]);+ let tr = &fx.seq.track(v1).unwrap().transitions[0];+ assert_eq!((tr.start, tr.duration), (f(7), f(4)), "the transition ends with the second clip");+ assert_eq!(tr.align, TransitionAlign::CenterAtCut);+ fx.seq.check().unwrap();+}+/// #374: moving an edge must not change which media sits under any timeline time the clip still/// covers (the timeline's live trim preview draws its waveform from this item), and must leave the/// item as the trim itself does.