diff --git a/crates/mcp/src/ui_catalog.rs b/crates/mcp/src/ui_catalog.rs index 18951b9c90..f2c66fd0e7 100644 --- a/crates/mcp/src/ui_catalog.rs +++ b/crates/mcp/src/ui_catalog.rs @@ -995,7 +995,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "ui.recolorDialog", "Recolor Artwork…", "", - "{colors?: n (an n-colour job: n rows, Scale Tints) | [colour] (new colours to assign, in order; with no art selected and no group they are the rows, and OK saves them as a new colour group, field `groupName`: the Color Guide's Edit or Apply Colors), library?: id or name; or \"document\" (Limit to Library; \"\" the first library), group?: colour group (Edit or Apply Color Group: OK rewrites the group with the new colours and recolours the selected art, if any), preset?: bool (Recolor with Preset: first open the `recolorPreset` dialog, whose Limit to Library field `limitTo` starts on `library`; its OK opens Recolor Artwork with `colors` and that library)} open Recolor Artwork (dialog `recolor`; engine: recolor.reduce / recolor.apply)", + "{colors?: n (an n-colour job: n rows, Scale Tints) | [colour] (new colours to assign, in order; with no art selected and no group they are the rows, and OK saves them as a new colour group, field `groupName`: the Color Guide's Edit or Apply Colors), library?: id or name; or \"document\" (Limit to Library; \"\" the first library), group?: colour group (Edit or Apply Color Group: OK rewrites the group with the new colours and recolours the selected art, if any), preset?: bool (Recolor with Preset: first open the `recolorPreset` dialog, whose Limit to Library field `limitTo` starts on `library`; its OK opens Recolor Artwork with `colors` and that library; an error with `group`)} open Recolor Artwork (dialog `recolor`; engine: recolor.reduce / recolor.apply)", ), ( "ui.recolorUndo", diff --git a/crates/ui-egui/src/dialogs/recolor_preset.rs b/crates/ui-egui/src/dialogs/recolor_preset.rs index a9063c8945..9ebde00787 100644 --- a/crates/ui-egui/src/dialogs/recolor_preset.rs +++ b/crates/ui-egui/src/dialogs/recolor_preset.rs @@ -1,6 +1,6 @@ //! Edit → Edit Colors → Recolor with Preset: before Recolor Artwork opens on a preset (an n-color //! job or Color Library), this dialog asks whether to limit the new colors to a swatch library -//! (`ui.recolorDialog {preset: true, colors?, library?}`). OK opens Recolor Artwork with the +//! (`ui.recolorDialog {preset: true, colors?, library?}`, without `group`). OK opens Recolor Artwork with the //! preset's colors and the library chosen (None: no limit); Cancel opens nothing. //! //! Fields: `colors` (the preset's count, null for Color Library) and `limitTo` (a library id, @@ -27,6 +27,9 @@ pub fn open(app: &mut VectorcraftApp, p: &Value) -> Result { if st.selection.is_empty() { return Err("select artwork to recolor".into()); } + if p.get("group").is_some_and(|g| !g.is_null()) { + return Err("`group` does not apply to a preset".into()); + } let colors = count(p.get("colors"))?; let limit = library_param(app, p)?; // A dialog this one replaces ends as Cancel ends it, its preview rolled back. diff --git a/crates/ui-egui/src/menus/ui_commands.rs b/crates/ui-egui/src/menus/ui_commands.rs index 27bcf98155..10b0982582 100644 --- a/crates/ui-egui/src/menus/ui_commands.rs +++ b/crates/ui-egui/src/menus/ui_commands.rs @@ -996,7 +996,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "ui.recolorDialog", "Recolor Artwork…", "", - "{colors?: n (an n-colour job: n rows, Scale Tints) | [colour] (new colours to assign, in order; with no art selected and no group they are the rows, and OK saves them as a new colour group, field `groupName`: the Color Guide's Edit or Apply Colors), library?: id or name; or \"document\" (Limit to Library; \"\" the first library), group?: colour group (Edit or Apply Color Group: OK rewrites the group with the new colours and recolours the selected art, if any), preset?: bool (Recolor with Preset: first open the `recolorPreset` dialog, whose Limit to Library field `limitTo` starts on `library`; its OK opens Recolor Artwork with `colors` and that library)} open Recolor Artwork (dialog `recolor`; engine: recolor.reduce / recolor.apply)", + "{colors?: n (an n-colour job: n rows, Scale Tints) | [colour] (new colours to assign, in order; with no art selected and no group they are the rows, and OK saves them as a new colour group, field `groupName`: the Color Guide's Edit or Apply Colors), library?: id or name; or \"document\" (Limit to Library; \"\" the first library), group?: colour group (Edit or Apply Color Group: OK rewrites the group with the new colours and recolours the selected art, if any), preset?: bool (Recolor with Preset: first open the `recolorPreset` dialog, whose Limit to Library field `limitTo` starts on `library`; its OK opens Recolor Artwork with `colors` and that library; an error with `group`)} open Recolor Artwork (dialog `recolor`; engine: recolor.reduce / recolor.apply)", ), ( "ui.recolorUndo", diff --git a/crates/ui-egui/src/tests/recolor.rs b/crates/ui-egui/src/tests/recolor.rs index 9a96a274c3..455f98055a 100644 --- a/crates/ui-egui/src/tests/recolor.rs +++ b/crates/ui-egui/src/tests/recolor.rs @@ -2012,6 +2012,7 @@ fn recolor_with_preset_asks_for_a_library_first() { art(&mut app, &["#333333", "#999999"]); assert!(app.run("ui.recolorDialog", json!({"colors": 1, "preset": 1})).is_err(), "`preset` is true or false"); assert!(app.run("ui.recolorDialog", json!({"colors": 0, "preset": true})).is_err(), "a preset has at least one color"); + assert!(app.run("ui.recolorDialog", json!({"colors": 1, "preset": true, "group": "Grays"})).is_err(), "a preset takes no group"); assert_eq!(dialog_kind(&app), None); let entries = crate::menus::menu_entries(&app); let presets: Vec = diff --git a/docs/control-protocol.md b/docs/control-protocol.md index 2f19b5fd37..dfe005ba1c 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -292,7 +292,8 @@ Recolor Artwork: `ui.recolorDialog {colors?, library?, group?, preset?}` opens t or `"document"`, `""` for the first library; `group`: a colour group, Edit or Apply Color Group). With `preset: true` (the Edit › Edit Colors › Recolor with Preset items) it first opens the `recolorPreset` dialog, which asks whether to limit the colors to a swatch library: its field `limitTo` (a library id, `"document"`, or `""` for None) starts on -`library`, and its OK opens the `recolor` dialog with `colors` and that library. Fields: `rows` (`[{from: [keys], to: key, exclude?, tint?, model?}]` +`library`, and its OK opens the `recolor` dialog with `colors` and that library; `preset: true` with `group` is an +error. Fields: `rows` (`[{from: [keys], to: key, exclude?, tint?, model?}]` as `recolor.reduce` returns them), `colors` (null for Auto), `method`, `preserveWhite`, `preserveBlack`, `preserveGrays`, `limitTo`, `groupName`, `tab` (`assign` or `edit`), `rule` (harmony id), `linked`, `preview`, `sliderMode` (the mode of the color sliders under the rows: `hsb`, `rgb`, `cmyk`, `lab`, or `tint` for a row whose new