#732: toolbar Fill/Stroke Options change the selected shape layers' kind

Problem: with shape layers selected, the Tools bar's Fill Options / Stroke
Options (None, Solid Color, Linear Gradient, Radial Gradient, and the
swatch's Alt-click cycle) only changed the defaults for new shapes.
shape.fillStroke had no kind, so a selected layer's fill or stroke could
not be removed or turned into a gradient from the toolbar; it had to be
edited in the Timeline. The swatch also kept showing the tool's kind, not
the layer's.

Fix: shape.fillStroke takes fillType / strokeType. None switches the
layers' Fills and Gradient Fills (or Strokes) off; another kind switches
them on and turns them into that kind, keeping the uid and the
properties both kinds share (blend mode, opacity, width, dashes...), and
gives a group with paths and no such item one (gradients span the
group's paths). It reports the first layer's fillType / strokeType, and
the toolbar shows them. The kind picks in the options popup and the
Alt-click cycle apply to the selected shape layers, one undo step each.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
vangel76
2026-10-11 11:49:48 +02:00
co-authored by Claude Opus 5.5
parent 9a7d3e7699
commit 0ae960102c
5 changed files with 294 additions and 31 deletions
+26
View File
@@ -601,6 +601,32 @@ fn fill_options_paint_the_next_shape() {
assert_eq!(gfill.get("opacity").unwrap().value.as_f64(), 40.0);
}
/// With a shape layer selected, Fill Options' None switches its fill off and Solid Color turns
/// it back on, and the Fill swatch shows the layer's kind (#732).
#[test]
fn fill_options_change_the_selected_shape_layer() {
let mut h = harness();
let l = h.state_mut().session.execute("layer.newShape", json!({"kind": "rect", "size": [100, 100], "position": [320, 180]})).unwrap()["layer"]
.as_u64()
.unwrap();
h.run_steps(2);
let fill_on = |h: &Harness<'_, EffectcraftApp>| {
let layer = h.state().session.active_comp().unwrap().layer(LayerId(l)).unwrap().clone();
layer.props.group("contents/group/contents/fill").unwrap().enabled
};
assert!(fill_on(&h));
for (kind, on) in [("none", false), ("solid", true)] {
let at = rect(&h, "header.fillOptions").center();
click(&mut h, at);
let at = rect(&h, &format!("header.fillOptions.{kind}")).center();
click(&mut h, at);
h.input_mut().events.push(Event::Key { key: egui::Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: Default::default() });
h.run_steps(3);
assert_eq!(fill_on(&h), on, "{kind}");
assert_eq!(h.state().session.state.shape_tool.fill.kind.id(), kind);
}
}
#[test]
fn shape_pen_draws_a_closed_shape_layer() {
let mut h = harness();