Keyframes: moving keys keeps subframe spacing (#1012)

keys.move and the nudges snapped each key's destination to the nearest
frame, so moving keys a Quick Offset had staggered onto subframes put
them back on frames: four keys at 0, 1/3, 2/3 and 1 frame, moved one
frame, came out at 1, 1, 2 and 2. Layer bars kept theirs, because
layer.timing snaps the move, not the times.

The move is now rounded to whole frames and every key translated by it.
layer_shift turns a comp-time move into a layer-time move through the
layer's start and stretch (reversed too) without a round trip through
comp time; keys.quickOffset uses it as well.

Test: moving_staggered_keys_keeps_their_subframe_spacing (Quick Offset,
then keys.move and keys.nudgeForward; fails before: 1/3 frame lands on
a frame).
This commit is contained in:
tylerjenningsw
2026-10-12 18:49:34 -04:00
parent e2d50ec926
commit f72b8993ef
3 changed files with 31 additions and 11 deletions
+16
View File
@@ -252,3 +252,19 @@ fn roving_keys_follow_and_the_selection_stays_on_the_moved_keys() {
}
assert_eq!(s.state.selected_keys.iter().map(|k| k.layer.0).collect::<Vec<_>>(), vec![ids[1], ids[0]]);
}
#[test]
fn moving_staggered_keys_keeps_their_subframe_spacing() {
let (mut s, ids) = setup(4);
for id in &ids {
add_key(&mut s, *id, "transform/opacity", 0.0, json!(0));
}
select_keys(&mut s, &ids.iter().map(|id| (*id, "transform/opacity", 0.0)).collect::<Vec<_>>());
s.execute_checked("keys.quickOffset", json!({"delta": 1.0 / 30.0})).unwrap();
// A plain move (and a nudge) translates them: it used to put each key on its nearest frame.
s.execute_checked("keys.move", json!({"delta": 1.0 / 30.0})).unwrap();
s.execute_checked("keys.nudgeForward", json!({})).unwrap();
for (i, id) in ids.iter().enumerate() {
assert_eq!(key_times(&s, *id, "transform/opacity"), vec![2 * F + F * i as i64 / 3], "layer {i}");
}
}