Recolor Artwork: an added color whose row is excluded joins no color group

This commit is contained in:
dotCooCoo
2026-11-15 11:31:36 -08:00
parent c1ba6e8cd3
commit a1aa6ddc01
2 changed files with 6 additions and 2 deletions
+5 -1
View File
@@ -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]
+1 -1
View File
@@ -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,