mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-26 20:38:21 +00:00
Recolor with Preset: reject a color group
ui.recolorDialog with preset: true and a group opened the preset dialog and dropped the group, so OK recolored the art without rewriting the group. That call is now an error. The params text and docs/control-protocol.md say so.
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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<Value, String> {
|
||||
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.
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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<Value> =
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user