Recolor Artwork: weights set before the art is read do not make Undo Changes available

When the art's reduction runs on the dialog's first frame or command,
it drops the Prominent Colors weights along with replacing the rows,
so weights set before then make no step. The availability check now
leaves out both, as ui.recolorUndo does.

The docs say that fields set with ui.dialog.set become a step at the
next frame with the pointer up, so they group across frames drawn while
the pointer is down, and the progress line names the new tests.
This commit is contained in:
dotCooCoo
2026-11-17 15:52:57 -08:00
parent a01bf5e0ad
commit 6253a6eff1
4 changed files with 20 additions and 16 deletions
+3 -2
View File
@@ -947,12 +947,13 @@ impl History {
fn can(&self, d: &Dialog, back: bool) -> bool {
// Before the first frame or command, fields set since the dialog opened are a step back,
// except rows that the art's reduction is about to replace.
// except rows and weights that the art's reduction is about to replace or drop ([`sync`]).
if self.base.is_none()
&& let Some(opened) = &self.opened
{
let reduces = d.bool("__art") && d.fields.get("__reduced") != Some(&reduce_params(d));
return back && STEP_FIELDS.iter().filter(|k| !(reduces && **k == "rows")).any(|k| d.fields.get(*k) != opened.get(*k));
let kept = |k: &&&str| !(reduces && (**k == "rows" || **k == WEIGHTS));
return back && STEP_FIELDS.iter().filter(kept).any(|k| d.fields.get(*k) != opened.get(*k));
}
if back { !self.undo.is_empty() || self.pending(d) } else { !self.redo.is_empty() && !self.pending(d) }
}
+13 -11
View File
@@ -1766,16 +1766,18 @@ fn an_edit_with_the_pointer_down_from_the_first_frame_is_a_step() {
assert_eq!((field(&app, "colors"), field(&app, "rows")), (Value::Null, start));
}
/// Rows set before the first frame, which the art's reduction then replaces, are no step: Undo
/// Changes is not available and changes nothing.
/// Rows or weights set before the first frame, which the art's reduction then replaces or drops,
/// are no step: Undo Changes is not available and changes nothing.
#[test]
fn rows_set_before_the_art_is_read_are_no_step() {
let mut app = app();
art(&mut app, &["#ff0000", "#0000ff"]);
app.run("ui.recolorDialog", json!({})).unwrap();
set(&mut app, "rows", json!([{"to": "#123456"}]));
assert!(!dialogs::recolor::can_step(&app, true), "Undo Changes is not available");
let r = app.run("ui.recolorUndo", json!({})).unwrap();
assert_eq!(r, json!({"changed": false, "canUndo": false, "canRedo": false}));
assert_eq!(field(&app, "rows").as_array().unwrap().len(), 2, "the rows of the art");
fn rows_and_weights_set_before_the_art_is_read_are_no_step() {
for (k, v) in [("rows", json!([{"to": "#123456"}])), ("weights", json!([25, 75]))] {
let mut app = app();
art(&mut app, &["#ff0000", "#0000ff"]);
app.run("ui.recolorDialog", json!({})).unwrap();
set(&mut app, k, v);
assert!(!dialogs::recolor::can_step(&app, true), "{k}: Undo Changes is not available");
let r = app.run("ui.recolorUndo", json!({})).unwrap();
assert_eq!(r, json!({"changed": false, "canUndo": false, "canRedo": false}), "{k}");
assert_eq!(field(&app, "rows").as_array().unwrap().len(), 2, "{k}: the rows of the art");
}
}
+3 -2
View File
@@ -4865,8 +4865,9 @@ when Recolor Artwork is not open. VectorCraft's own rules: the dialog's history
history, which changes when OK records the recolor as one undo step and when a color group is saved (below); Cancel
discards the history with the edits. A change is one step once the pointer is released, so a drag on the wheel, a
slider or the Prominent Colors bar is one step, and an action that changes none of those fields is no step. Fields set
with `ui.dialog.set` become a step at the dialog's next frame or the next `ui.recolorUndo` or `ui.recolorRedo`, so
fields set before either are one step together. Reset is a step of its own, which Undo
with `ui.dialog.set` become a step at the dialog's next frame with the pointer up or the next `ui.recolorUndo` or
`ui.recolorRedo`, so fields set before either are one step together, also across frames drawn while the pointer is
down. Reset is a step of its own, which Undo
Changes reverses. A new edit after Undo Changes leaves nothing to redo. Switching tabs, displays or slider modes,
selecting rows, Find and Preview make no step. The dialog keeps at most 64 steps and 4 MiB of them as JSON, dropping
the oldest first. A button with no step to go to is disabled. Save All Colors and Save Prominent Colors add a color
+1 -1
View File
@@ -1766,7 +1766,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
- **Recolor Artwork brightness and hue wheel:** a button under the Edit tab's wheel tools switches the wheel between hue with saturation and hue with brightness; a marker's angle sets its hue, and its distance from the center sets the component the wheel shows ([Recolor options overview](https://helpx.adobe.com/illustrator/desktop/manage-colors/modify-colors/recolor-options-overview.html), [archived help, Edit colors](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=144)). VectorCraft's own rules: brightness runs from black at the center to full at the edge, the segmented wheel's five rings become brightness steps, the slider under the wheel edits the component the wheel leaves out (Saturation on the brightness wheel), Add Color takes the hue and brightness clicked at the base color's saturation, the choice holds for both wheels while the dialog is open and the button is off for the color bars, and each opening shows hue and saturation. `wheelAxes` (`hueSaturation`, `hueBrightness`) is the dialog field. Tests: `the_brightness_and_hue_wheel_swaps_the_wheel_axis_and_the_slider`, `a_marker_on_the_brightness_wheel_sets_hue_and_brightness`, `the_add_color_tool_on_the_brightness_wheel_adds_the_brightness_clicked` and `the_segmented_brightness_wheel_has_24_hues_by_5_brightnesses` in `crates/ui-egui/src/tests/recolor.rs`, and `an_added_color_on_the_brightness_wheel_takes_the_base_colors_saturation` in `crates/ui-egui/src/dialogs/recolor.rs`. Scores and estimates unchanged.
- **Recolor Artwork Find:** the Assign tab's Find button finds the colors of the selected rows in the art ([Advanced recolor options overview](https://helpx.adobe.com/illustrator/desktop/manage-colors/learn-color-basics/edit-colors-dialog-overview.html)): while it is on, their art shows as the preview shows it and the rest of the selected art shows dimmed, until a second click ([archived help, Recolor Artwork](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=149)). VectorCraft's own rules: a dimmed color is a 25% tint of its current color (or the nearest lighter tint when that one is a color a selected row lists), a color a selected row also lists is not dimmed, and Find records no undo step. `findColors` is the dialog field. Tests: `find_dims_the_colors_of_the_rows_not_selected` and `find_shows_the_selected_rows_art_and_dims_the_rest` in `crates/ui-egui/src/dialogs/recolor.rs`. Scores and estimates unchanged.
- **Recolor Artwork New Row:** the Assign tab's New Row button adds a row with no current colors, so current colors can be moved into it and take its new color ([Advanced recolor options overview](https://helpx.adobe.com/illustrator/desktop/manage-colors/learn-color-basics/edit-colors-dialog-overview.html), [Assign new colors to selected artworks](https://helpx.adobe.com/illustrator/desktop/manage-colors/modify-colors/assign-new-colors-to-selected-artwork.html)). VectorCraft's own rules: the row goes above the first selected row (at the top when none is selected) with that row's new color and becomes the selection, and Merge with it as the first selected row moves the other rows' colors into it. The button needs selected art. An empty row recolors nothing, does not count toward Colors, adds no library swatch and gives a rewritten color group no color. While it is empty, Save All Colors and a new color group saved from colors alone leave its new color out, the Edit tab's wheel, bars and chips do not show it and its sliders edit the base color instead, the harmony rules and linked moves leave its new color as it is, and the Color Theme Picker gives it no color. Tests: `a_new_row_goes_above_the_selection_and_takes_merged_colors`, `an_empty_row_gives_the_group_no_color`, `an_empty_row_gives_a_new_group_no_color`, `an_empty_row_takes_no_harmony_or_wheel_color`, `theme_picks_leave_an_empty_row_out`, `save_all_colors_leaves_an_empty_row_out` and `colors_merged_into_a_new_row_take_its_new_color` in `crates/ui-egui/src/dialogs/recolor.rs`, `an_empty_row_recolors_nothing` and `an_empty_row_adds_no_swatch_and_no_group_color` in `crates/engine/src/tests/recolor.rs`.
- **Recolor Artwork Undo Changes and Redo Changes:** two buttons beside the Color Theme Picker go back and forward one color edit made in the open dialog, and Undo Changes has nothing to undo after the dialog is opened again ([Recolor options overview](https://helpx.adobe.com/illustrator/desktop/manage-colors/modify-colors/recolor-options-overview.html)); `ui.recolorUndo` and `ui.recolorRedo` run them. VectorCraft's own rules: the dialog's history is separate from the document's, which changes when OK records one undo step and when Save All Colors or Save Prominent Colors adds a color group at once as its own undo step, which Cancel and Undo Changes leave in place; a drag is one step, fields set with `ui.dialog.set` before the next frame or step are one step, Reset is a step of its own, a new edit leaves nothing to redo, a button with no step to go to is disabled, and the dialog keeps at most 64 steps and 4 MiB of them. Tests: `undo_and_redo_changes_step_through_the_dialogs_own_edits`, `a_drag_is_one_step_of_undo_changes`, `undo_changes_reverses_reset` and `the_recolor_undo_and_redo_commands_step_the_open_dialog` in `crates/ui-egui/src/tests/recolor.rs`, and `undo_changes_keeps_a_bounded_history` in `crates/ui-egui/src/dialogs/recolor.rs`. Scores and estimates unchanged.
- **Recolor Artwork Undo Changes and Redo Changes:** two buttons beside the Color Theme Picker go back and forward one color edit made in the open dialog, and Undo Changes has nothing to undo after the dialog is opened again ([Recolor options overview](https://helpx.adobe.com/illustrator/desktop/manage-colors/modify-colors/recolor-options-overview.html)); `ui.recolorUndo` and `ui.recolorRedo` run them. VectorCraft's own rules: the dialog's history is separate from the document's, which changes when OK records one undo step and when Save All Colors or Save Prominent Colors adds a color group at once as its own undo step, which Cancel and Undo Changes leave in place; a drag is one step, fields set with `ui.dialog.set` before the next frame with the pointer up or the next step are one step, Reset is a step of its own, a new edit leaves nothing to redo, a button with no step to go to is disabled, and the dialog keeps at most 64 steps and 4 MiB of them. Tests: `undo_and_redo_changes_step_through_the_dialogs_own_edits`, `a_drag_is_one_step_of_undo_changes`, `undo_changes_reverses_reset`, `the_recolor_undo_and_redo_commands_step_the_open_dialog`, `an_edit_with_the_pointer_down_from_the_first_frame_is_a_step` and `rows_and_weights_set_before_the_art_is_read_are_no_step` in `crates/ui-egui/src/tests/recolor.rs`, and `undo_changes_keeps_a_bounded_history` in `crates/ui-egui/src/dialogs/recolor.rs`. Scores and estimates unchanged.
- **Edit Colors parameters:** `edit.colors.saturate` needs a number `intensity`, the value from -100% to 100% that Saturate takes ([Adjusting colors](https://web.archive.org/web/20230128232631/https://helpx.adobe.com/illustrator/using/adjusting-colors.html)), and answers "missing number `intensity`" without one; a number outside the range counts as its nearest end. A value that is not a number, such as `"40"`, is refused with `` `intensity` must be a number, not "40" ``, as in every command that needs a number (`tests::params::a_malformed_required_number_is_not_reported_as_missing`). `edit.colors.adjustBalance` refuses a channel and `color.harmony` refuses `steps` or `amount` that is not a number; both read `null` as a value left out. `tests::editcolors` and `tests::colorguide` cover them.
- **Convert to Indexed Color:** Edit › Edit Colors › Convert to Indexed Color… (`edit.colors.toIndexed`) stores the embedded images in the selection as indexed-color PNGs of at most 256 colors. The palette is chosen as for a PNG-8 export, as evenly spaced levels of red, green and blue, or from the document's swatches, with diffusion, pattern or noise dithering; pixels under half opacity become transparent. The dialog previews live, and OK is one undo step. This is VectorCraft's own command and counts toward no score. `tests::editcolors` and `encode::tests_palette` cover it. Scores and estimates unchanged.
- **Working RGB numeric controls:** the Color panel and Color Picker read RGB, HSB, hex and Web Safe RGB values in the active working RGB space. Editing one RGB channel preserves the other native channels, including colors outside display sRGB. Regressions cover sRGB, Display P3, Wide Gamut RGB and ProPhoto RGB, picker initialization, native numeric round trips, and a slider click with one Undo step. Scores and estimates unchanged.