FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
Frame-held Regular In trim stops at the previous clip instead of overlapping it (#530)
MarekSpodBiedryd23b33a9fe04
diff --git a/crates/edit/src/lib.rs b/crates/edit/src/lib.rsindex ed66f951a..a8c027417 100644--- a/crates/edit/src/lib.rs+++ b/crates/edit/src/lib.rs@@ -538,7 +538,13 @@ pub fn clamp_trim(seq: &Sequence, clip: ClipId, edge: Edge, mode: TrimMode, deltlet max_ext = Tick((head(ctx, it).0 as f64 / speed).floor() as i64);let lo = if mode == TrimMode::Regular { (-(it.start - prev_end)).max(-max_ext) } else { -max_ext };let hi = it.duration - ctx.min_duration;- d = d.clamp(if it.frame_hold.is_some() { Tick::MIN } else { lo }, hi);+ // a frame hold needs no source head, but a Regular trim still stops at the previous clip+ let lo = match (it.frame_hold.is_some(), mode) {+ (true, TrimMode::Regular) => -(it.start - prev_end),+ (true, _) => Tick::MIN,+ (false, _) => lo,+ };+ d = d.clamp(lo, hi);}Edge::Out => {let lo = -(it.duration - ctx.min_duration);diff --git a/crates/edit/src/tests.rs b/crates/edit/src/tests.rsindex 558e1ebc4..03558b283 100644--- a/crates/edit/src/tests.rs+++ b/crates/edit/src/tests.rs@@ -253,6 +253,24 @@ fn regular_trim_respects_neighbours_and_handles() {fx.seq.check().unwrap();}+#[test]+fn held_regular_in_trim_stops_at_previous_clip() {+ let mut fx = Fx::new();+ let v1 = fx.v(0);+ fx.put(v1, 0, 10, 0);+ let b = fx.put(v1, 15, 10, 5);+ fx.seq.find_item_mut(b).unwrap().1.frame_hold = Some(f(5));+ let mut n = fx.next;+ // 5 frames of gap: a 20 frame extension is clamped to 5 instead of overlapping the previous clip+ let d = trim(&mut fx.seq, b, Edge::In, TrimMode::Regular, -f(20), &mut Fx::ctx(&mut n)).unwrap();+ assert_eq!(d, -f(5));+ assert_eq!(fx.spans(v1), vec![(0, 10), (10, 15)]);+ // no space left: nothing to do, and no error+ let d = trim(&mut fx.seq, b, Edge::In, TrimMode::Regular, -f(3), &mut Fx::ctx(&mut n)).unwrap();+ assert_eq!(d, Tick::ZERO);+ fx.seq.check().unwrap();+}+#[test]fn ripple_trim_shifts_following() {let mut fx = Fx::new();