Recolor Artwork: an edit with the pointer down from the first frame is an Undo Changes step

The dialog's history takes the fields it read from the art as its first
state on the first frame, before the controls run. A pointer held from
that frame no longer leaves the first state unset until release, which
made the first edit the starting state with nothing to undo.

The docs say that fields set with ui.dialog.set become one step at the
next frame or step, and that Save All Colors and Save Prominent Colors
add a color group to the document at once, which Cancel and Undo
Changes leave in place.
This commit is contained in:
dotCooCoo
2026-11-17 14:52:39 -08:00
parent f5456410b2
commit c894fd6a2d
4 changed files with 39 additions and 5 deletions
+10
View File
@@ -746,6 +746,9 @@ fn body(app: &mut VectorcraftApp, ui: &mut Ui, d: &mut Dialog) -> bool {
sync(app, d);
sync_theme(app, d);
sync_weights(app, d);
// The fields as the dialog read the art are where Undo Changes starts, also when the pointer is
// down on the first frame and the first step is recorded only on release.
app.ui.recolor_history.start(d);
let t = Tokens::get(ui.ctx());
let picking = d.bool(THEME_PICKER);
let mut stepped = None;
@@ -903,6 +906,13 @@ fn seed(app: &mut VectorcraftApp, d: &Dialog) {
}
impl History {
/// Take the fields of `d` as those after the last step when no step has them yet.
fn start(&mut self, d: &Dialog) {
if self.base.is_none() {
self.base = Some(snapshot(d));
}
}
/// Whether the fields of `d` differ from those after the last step.
fn pending(&self, d: &Dialog) -> bool {
self.base.as_ref().is_some_and(|b| STEP_FIELDS.iter().any(|k| d.fields.get(*k) != b.get(*k)))
+22
View File
@@ -1742,3 +1742,25 @@ fn the_recolor_undo_and_redo_commands_step_the_open_dialog() {
dialog_frame(&mut app, &ctx);
assert!(!dialogs::recolor::can_step(&app, true) && !dialogs::recolor::can_step(&app, false), "a new opening");
}
/// An edit made while the pointer is held from the dialog's first frame is a step from the fields
/// the dialog opened with, not where Undo Changes starts.
#[test]
fn an_edit_with_the_pointer_down_from_the_first_frame_is_a_step() {
let mut app = app();
let ctx = context();
art(&mut app, &["#ff0000", "#e01010", "#0000ff", "#1010e0"]);
app.run("ui.recolorDialog", json!({})).unwrap();
let at = Pos2::new(2.0, 2.0);
let button = |pressed| Event::PointerButton { pos: at, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE };
frame(&mut app, &ctx, vec![Event::PointerMoved(at), button(true)], 1.0, |app, ui| dialogs::show(app, ui.ctx()));
let start = field(&app, "rows");
assert_eq!(start.as_array().unwrap().len(), 4);
set(&mut app, "colors", json!(2));
frame(&mut app, &ctx, vec![], 2.0, |app, ui| dialogs::show(app, ui.ctx()));
frame(&mut app, &ctx, vec![button(false)], 3.0, |app, ui| dialogs::show(app, ui.ctx()));
assert_eq!(field(&app, "rows").as_array().unwrap().len(), 2);
let r = app.run("ui.recolorUndo", json!({})).unwrap();
assert_eq!(r, json!({"changed": true, "canUndo": false, "canRedo": true}));
assert_eq!((field(&app, "colors"), field(&app, "rows")), (Value::Null, start));
}
+6 -4
View File
@@ -4862,13 +4862,15 @@ again ([Recolor options overview](https://helpx.adobe.com/illustrator/desktop/ma
A step restores the rows, `colors`, `method`, the Preserve options, `limitTo`, `rule`, `globalAdjust`, `themePicks`
and `weights`, and the art previews the result. Both commands return `{changed, canUndo, canRedo}` and are an error
when Recolor Artwork is not open. VectorCraft's own rules: the dialog's history is separate from the document's undo
history, which does not change until OK records the recolor as one undo step; 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. Reset is a step of its own, which Undo
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
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
group to the document at once, as its own undo step, and Undo Changes leaves that group in place.
group to the document at once, as its own undo step, and Cancel and Undo Changes leave that group in place.
The `recolor.*` commands refuse parameters of the wrong form. A `limitTo` or `method` that is not a string gets the
error for an unknown library or method. Other wrong-form parameters get an error that names them.
+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 only when OK records one undo step; a drag is 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 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.
- **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.