From 70885f54668ca71bd8dd4781bfe674e405b1a22e Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 22:57:51 -0800 Subject: [PATCH] Color Wheel: document null params and the sampled gamut shading ui.colorWheel's params text and docs/mcp.md now say that a key set to null keeps its value while the other keys apply, and that the out-of-gamut shading is approximate: each cell of the 16 by 16 grid is grayed out or not by the color at its center. A test checks that null keeps view and channel while another key applies. --- crates/mcp/src/ui_catalog.rs | 2 +- crates/ui-egui/src/menus/ui_commands.rs | 2 +- crates/ui-egui/src/panels/color_wheel.rs | 5 +++-- crates/ui-egui/src/panels/tests_color_wheel_gamut.rs | 8 ++++++-- docs/mcp.md | 7 +++++-- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/crates/mcp/src/ui_catalog.rs b/crates/mcp/src/ui_catalog.rs index aa8a0f8cbf..dc8fbefef8 100644 --- a/crates/mcp/src/ui_catalog.rs +++ b/crates/mcp/src/ui_catalog.rs @@ -1418,7 +1418,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "ui.colorWheel", "Color Wheel Options", "", - "{view?: wheel|box, channel?: hue|saturation|brightness|red|green|blue, gamut?: bool} show the Color Wheel panel's wheel or its box, as the panel menu's Wheel View and Box View do, and pick the box's channel, as Box Channel does: the box is a color field with the channel's strip at its right, and the field shows the other two components (hue: saturation across and brightness up; saturation: hue across and brightness up; brightness: hue across and saturation up; red: blue across and green up; green: blue across and red up; blue: red across and green up); gamut true grays out the parts of the wheel's square and the box's field whose colors the CMYK space cannot print (the out-of-gamut warning's test, as color.gamutCheck answers it), as Show Out-of-Gamut Colors does, and false shows them again; keys left out keep their values, params that are not an object, another key or a value off the list are an error and change nothing, all three are kept with the preferences, and the command does not open the panel (window.panel {panel: \"colorWheel\"} does) (ui.inspect: ui.color_wheel) → {view, channel, gamut}", + "{view?: wheel|box, channel?: hue|saturation|brightness|red|green|blue, gamut?: bool} show the Color Wheel panel's wheel or its box, as the panel menu's Wheel View and Box View do, and pick the box's channel, as Box Channel does: the box is a color field with the channel's strip at its right, and the field shows the other two components (hue: saturation across and brightness up; saturation: hue across and brightness up; brightness: hue across and saturation up; red: blue across and green up; green: blue across and red up; blue: red across and green up); gamut true grays out the parts of the wheel's square and the box's field whose colors the CMYK space cannot print (the out-of-gamut warning's test, as color.gamutCheck answers it), as Show Out-of-Gamut Colors does, and false shows them again; the shading is approximate: each cell of a 16 by 16 grid over the square or the field is grayed out or not by the color at its center, so a grayed cell can hold printable colors and a clear cell can hold colors that cannot print; keys left out or set to null keep their values while the other keys apply, params that are not an object, another key or a value off the list are an error and change nothing, all three are kept with the preferences, and the command does not open the panel (window.panel {panel: \"colorWheel\"} does) (ui.inspect: ui.color_wheel) → {view, channel, gamut}", ), ( "ui.savePdfDialog", diff --git a/crates/ui-egui/src/menus/ui_commands.rs b/crates/ui-egui/src/menus/ui_commands.rs index 1b9165108c..9648962555 100644 --- a/crates/ui-egui/src/menus/ui_commands.rs +++ b/crates/ui-egui/src/menus/ui_commands.rs @@ -1419,7 +1419,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "ui.colorWheel", "Color Wheel Options", "", - "{view?: wheel|box, channel?: hue|saturation|brightness|red|green|blue, gamut?: bool} show the Color Wheel panel's wheel or its box, as the panel menu's Wheel View and Box View do, and pick the box's channel, as Box Channel does: the box is a color field with the channel's strip at its right, and the field shows the other two components (hue: saturation across and brightness up; saturation: hue across and brightness up; brightness: hue across and saturation up; red: blue across and green up; green: blue across and red up; blue: red across and green up); gamut true grays out the parts of the wheel's square and the box's field whose colors the CMYK space cannot print (the out-of-gamut warning's test, as color.gamutCheck answers it), as Show Out-of-Gamut Colors does, and false shows them again; keys left out keep their values, params that are not an object, another key or a value off the list are an error and change nothing, all three are kept with the preferences, and the command does not open the panel (window.panel {panel: \"colorWheel\"} does) (ui.inspect: ui.color_wheel) → {view, channel, gamut}", + "{view?: wheel|box, channel?: hue|saturation|brightness|red|green|blue, gamut?: bool} show the Color Wheel panel's wheel or its box, as the panel menu's Wheel View and Box View do, and pick the box's channel, as Box Channel does: the box is a color field with the channel's strip at its right, and the field shows the other two components (hue: saturation across and brightness up; saturation: hue across and brightness up; brightness: hue across and saturation up; red: blue across and green up; green: blue across and red up; blue: red across and green up); gamut true grays out the parts of the wheel's square and the box's field whose colors the CMYK space cannot print (the out-of-gamut warning's test, as color.gamutCheck answers it), as Show Out-of-Gamut Colors does, and false shows them again; the shading is approximate: each cell of a 16 by 16 grid over the square or the field is grayed out or not by the color at its center, so a grayed cell can hold printable colors and a clear cell can hold colors that cannot print; keys left out or set to null keep their values while the other keys apply, params that are not an object, another key or a value off the list are an error and change nothing, all three are kept with the preferences, and the command does not open the panel (window.panel {panel: \"colorWheel\"} does) (ui.inspect: ui.color_wheel) → {view, channel, gamut}", ), ( "ui.savePdfDialog", diff --git a/crates/ui-egui/src/panels/color_wheel.rs b/crates/ui-egui/src/panels/color_wheel.rs index 64c75fa5aa..6009ba5963 100644 --- a/crates/ui-egui/src/panels/color_wheel.rs +++ b/crates/ui-egui/src/panels/color_wheel.rs @@ -104,8 +104,9 @@ pub fn deserialize_settings<'de, D: serde::Deserializer<'de>>(d: D) -> Result Result { const KEYS: [&str; 3] = ["view", "channel", "gamut"]; match p { diff --git a/crates/ui-egui/src/panels/tests_color_wheel_gamut.rs b/crates/ui-egui/src/panels/tests_color_wheel_gamut.rs index f24329b69d..b124ab492b 100644 --- a/crates/ui-egui/src/panels/tests_color_wheel_gamut.rs +++ b/crates/ui-egui/src/panels/tests_color_wheel_gamut.rs @@ -150,8 +150,9 @@ fn with_the_setting_off_no_grid_is_computed() { assert_eq!(drawn(&h), None); } -/// `ui.colorWheel {gamut}` sets the setting and keeps the others; a value that is not true or -/// false is an error that changes nothing, translated where messages are. +/// `ui.colorWheel {gamut}` sets the setting and keeps the others; a key set to null keeps its value +/// while the other keys apply; a value that is not true or false is an error that changes nothing, +/// translated where messages are. #[test] fn ui_color_wheel_sets_gamut() { let mut app = VectorcraftApp::new(Session::new(), Default::default()); @@ -161,6 +162,9 @@ fn ui_color_wheel_sets_gamut() { assert_eq!(e, "`gamut` must be true or false"); assert_eq!(app.ui.color_wheel, Settings { view: View::Box, gamut: true, ..Default::default() }, "an error changes nothing"); assert_eq!(app.run("ui.colorWheel", json!({"gamut": null})).unwrap()["gamut"], json!(true), "null keeps the value"); + app.run("ui.colorWheel", json!({"channel": "red"})).unwrap(); + let got = app.run("ui.colorWheel", json!({"view": "wheel", "channel": null, "gamut": null})).unwrap(); + assert_eq!(got, json!({"view": "wheel", "channel": "red", "gamut": true}), "null keeps a value while the other keys apply"); assert_eq!(app.run("ui.colorWheel", json!({"gamut": false})).unwrap()["gamut"], json!(false)); for code in ["de", "fr", "ja", "zh-hans"] { let lang = crate::i18n::Lang::from_code(code).expect("registered"); diff --git a/docs/mcp.md b/docs/mcp.md index 1f11853929..2af8195eee 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -674,8 +674,11 @@ and answers true when the fields show in percent. strip at its right) in place of the wheel, as the panel menu's Box View and Box Channel do, and `"view": "wheel"` shows the wheel again. `"gamut": true` grays out the parts of the wheel's square and the box's field whose colors the CMYK space cannot print, as the panel menu's Show Out-of-Gamut Colors does, and `false` shows them again. The -test is the out-of-gamut warning's, which `color.gamutCheck` answers for one color. Keys left out keep their values. -Params that are not an object, another key or a value off the list return an error and change nothing. The command +test is the out-of-gamut warning's, which `color.gamutCheck` answers for one color. The shading is approximate: the +panel tests the color at the center of each cell of a 16 by 16 grid over the square or the field and grays out the +whole cell or none of it, so a grayed cell can hold printable colors and a clear cell can hold colors that cannot +print. Keys left out or set to `null` keep their values, and the other keys still apply. Params that are not an +object, another key or a value off the list return an error and change nothing. The command returns `{view, channel, gamut}`, and the settings are kept with the preferences. In remote desktop mode, `invoke_menu` with `{"command":"ui.sampleScreenColor","params":{}}` shows the system's