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

This commit is contained in:
dotCooCoo
2026-11-15 09:16:17 -08:00
parent c0550a00a7
commit 78e56b6d7a
2 changed files with 6 additions and 2 deletions
+5 -1
View File
@@ -605,7 +605,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);
@@ -2029,6 +2029,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
@@ -296,7 +296,7 @@ color's brightness (the base color's when none is selected; the patch's color on
`added: true` that becomes the selected row; `remove` (the Remove Color tool) removes the color of the marker clicked. 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.
The base color is the row with `base: true`, or the first color the Edit tab shows when no row has it; the harmony rules
build from it, and selecting another color for the sliders leaves it the base. A right-click on a wheel marker or a
color bar opens a menu with Set As Base Color (moves `base: true` to that row), Select Shade (a grid of the color's hue