Timeline: colour properties get an eyedropper after their swatch, as in After Effects (#633)

A shape's Fill and Stroke Color (and every other colour property) in the
Timeline only had a swatch that opens the colour picker; After Effects puts
an eyedropper next to it to sample a colour from the Composition panel.
The Timeline now shows that eyedropper (`timeline.prop.<uid>.eyedropper`),
reusing Effect Controls' viewer pick: click it, then click in the
Composition panel, and the property is set to the sampled colour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QiAJeFttZp83Fh7YuzAR5f
This commit is contained in:
Claude
2026-10-10 21:11:53 +00:00
parent d3b26f2a65
commit 1bcfe6912d
3 changed files with 60 additions and 2 deletions
@@ -197,3 +197,49 @@ fn toolbar_stroke_edits_the_selected_shape_layer() {
assert_eq!(width, Some(4.0), "a stroke was added with the toolbar's width");
assert_eq!(h.state().session.state.shape_tool.stroke_width, 4.0);
}
/// Issue #633: a colour property in the Timeline (a shape's Fill Color) has an eyedropper after
/// its swatch, as in After Effects: click it, then click in the Composition panel to sample.
#[test]
fn timeline_colour_eyedropper_samples_the_comp() {
let mut s = session();
s.execute("layer.newSolid", json!({"name": "Back", "color": "#20c040"})).unwrap();
let l = s.execute("layer.newShape", json!({"kind": "rect", "fill": [1.0, 0.0, 0.0], "size": [100.0, 60.0]})).unwrap()["layer"].as_u64().unwrap();
let layer = s.active_comp().unwrap().layer(LayerId(l)).unwrap().clone();
let mut fill = None;
layer.props.walk("", &mut |_, p| {
if fill.is_none() && matches!(p.value, effectcraft_engine::keyframe::Value::Color(_)) {
fill = Some(p.uid);
}
});
let fill = fill.expect("a fill colour");
fn groups(g: &effectcraft_engine::project::PropGroup, out: &mut Vec<u64>) {
for c in g.groups() {
out.push(c.uid);
groups(c, out);
}
}
let mut open = vec![];
groups(&layer.props, &mut open);
let mut h = harness(s);
h.state_mut().ui.timeline.open_groups.extend(open);
open_layer(&mut h, l);
h.run_steps(2);
click(&mut h, &format!("timeline.prop.{fill}.eyedropper"));
assert_eq!(h.state().ui.fx_pick.as_ref().map(|p| (p.prop, p.kind.as_str())), Some((fill, "color")), "the eyedropper waits for a viewer click");
let pos = effectcraft_ui_egui::panels::viewer::comp_to_screen(&h.ctx, [6.0, 6.0]).unwrap();
click_at(&mut h, pos);
assert!(h.state().ui.fx_pick.is_none(), "the pick is used up");
let layer = h.state().session.active_comp().unwrap().layer(LayerId(l)).unwrap().clone();
let mut got = None;
layer.props.walk("", &mut |_, p| {
if p.uid == fill {
got = Some(p.value.clone());
}
});
let Some(effectcraft_engine::keyframe::Value::Color(c)) = got else { panic!("{got:?}") };
let want = [0x20 as f64 / 255.0, 0xc0 as f64 / 255.0, 0x40 as f64 / 255.0];
for k in 0..3 {
assert!((c[k] - want[k]).abs() < 0.02, "{c:?} vs {want:?}");
}
}