Merge pull request #9775 from dotCooCoo/fix/brush-options-unchanged-approval-b-verify

Keep unchanged Brush Options out of document history
This commit is contained in:
.CooCoo authored and GitHub committed 2026-11-28 17:28:50 -08:00
commit 67adc70369
6 files changed
+118 -4

No files matched your search

+1 -1
View File
@@ -1132,7 +1132,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
"ui.brushOptions",
"Brush Options…",
"",
"{name?} (default: the selected path's brush, else the current brush) open its Brush Options, what double-clicking a brush in the Brushes panel opens (dialog `brushOptions`): Calligraphic (fields name, angle −180..180, roundness 0..100, size 0..1296 pt, angleMode/roundnessMode/sizeMode: fixed|random|pressure, angleVariation/roundnessVariation/sizeVariation), Bristle (fields name, shape, size, length, density, thickness, opacity, stiffness), Scatter (fields sizeMin/sizeMax/sizeMode, spacingMin/spacingMax/spacingMode, scatterMin/scatterMax/scatterMode, rotationMin/rotationMax/rotationMode with modes fixed|random|pressure, rotationRelativeTo: page|path, hueJitter 0..180°, saturationJitter 0..100%, brightnessJitter 0..100%), Art (fields width %, scaleMode: proportional|stretch|betweenGuides, guideStart/guideEnd % of the art length, direction: leftToRight|rightToLeft|topToBottom|bottomToTop, flipAlong, flipAcross) or Pattern (fields scale %, scaleMax %, scaleMode: fixed|pressure|tilt|bearing|rotation|stylusWheel, spacing %, fit: stretch|addSpace|approximate, flipAlong, flipAcross); Scatter, Art and Pattern also colorization: none|tints|tintsAndShades|hueShift, keyColor, and tips: true opens Colorization Tips (what each method does, beside a sample of the brush painted with it), as the Tips button beside Method does; OK runs brush.options",
"{name?} (default: the selected path's brush, else the current brush) open its Brush Options, what double-clicking a brush in the Brushes panel opens (dialog `brushOptions`): Calligraphic (fields name, angle −180..180, roundness 0..100, size 0..1296 pt, angleMode/roundnessMode/sizeMode: fixed|random|pressure, angleVariation/roundnessVariation/sizeVariation), Bristle (fields name, shape, size, length, density, thickness, opacity, stiffness), Scatter (fields sizeMin/sizeMax/sizeMode, spacingMin/spacingMax/spacingMode, scatterMin/scatterMax/scatterMode, rotationMin/rotationMax/rotationMode with modes fixed|random|pressure, rotationRelativeTo: page|path, hueJitter 0..180°, saturationJitter 0..100%, brightnessJitter 0..100%), Art (fields width %, scaleMode: proportional|stretch|betweenGuides, guideStart/guideEnd % of the art length, direction: leftToRight|rightToLeft|topToBottom|bottomToTop, flipAlong, flipAcross) or Pattern (fields scale %, scaleMax %, scaleMode: fixed|pressure|tilt|bearing|rotation|stylusWheel, spacing %, fit: stretch|addSpace|approximate, flipAlong, flipAcross); Scatter, Art and Pattern also colorization: none|tints|tintsAndShades|hueShift, keyColor, and tips: true opens Colorization Tips (what each method does, beside a sample of the brush painted with it), as the Tips button beside Method does; OK runs brush.options only when its name or options changed; unchanged approval preserves the brush and adds no Undo",
),
(
"ui.brushObjectOptions",
+13 -2
View File
@@ -3,8 +3,9 @@
//! Tilt, Bearing or Rotation with its Variation, over live previews of the nib and of a stroke
//! (light, heavy, light pressure). Bristle Brush Options: Name (a new bristle brush name that is too
//! long is refused at OK), Shape and the bristle sliders. Scatter, Art and Pattern Brush Options: see
//! [`super::brush_art_options`]. OK runs `brush.options` (strokes painted with the brush update);
//! a name another brush has, or a new bristle brush name that is too long, keeps the dialog open.
//! [`super::brush_art_options`]. A changed OK runs `brush.options` (strokes painted with the brush update);
//! accepting unchanged settings closes without an Undo step.
//! A name another brush has, or a new bristle brush name that is too long, keeps the dialog open.
//!
//! Fields: `__brush` (the brush's name), `__type` (`calligraphic` | `bristle` | `scatter` | `art` |
//! `pattern`), `name`.
@@ -183,6 +184,7 @@ fn open_dialog(app: &mut VectorcraftApp, f: &Map<String, Value>, object_keys: Op
initial.set(OPENED, FieldValue::Json(Value::Object(opened)));
initial.set(KEYS, FieldValue::Json(json!(keys)));
}
let unchanged = (!object && !flag(&initial, CREATE)).then(|| (string(&initial, "name"), string(&initial, "__brush"), params(&initial)));
// The canvas of the current window: the Key Color dropper samples there while the dialog is open.
let canvas = crate::doc_windows::current(app).map(crate::canvas::canvas_id);
let dialog = HostedParamDialog::new(&ctx, KIND, initial, move |fields| {
@@ -202,6 +204,15 @@ fn open_dialog(app: &mut VectorcraftApp, f: &Map<String, Value>, object_keys: Op
None if !object => return Err(tl!("Return to the original drawing to edit its brush").into()),
_ => {}
}
if let Some((opened_name, brush, opened_params)) = &unchanged {
let name = string(&result.fields, "name");
// The command ignores an empty name and trims a supplied rename.
let same_name = name == *opened_name || name.trim().is_empty() || name.trim() == brush;
if same_name && params(&result.fields) == *opened_params {
// A deleted brush still reports its normal error instead of accepting a stale dialog.
return app.run("brush.get", json!({"name": brush})).map(|_| ());
}
}
ok(app, result)
})
.ok_or("no window")?,
@@ -9,6 +9,102 @@ fn app() -> VectorcraftApp {
app
}
#[test]
fn unchanged_normal_brush_approval_keeps_the_document_and_undo_history_exact() {
use crate::tests::panel_harness::Panel;
for name in ["6 pt. Flat", "Bristle Round", "Confetti", "Arrow", "Diamonds"] {
let mut app = app();
let params = if name == "Arrow" { json!({"width": 100.25}) } else { json!({}) };
// Establish a saved library before testing a normal approval of an existing brush.
app.run("brush.options", json!({"name": name, "params": params})).unwrap();
let brush = app.run("brush.get", json!({"name": name})).unwrap();
let document = app.session.active().unwrap().doc.clone();
let revision = app.session.active().unwrap().revision;
let undo = app.session.active().unwrap().history.undo.len();
let mut panel = Panel::new(app, crate::tests::picks::dialogs);
panel.room(vec2(1200.0, 1200.0));
panel.app().run("ui.brushOptions", json!({"name": name})).unwrap();
panel.frame();
panel.click("OK");
panel.frame();
panel.frame();
assert!(!is_open(&panel.app()), "the unchanged {name} dialog closes normally");
assert_eq!(panel.app().run("brush.get", json!({"name": name})).unwrap(), brush);
let app = panel.app();
let st = app.session.active().unwrap();
assert_eq!(st.doc, document, "unchanged {name} approval preserves the entire stored library");
assert_eq!(st.revision, revision);
assert_eq!(st.history.undo.len(), undo, "unchanged {name} approval adds no Undo step");
}
}
#[test]
fn brush_automation_approval_skips_noop_but_saves_changed_options_in_one_step() {
let mut app = app();
app.run("brush.options", json!({"name": "Arrow", "params": {"width": 100.25}})).unwrap();
let original = app.session.active().unwrap().doc.clone();
let revision = app.session.active().unwrap().revision;
let undo = app.session.active().unwrap().history.undo.len();
open(&mut app, "Arrow");
confirm(&mut app).unwrap();
assert_eq!(app.session.active().unwrap().doc, original);
assert_eq!(app.session.active().unwrap().revision, revision);
assert_eq!(app.session.active().unwrap().history.undo.len(), undo);
for name in [" Arrow ", ""] {
open(&mut app, "Arrow");
set(&mut app, json!({"name": name}));
confirm(&mut app).unwrap();
assert_eq!(app.session.active().unwrap().doc, original, "a command-equivalent name does not rewrite the brush");
assert_eq!(app.session.active().unwrap().history.undo.len(), undo);
}
open(&mut app, "Arrow");
set(&mut app, json!({"width": 110.25}));
confirm(&mut app).unwrap();
assert_eq!(app.run("brush.get", json!({"name": "Arrow"})).unwrap()["width"], json!(110.25));
assert_eq!(app.session.active().unwrap().history.undo.len(), undo + 1);
app.run("edit.undo", json!({})).unwrap();
assert_eq!(app.session.active().unwrap().doc, original);
}
#[test]
fn normal_brush_rename_still_saves_and_a_deleted_brush_still_refuses_approval() {
use crate::tests::panel_harness::Panel;
use craft::ui::contract::Role;
use egui::{Key, Modifiers};
let mut app = app();
app.run("brush.options", json!({"name": "Arrow", "params": {}})).unwrap();
let original = app.session.active().unwrap().doc.clone();
let undo = app.session.active().unwrap().history.undo.len();
let mut panel = Panel::new(app, crate::tests::picks::dialogs);
panel.room(vec2(1200.0, 1200.0));
panel.app().run("ui.brushOptions", json!({"name": "Arrow"})).unwrap();
panel.frame();
panel.click_role("Name", Role::TEXT_INPUT);
panel.key(Key::A, Modifiers::COMMAND);
panel.type_text("Renamed Arrow");
panel.key(Key::Tab, Modifiers::NONE);
panel.click("OK");
panel.frame();
panel.frame();
assert!(!is_open(&panel.app()));
assert!(panel.app().run("brush.get", json!({"name": "Renamed Arrow"})).is_ok());
assert_eq!(panel.app().session.active().unwrap().history.undo.len(), undo + 1);
panel.app().run("edit.undo", json!({})).unwrap();
assert_eq!(panel.app().session.active().unwrap().doc, original);
open(&mut panel.app(), "Arrow");
panel.app().run("brush.delete", json!({"name": "Arrow"})).unwrap();
let deleted = panel.app().session.active().unwrap().doc.clone();
let undo = panel.app().session.active().unwrap().history.undo.len();
assert!(confirm(&mut panel.app()).unwrap_err().contains("no brush named"));
assert!(is_open(&panel.app()), "the stale unchanged dialog reports its normal error");
assert_eq!(panel.app().session.active().unwrap().doc, deleted);
assert_eq!(panel.app().session.active().unwrap().history.undo.len(), undo);
cancel(&mut panel.app());
}
fn ctx(app: &VectorcraftApp) -> egui::Context {
app.ui_ctx.clone().expect("the test app has a context")
}
+1 -1
View File
@@ -1133,7 +1133,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
"ui.brushOptions",
"Brush Options…",
"",
"{name?} (default: the selected path's brush, else the current brush) open its Brush Options, what double-clicking a brush in the Brushes panel opens (dialog `brushOptions`): Calligraphic (fields name, angle −180..180, roundness 0..100, size 0..1296 pt, angleMode/roundnessMode/sizeMode: fixed|random|pressure, angleVariation/roundnessVariation/sizeVariation), Bristle (fields name, shape, size, length, density, thickness, opacity, stiffness), Scatter (fields sizeMin/sizeMax/sizeMode, spacingMin/spacingMax/spacingMode, scatterMin/scatterMax/scatterMode, rotationMin/rotationMax/rotationMode with modes fixed|random|pressure, rotationRelativeTo: page|path, hueJitter 0..180°, saturationJitter 0..100%, brightnessJitter 0..100%), Art (fields width %, scaleMode: proportional|stretch|betweenGuides, guideStart/guideEnd % of the art length, direction: leftToRight|rightToLeft|topToBottom|bottomToTop, flipAlong, flipAcross) or Pattern (fields scale %, scaleMax %, scaleMode: fixed|pressure|tilt|bearing|rotation|stylusWheel, spacing %, fit: stretch|addSpace|approximate, flipAlong, flipAcross); Scatter, Art and Pattern also colorization: none|tints|tintsAndShades|hueShift, keyColor, and tips: true opens Colorization Tips (what each method does, beside a sample of the brush painted with it), as the Tips button beside Method does; OK runs brush.options",
"{name?} (default: the selected path's brush, else the current brush) open its Brush Options, what double-clicking a brush in the Brushes panel opens (dialog `brushOptions`): Calligraphic (fields name, angle −180..180, roundness 0..100, size 0..1296 pt, angleMode/roundnessMode/sizeMode: fixed|random|pressure, angleVariation/roundnessVariation/sizeVariation), Bristle (fields name, shape, size, length, density, thickness, opacity, stiffness), Scatter (fields sizeMin/sizeMax/sizeMode, spacingMin/spacingMax/spacingMode, scatterMin/scatterMax/scatterMode, rotationMin/rotationMax/rotationMode with modes fixed|random|pressure, rotationRelativeTo: page|path, hueJitter 0..180°, saturationJitter 0..100%, brightnessJitter 0..100%), Art (fields width %, scaleMode: proportional|stretch|betweenGuides, guideStart/guideEnd % of the art length, direction: leftToRight|rightToLeft|topToBottom|bottomToTop, flipAlong, flipAcross) or Pattern (fields scale %, scaleMax %, scaleMode: fixed|pressure|tilt|bearing|rotation|stylusWheel, spacing %, fit: stretch|addSpace|approximate, flipAlong, flipAcross); Scatter, Art and Pattern also colorization: none|tints|tintsAndShades|hueShift, keyColor, and tips: true opens Colorization Tips (what each method does, beside a sample of the brush painted with it), as the Tips button beside Method does; OK runs brush.options only when its name or options changed; unchanged approval preserves the brush and adds no Undo",
),
(
"ui.brushObjectOptions",
+6
View File
@@ -5879,6 +5879,11 @@ already walks Image Trace. Short agent entry points:
for new art become no fill and a 0.5 pt black stroke; with New Art Has Basic Appearance off, new art then takes the
selection's appearance, as after any command.
For an existing brush, approving Brush Options without changing its trimmed name or options closes the dialog
without rewriting the brush, changing the document revision or adding Undo. An empty name is ignored and counts
as unchanged. A changed name or option is saved in
one step. A brush deleted while its dialog is open still gives an error on approval.
`brush.selectionArt {ids?|id?}` (a query) replies `{art}`: the object that `brush.new` given the same `ids` or `id`,
or the same selection, takes as a new scatter or art brush's art and as a new pattern brush's side tile. Several
objects become one group, and `art` is `null` when nothing is selected or `ids` name no object. In the app, the
@@ -17711,6 +17716,7 @@ the error text. The interactive fallback applies only to ordinary File > Save, n
| Date | Change |
|---|---|
| 2026-11-27 | Existing 3D effect options: unchanged validated parameters preserve the stored effect, document revision and Undo, including defaults and equivalent numeric JSON. |
| 2026-11-27 | Brush Options: untouched approval preserves the brush, document revision and Undo; changed settings save in one step. Native UI and automation covered. Scores and estimates unchanged. |
| 2026-11-27 | Shape Control bar: canceled numeric edits restore future-tool settings and coupled radii along with selected artwork; retired edits cannot overwrite a different tool. Native scrub, keyboard, next-shape and Undo cases covered. Scores and estimates unchanged. |
| 2026-11-27 | Anchor Inspector: Cancel restores Corner radius/kind and Shared Edge diameter/coincidence tool values; accepted settings leave document history unchanged. Native numeric and menu cases covered. Scores and estimates unchanged. |
| 2026-11-18 | Production Preflight: output and artboard scope, four check summaries, clickable canvas ids, effective PPI and explicit unchecked resolution coverage. |
+1
View File
@@ -451,6 +451,7 @@ next unit in the order a right-click on a ruler lists them, from Feet back to Po
| Interaction | Status | Evidence |
|---|---|---|
| Brush Options › Key Color eyedropper yields to one canvas click, then resumes the same draft and previous tool | done | #8284; the pick changes the dialog draft without painting or editing the document. OK applies the brush options; Cancel discards them. Escape ends the pick without sampling before a later Escape cancels the dialog. Six full-app input regressions in `crates/ui-egui/tests/brush_keycolor_modal_repro.rs` cover the actual pick, OK/reopen/Cancel, Escape, reentry, held clicks, stale releases and ordinary modal blocking. |
| Brush Options skip unchanged approval | done | Approving without editing preserves the brush, document revision and Undo history. |
| Ordinary Save refused by filesystem permissions/read-only storage offers Save As | focused UI regressions passed; native acceptance pending | #6146; `io::tests_read_only_save`; same name/format suggested; unchanged format keeps options, changed format opens its Save options; Documents folder, UID-bound continuation; cancellation and automation isolation |
| Selection artwork drag hovers a visible document tab to activate it, then drops editable artwork on its canvas | done | `tests_document_drag`, `edit.dropSelection`, lossless resource and one-step Undo regressions; a release over another document's tiled pane copies it there too (`canvas::panes` tests), and so does a release over a floating window drawn inside the main window (`doc_windows` tests); overflow-menu drag and floating OS windows remain separate |
| A document tab dragged along the tab strip moves its document; a line marks where it goes, the current document and every document's view stay as they were, and a drag off the strip still floats it | done | #5663, [public source](https://helpx.adobe.com/illustrator/using/customizing-workspace.html); `document.move`; `tests::tab_reorder`, `chrome::tests` (drop index with floating and view tabs), `engine` `tests::document_move` |