M5.10: keyframes behave like After Effects: drags never destroy keys, stretched layers, Shift/Ctrl/Ctrl+Alt clicks, locked layers, Hold off

- A drag (keys.move steps sharing a merge key) applies its total offset to the keys as they
  were before it (`Session::key_move`, `prop::shift_keys`): dragging over another key of the
  property no longer deletes it; only the drop position replaces a key, as in After Effects.
- Keys of time-stretched layers move with the pointer: offsets are applied in comp time and
  snapped to comp frames (drags and Alt+Arrow nudges; they moved by the layer-time distance).
- Shift+click toggles a key in or out of the selection (`keys.select {toggle}`); Ctrl+click
  switches Linear ↔ Auto Bezier and Ctrl+Alt+click toggles Hold.
- Keys of locked layers can't be selected (clicks, marquee, Select All Keyframes), so nothing
  edits them.
- Toggle Hold off returns an eased key to Bezier (it always restored Linear).
- Shift-dragging a key snaps to everything the current time snaps to — other keys, layer in /
  out points, layer and comp markers, the work area — and a tooltip shows the key's time and how
  many frames it moved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bflatastic
2026-10-05 07:40:42 +07:00
co-authored by Claude Opus 5.5
parent 3b6b390f68
commit 9929b5f9ac
6 changed files with 262 additions and 28 deletions
+5 -6
View File
@@ -6,7 +6,7 @@ use effectcraft_project::{LayerId, Property, Uid};
use effectcraft_time::Tick;
use serde_json::{Value, json};
use super::prop::{edit_keys, prop_ref};
use super::prop::prop_ref;
use super::{CommandSpec, bad, comp_id, f_p, has_comp, has_keys, layers_p, merge_p, str_p, time_p};
use crate::{EngineError, KeyClip, KeyRef, Result, Session, cmd, query};
@@ -145,6 +145,8 @@ fn select_all(s: &mut Session, p: &Value) -> Result<Value> {
l.props.walk("", &mut |_, pr| sel.extend(pr.keys.iter().map(|k| KeyRef { layer: l.id, prop: pr.uid, time: k.time })));
}
}
// Keys of locked layers can't be selected.
sel.retain(|k| comp.layer(k.layer).is_some_and(|l| !l.switches.locked));
s.state.selected_keys = sel;
Ok(json!(s.state.selected_keys.len()))
}
@@ -153,11 +155,8 @@ fn select_all(s: &mut Session, p: &Value) -> Result<Value> {
fn nudge(s: &mut Session, p: &Value) -> Result<Value> {
let frames = p.get("frames").and_then(Value::as_i64).ok_or_else(|| bad("keys.nudge", "missing `frames`"))?;
let comp = s.active_comp().ok_or(EngineError::NoComp)?;
let d = Tick(comp.frame_duration().0 * frames);
edit_keys(s, "Nudge Keyframes", merge_p(p), move |_, _, t| {
*t += d;
true
})
let d = Tick(comp.frame_duration().0.saturating_mul(frames));
super::prop::shift_keys(s, "Nudge Keyframes", merge_p(p), d)
}
/// Edit one key directly: move it in time and/or set its value (Graph Editor drags).