Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(gpui): ripple 3D shots when removing clip transitions

Richie McIlroyac15f794b887
diff --git a/apps/desktop-gpui/src/editor_clips.rs b/apps/desktop-gpui/src/editor_clips.rs
index 0d1507b8e..ada39180a 100644
--- a/apps/desktop-gpui/src/editor_clips.rs
+++ b/apps/desktop-gpui/src/editor_clips.rs
@@ -230,6 +230,11 @@ pub(crate) fn drop_clip_transition(
ripple_track(&mut timeline.mask_segments, boundary, effective.duration);
ripple_track(&mut timeline.text_segments, boundary, effective.duration);
ripple_track(&mut timeline.caption_segments, boundary, effective.duration);
+ ripple_track(
+ &mut timeline.camera3d_segments,
+ boundary,
+ effective.duration,
+ );
ripple_keyboard_track(
&mut timeline.keyboard_segments,
boundary,
@@ -3887,6 +3892,21 @@ mod tests {
}
]))
.unwrap();
+ config.camera3d_segments = [(2.0, 4.0), (11.0, 15.0), (15.0, 18.0)]
+ .into_iter()
+ .map(|(start, end)| {
+ serde_json::from_value(serde_json::json!({
+ "start": start,
+ "end": end,
+ "tracks": { "zoom": [
+ { "time": 0.0, "value": 1.0 },
+ { "time": (end - start) / 2.0, "value": 1.5 },
+ { "time": end - start, "value": 2.0 }
+ ] }
+ }))
+ .unwrap()
+ })
+ .collect();
// Moving clip 0 to the end separates the 0|1 pair, dropping the 1s
// transition whose boundary sat at offset(1) + 1.0 = 10.0.
assert!(move_clip(&mut config, 0, 3));
@@ -3918,6 +3938,22 @@ mod tests {
);
assert_eq!(config.keyboard_segments[1].keys[0].time_offset, 500.0);
assert_eq!(config.keyboard_segments[1].keys[1].time_offset, 2500.0);
+ for (shot, (start, end)) in
+ config
+ .camera3d_segments
+ .iter()
+ .zip([(2.0, 4.0), (11.0, 16.0), (16.0, 19.0)])
+ {
+ assert_eq!((shot.start, shot.end), (start, end));
+ for (keyframe, (time, value)) in shot.tracks.zoom.iter().zip([
+ (0.0, 1.0),
+ ((end - start) / 2.0, 1.5),
+ (end - start, 2.0),
+ ]) {
+ assert!((keyframe.time - time).abs() < 1e-9);
+ assert_eq!(keyframe.value, value);
+ }
+ }
}
/// `computeDropIndex` (`:692-703`): the insertion point is after every
diff --git a/apps/desktop-gpui/src/editor_edits.rs b/apps/desktop-gpui/src/editor_edits.rs
index 7d44d34ed..93e1889d7 100644
--- a/apps/desktop-gpui/src/editor_edits.rs
+++ b/apps/desktop-gpui/src/editor_edits.rs
@@ -3968,6 +3968,16 @@ mod tests {
instant_animation: false,
edge_snap_ratio: 0.0,
}];
+ timeline.camera3d_segments = serde_json::from_value(serde_json::json!([
+ {
+ "start": 12.0, "end": 14.0,
+ "tracks": { "zoom": [
+ { "time": 0.0, "value": 1.0 },
+ { "time": 2.0, "value": 1.5 }
+ ] }
+ }
+ ]))
+ .unwrap();
let before = clip_timeline_duration(timeline);
assert_eq!(
merge_clip_segments(timeline, 0, ClipMergeDirection::Next),
@@ -3977,6 +3987,11 @@ mod tests {
assert!(timeline.transitions.is_empty());
assert!((timeline.zoom_segments[0].start - 13.0).abs() < 1e-9);
assert!((timeline.zoom_segments[0].end - 15.0).abs() < 1e-9);
+ let shot = &timeline.camera3d_segments[0];
+ assert_eq!((shot.start, shot.end), (13.0, 15.0));
+ assert_eq!(shot.tracks.zoom[0].time, 0.0);
+ assert_eq!(shot.tracks.zoom[1].time, 2.0);
+ assert_eq!(shot.tracks.zoom[1].value, 1.5);
}
#[test]