From a1aa6ddc01cc06360ca6e6747dcba5838fa9c42e Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 15 Nov 2026 11:31:36 -0800 Subject: [PATCH] Recolor Artwork: an added color whose row is excluded joins no color group --- crates/ui-egui/src/dialogs/recolor.rs | 6 +++++- docs/control-protocol.md | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/dialogs/recolor.rs b/crates/ui-egui/src/dialogs/recolor.rs index 2f4ca1c131..f8d0ac547e 100644 --- a/crates/ui-egui/src/dialogs/recolor.rs +++ b/crates/ui-egui/src/dialogs/recolor.rs @@ -598,7 +598,7 @@ fn apply_params(d: &Dialog) -> Value { let took: Vec<&Value> = rs.iter().filter(|r| !no_current(r)).map(|r| &r["to"]).collect(); let assign = d.fields.get("__assign").and_then(Value::as_array).filter(|_| d.bool("__art")); let rest = assign.map_or(&[][..], |a| a.get(took.len()..).unwrap_or_default()); - let added = rs.iter().filter(|r| no_current(r) && is_added(r)).map(|r| &r["to"]).filter(|c| !c.is_null()); + let added = rs.iter().filter(|r| no_current(r) && is_added(r) && !excluded(r)).map(|r| &r["to"]).filter(|c| !c.is_null()); let colors: Vec<&Value> = took.into_iter().chain(rest).chain(added).collect(); let name = d.str("groupName"); let rename = (!name.trim().is_empty() && name != g).then_some(name); @@ -1822,6 +1822,10 @@ mod tests { add_color(&mut rs, &Color::rgb(9.0 / 255.0, 9.0 / 255.0, 9.0 / 255.0)); d.fields.insert("rows".into(), json!(rs)); assert_eq!(apply_params(&d)["groupColors"], json!(["rgb 1 1 1", null, "rgb 3 3 3", "rgb 9 9 9"])); + // An added color whose row is excluded joins no group. + rs[3]["exclude"] = json!(true); + d.fields.insert("rows".into(), json!(rs)); + assert_eq!(apply_params(&d)["groupColors"], json!(["rgb 1 1 1", null, "rgb 3 3 3"])); } #[test] diff --git a/docs/control-protocol.md b/docs/control-protocol.md index 2a2b2a7079..5a5b96ff50 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -297,7 +297,7 @@ color's brightness (the patch's color on the segmented wheel), in a new row with right-click menu has Remove Color too. The base color can't be removed. A removed color's row is dropped, unless it has current colors and art or a group is open: it then keeps them with `to: null`, that art keeps its colors, and the group's swatch at that place is removed. A row with no current colors recolors no art; with a group, the new color of -one with `added: true` is added to the group after the group's other colors, and a row made with New Row adds none. +one with `added: true` that is not excluded is added to the group after the group's other colors, and a row made with New Row adds none. Setting `colors`, a preserve flag or `limitTo` reduces the rows again (also on `ui.dialog.confirm`). The dialog previews `recolor.apply` on the canvas; confirm keeps it as one undo step (with a group, the group is rewritten in the same step; with no art selected only the group changes). In the Swatches panel, double-clicking a colour group's folder,