Timeline: Puppet pin keyframes show in the Timeline (#273)

Moving a puppet pin keys its Position, but the Timeline didn't show
those keys where people look for them. U revealed every pin's Position
as one more flat "Position" row under the layer, indistinguishable from
the layer's own Position and from each other, and the reveal was a
snapshot: a pin placed or moved after U (or with the layer twirled open
and Effects closed) got keys that no row showed.

As in After Effects, revealed properties inside an effect now show
under the effect and its groups (Puppet > Mesh 1 > Deform > Puppet
Pin 1 > Position), twirled open by the reveal and closable like any
group; Transform and mask properties stay as they were. Placing, moving
or recording a pin in the viewer keeps its Position in view: on a
twirled-open layer its groups open, and a U reveal takes it in. A
collapsed layer stays collapsed. The keys select, move and delete like
any others.

Test: puppet_pin_keys_show_under_their_pins_in_the_timeline,
placing_a_pin_opens_its_groups_on_a_twirled_open_layer (ui_viewer).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bflatastic
2026-10-08 20:05:07 +07:00
co-authored by Claude Opus 5.5
parent fbc4080f53
commit 285297ed93
5 changed files with 235 additions and 15 deletions
+90
View File
@@ -801,6 +801,96 @@ fn puppet_pin_click_selects_and_delete_removes_only_the_pins() {
assert!(h.state().session.active_comp().unwrap().layer(LayerId(id)).is_some());
}
/// A pin's Position property and its keys' times (seconds).
fn pin_keys(h: &Harness<'_, EffectcraftApp>, layer: u64, pin: u64) -> (u64, Vec<f64>) {
let l = h.state().session.active_comp().unwrap().layer(LayerId(layer)).unwrap().clone();
let pos = l.props.find_group(pin).unwrap().get("position").unwrap().clone();
(pos.uid, pos.keys.iter().map(|k| k.time.seconds()).collect())
}
/// The keys the Timeline draws for a property, left to right.
fn timeline_keys(h: &Harness<'_, EffectcraftApp>, prop: u64) -> Vec<Pos2> {
let mut ks: Vec<Pos2> =
h.state().auto.query(&format!("timeline.key.{prop}.")).iter().map(|e| pos2(e.rect[0] + e.rect[2] / 2.0, e.rect[1] + e.rect[3] / 2.0)).collect();
ks.sort_by(|a, b| a.x.total_cmp(&b.x));
ks
}
/// The pin the last click placed (placing a pin selects it).
fn placed_pin(h: &Harness<'_, EffectcraftApp>) -> u64 {
h.state().session.state.selected_props.last().map(|(_, u)| *u).unwrap()
}
/// #273: U shows each pin's keyframed Position under its pin (Puppet ▸ Mesh 1 ▸ Deform ▸ Puppet
/// Pin 1 ▸ Position) rather than as one more "Position"; a pin moved or placed in the viewer
/// afterwards shows its keys there too (they were made but not shown); and pin keys select, move
/// and delete like any others.
#[test]
fn puppet_pin_keys_show_under_their_pins_in_the_timeline() {
let (mut h, id, bend) = puppet_harness();
h.state_mut().ui.tool = Tool::Puppet;
let pins: Vec<u64> = h.state().auto.previous.iter().filter_map(|e| e.id.strip_prefix("viewer.puppetPin.")?.parse().ok()).filter(|p| *p != bend).collect();
let ctx = h.ctx.clone();
effectcraft_ui_egui::menus::invoke(h.state_mut(), &ctx, "anim.reveal", json!({"kind": "keyframes"})).unwrap();
h.run_steps(3);
assert_eq!(pins.len(), 2);
for pin in &pins {
let row = h.state().auto.find(&format!("timeline.group.{pin}.name")).map(|e| e.label.clone()).unwrap_or_default();
assert!(row.starts_with("Puppet Pin"), "the pin's row: {row:?}");
assert_eq!(timeline_keys(&h, pin_keys(&h, id, *pin).0).len(), 1, "its key at 0 s");
}
// Moved at 1 s: keyed there, in view.
h.state_mut().session.set_time(effectcraft_engine::time::Tick::from_seconds_f64(1.0));
h.run_steps(2);
let pa = rect(&h, &format!("viewer.puppetPin.{}", pins[0])).center();
drag(&mut h, pa, pa + vec2(20.0, 10.0));
let (pos, times) = pin_keys(&h, id, pins[0]);
assert_eq!(times.len(), 2);
assert_eq!(timeline_keys(&h, pos).len(), 2, "both keys drawn");
// A pin placed after U shows with its key too.
let at = screen(&h, [320.0, 210.0]);
click(&mut h, at);
let new = placed_pin(&h);
assert!(!pins.contains(&new) && new != bend);
assert!(h.state().auto.find(&format!("timeline.group.{new}.name")).is_some(), "the new pin's row");
assert_eq!(timeline_keys(&h, pin_keys(&h, id, new).0).len(), 1, "and its key");
// Click the 1 s key, drag it half a second later, delete it.
let ks = timeline_keys(&h, pos);
click(&mut h, ks[1]);
assert_eq!(h.state().session.state.selected_keys.iter().map(|k| k.prop).collect::<Vec<_>>(), [pos]);
let half = (ks[1].x - ks[0].x) / 2.0;
drag(&mut h, ks[1], ks[1] + vec2(half, 0.0));
let t = pin_keys(&h, id, pins[0]).1;
assert!((t[1] - 1.5).abs() < 0.05, "moved: {t:?}");
h.input_mut().events.push(Event::Key { key: egui::Key::Delete, physical_key: None, pressed: true, repeat: false, modifiers: Default::default() });
h.run_steps(2);
assert_eq!(pin_keys(&h, id, pins[0]).1, [0.0], "deleted; the pin stays");
}
/// #273: on a layer twirled open in the Timeline, placing a pin twirls open Effects ▸ Puppet ▸
/// Mesh 1 ▸ Deform ▸ the pin, so its Position key shows; a collapsed layer stays collapsed, as
/// in After Effects.
#[test]
fn placing_a_pin_opens_its_groups_on_a_twirled_open_layer() {
let mut h = harness();
let s = &mut h.state_mut().session;
s.execute("edit.clear", json!({"layers": ["Plate"]})).unwrap();
s.execute("layer.select", json!({"layers": ["Box"]})).unwrap();
let id = s.state.selected_layers[0].0;
h.state_mut().ui.tool = Tool::Puppet;
h.run_steps(2);
let at = screen(&h, [300.0, 160.0]);
click(&mut h, at);
assert!(h.state().ui.timeline.open_groups.is_empty() && h.state().ui.timeline.open_layers.is_empty(), "collapsed stays collapsed");
let twirl = rect(&h, &format!("timeline.layer.{id}.twirl")).center();
click(&mut h, twirl);
assert!(h.state().ui.timeline.open_layers.contains(&id));
let at = screen(&h, [340.0, 200.0]);
click(&mut h, at);
let pin = placed_pin(&h);
assert_eq!(timeline_keys(&h, pin_keys(&h, id, pin).0).len(), 1, "the new pin's Position key shows");
}
/// Filled circles painted this frame (flattening nested shape lists).
fn circles(h: &Harness<'_, EffectcraftApp>) -> Vec<egui::epaint::CircleShape> {
fn walk(s: &egui::Shape, out: &mut Vec<egui::epaint::CircleShape>) {