From 2843ee7fd03390d1767c7291ddd481093324b0f2 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 18 Nov 2026 22:06:47 -0800 Subject: [PATCH 1/2] Keyboard Shortcuts: Color Picker can be given a key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Edit › Keyboard Shortcuts did not list Color Picker… (`ui.colorPicker`), so no key could be assigned to it, and no menu item runs it. It is now listed, with no default key. A key assigned to it runs the command with no params, which opens the picker for the proxy in front: the fill, or the stroke while Stroke is in front, with or without a selection and with no document open. Docs: docs/mcp.md, docs/ui-parity.md. --- crates/ui-egui/src/shortcut_editor.rs | 5 ++-- crates/ui-egui/src/shortcuts/tests.rs | 34 +++++++++++++++++++++++++++ docs/mcp.md | 13 +++++----- docs/ui-parity.md | 2 +- 4 files changed, 45 insertions(+), 9 deletions(-) diff --git a/crates/ui-egui/src/shortcut_editor.rs b/crates/ui-egui/src/shortcut_editor.rs index bb71115d8a..d700325d49 100644 --- a/crates/ui-egui/src/shortcut_editor.rs +++ b/crates/ui-egui/src/shortcut_editor.rs @@ -990,9 +990,10 @@ fn listed_on_its_own(c: &vectorcraft_engine::CommandSpec) -> bool { /// Is UI command `id` (default key `sc`, params doc `params`) listed in Edit › Keyboard Shortcuts /// whether or not an item of the menu bar runs it? It is when it has a default key or a params doc /// of `{}` or `{path…}`. Rename has no default key, and a key press names the selection: it needs -/// no `id`. +/// no `id`. Color Picker… has no default key either, and a key press opens it for the proxy in +/// front. fn ui_listed_on_its_own(id: &str, sc: &str, params: &str) -> bool { - !sc.is_empty() || params.starts_with("{}") || params.starts_with("{path") || id == "ui.rename" + !sc.is_empty() || params.starts_with("{}") || params.starts_with("{path") || id == "ui.rename" || id == "ui.colorPicker" } /// Does a menu bar item run the command with no params, so that it does what its label says and opens diff --git a/crates/ui-egui/src/shortcuts/tests.rs b/crates/ui-egui/src/shortcuts/tests.rs index 5dbdc46a14..bb27f66084 100644 --- a/crates/ui-egui/src/shortcuts/tests.rs +++ b/crates/ui-egui/src/shortcuts/tests.rs @@ -1529,6 +1529,40 @@ fn polygonal_lasso_takes_backspace_delete_enter_and_escape_while_a_loop_is_open( assert_eq!(sel.anchors.get(&id).map(|a| a.len()), Some(1), "only the corner inside the loop"); } +/// Color Picker… (`ui.colorPicker`) has no default key. Keyboard Shortcuts lists it, and a key +/// assigned there opens the picker for the proxy in front: with no document open, with nothing +/// selected and with an object selected, and for the stroke while the Stroke proxy is in front. +#[test] +fn a_key_assigned_to_the_color_picker_opens_it_for_the_proxy_in_front() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + crate::shortcut_editor::sync(&app.ui); + assert_eq!(crate::shortcut_editor::default_command_shortcut("ui.colorPicker"), None); + let listed = app.run("shortcuts.list", json!({"query": "ui.colorPicker"})).unwrap(); + let rows: Vec<_> = listed.as_array().expect("rows").iter().map(|r| r["label"].clone()).collect(); + assert_eq!(rows, [json!("Color Picker…")], "Keyboard Shortcuts lists it"); + app.run("shortcuts.set", json!({"id": "ui.colorPicker", "shortcut": "Cmd+Alt+Shift+F12"})).unwrap(); + crate::shortcut_editor::sync(&app.ui); + let key = || press(Key::F12, Modifiers::COMMAND | Modifiers::ALT | Modifiers::SHIFT); + let opened = |app: &mut VectorcraftApp| { + let stroke = app.ui.dialog.as_ref().filter(|d| d.kind == "colorPicker").map(|d| d.bool("stroke")); + app.ui.dialog = None; + stroke + }; + frame(&mut app, key()); + assert_eq!(opened(&mut app), Some(false), "no document: the fill"); + app.run("file.new", json!({"width": 200, "height": 200})).unwrap(); + frame(&mut app, key()); + assert_eq!(opened(&mut app), Some(false), "nothing selected: the fill"); + let id = app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 50, "height": 50})).unwrap()["id"].clone(); + app.run("select.set", json!({"ids": [id]})).unwrap(); + frame(&mut app, key()); + assert_eq!(opened(&mut app), Some(false), "an object selected: the fill"); + app.run("paint.toggleActive", json!({})).unwrap(); + frame(&mut app, key()); + assert_eq!(opened(&mut app), Some(true), "the Stroke proxy in front: the stroke"); + crate::shortcut_editor::sync(&crate::state::UiState::default()); +} + /// Binds Show Grid to `chord`, or with `None` leaves every command its default shortcut. fn bind_grid(app: &mut VectorcraftApp, chord: Option<&str>) { app.ui.shortcut_overrides.clear(); diff --git a/docs/mcp.md b/docs/mcp.md index 5bc273289c..18eab08c4f 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -675,12 +675,13 @@ objects' fills or strokes differ (`fillMixed` / `strokeMixed`, drawn as a "?" pr In the app's Color panel and Color Picker, RGB, HSB, hex and Web Safe RGB values describe the active working RGB space. RGB edits preserve the other native channels; HSB uses those same working RGB components. Colors outside display sRGB retain their native numeric values. `ui.colorPanel` selects the panel mode and `ui.colorPicker` -opens the picker through `run_command` with the remote backend. `ui.colorPanel {"recentColors": false}` unchecks -the panel menu's Show Recent Colors, which hides the Color panel's Recent Colors row, and `true` shows it again; -applied colors still join the list while it is hidden. `ui.colorPanel {"rgbPercent": true}` shows the Color panel's -RGB fields in percent, as a double-click right of an RGB field does, and `false` shows them from 0 to 255 again. -`ui.colorRgbPercent` (Toggle RGB Percent in the command palette and Keyboard Shortcuts) switches between the two -and answers true when the fields show in percent. +opens the picker through `run_command` with the remote backend. Edit › Keyboard Shortcuts lists `ui.colorPicker` as +Color Picker… with no default key; a key assigned there opens the picker for the proxy in front, as `{}` does. +`ui.colorPanel {"recentColors": false}` unchecks the panel menu's Show Recent Colors, which hides the Color panel's +Recent Colors row, and `true` shows it again; applied colors still join the list while it is hidden. +`ui.colorPanel {"rgbPercent": true}` shows the Color panel's RGB fields in percent, as a double-click right of an RGB +field does, and `false` shows them from 0 to 255 again. `ui.colorRgbPercent` (Toggle RGB Percent in the command +palette and Keyboard Shortcuts) switches between the two and answers true when the fields show in percent. `ui.colorWheel {"view": "box", "channel": "red"}` shows the Color Wheel panel's box (a color field with the channel's 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. Keys left out keep their values. Params that are not an object, another key or a value off diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 64e6be0b94..3c7365674e 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -385,7 +385,7 @@ Cmd/Ctrl+/ (`appearance.addFill`) and Cmd/Ctrl+Alt+/ (`appearance.addStroke`) ad selected objects, as the Appearance panel's Add New Fill and Add New Stroke buttons do. ~110 distinct modified shortcuts on menu commands plus single-key tool shortcuts for the default toolbar -(`crates/tools/src/catalog.rs`), a shortcut editor with chords, and saved sets. Cmd/Ctrl+Alt+L (`ui.newLayer`) opens Layer Options for a new layer, as an Alt-click on the Layers panel's New Layer button does, and Cmd/Ctrl+L still adds a layer without the dialog. F8 (`ui.symbolOptions`) opens Symbol Options for a new symbol made from the selection, as the Symbols panel's New Symbol button does. Rename (`ui.rename`, in the shortcut editor with no default key; a VectorCraft addition, #5324) opens the Layers panel's name field on the selected layer, group or object's row, as double-clicking its name does: Enter renames it in one undo step and Escape keeps the name; several selected objects, or a row the panel's search, filter or Show Layers Only hides, is refused with a message. Not yet diffed item by item +(`crates/tools/src/catalog.rs`), a shortcut editor with chords, and saved sets. Cmd/Ctrl+Alt+L (`ui.newLayer`) opens Layer Options for a new layer, as an Alt-click on the Layers panel's New Layer button does, and Cmd/Ctrl+L still adds a layer without the dialog. F8 (`ui.symbolOptions`) opens Symbol Options for a new symbol made from the selection, as the Symbols panel's New Symbol button does. Rename (`ui.rename`, in the shortcut editor with no default key; a VectorCraft addition, #5324) opens the Layers panel's name field on the selected layer, group or object's row, as double-clicking its name does: Enter renames it in one undo step and Escape keeps the name; several selected objects, or a row the panel's search, filter or Show Layers Only hides, is refused with a message. Color Picker… (`ui.colorPicker`) is in the shortcut editor with no default key; a key assigned to it opens the Color Picker for the Fill or Stroke proxy in front, with or without a selection and with no document open. Not yet diffed item by item against Illustrator's published default shortcut list; estimated ~70% of it. Remaining: other panel shortcuts, the type shortcuts (tracking/kerning/leading/baseline steps with Alt/Shift), and selection shortcuts in the Layers panel. The shortcut editor also lists the commands that are in no menu but run without parameters (Edit › Duplicate, From fab39fc50b432df445251387f60f4617e551b925 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 19 Nov 2026 05:41:58 -0800 Subject: [PATCH 2/2] Tests: the Color Picker key opens the stroke with no document open The Color Picker shortcut test now also brings the Stroke proxy forward before a document is open and checks that the key opens the picker for the stroke. --- crates/ui-egui/src/shortcuts/tests.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/shortcuts/tests.rs b/crates/ui-egui/src/shortcuts/tests.rs index bb27f66084..3209ffd84c 100644 --- a/crates/ui-egui/src/shortcuts/tests.rs +++ b/crates/ui-egui/src/shortcuts/tests.rs @@ -1531,7 +1531,8 @@ fn polygonal_lasso_takes_backspace_delete_enter_and_escape_while_a_loop_is_open( /// Color Picker… (`ui.colorPicker`) has no default key. Keyboard Shortcuts lists it, and a key /// assigned there opens the picker for the proxy in front: with no document open, with nothing -/// selected and with an object selected, and for the stroke while the Stroke proxy is in front. +/// selected and with an object selected, and for the stroke while the Stroke proxy is in front, +/// with or without a document open. #[test] fn a_key_assigned_to_the_color_picker_opens_it_for_the_proxy_in_front() { let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); @@ -1550,6 +1551,10 @@ fn a_key_assigned_to_the_color_picker_opens_it_for_the_proxy_in_front() { }; frame(&mut app, key()); assert_eq!(opened(&mut app), Some(false), "no document: the fill"); + app.run("paint.toggleActive", json!({"fill": false})).unwrap(); + frame(&mut app, key()); + assert_eq!(opened(&mut app), Some(true), "no document, the Stroke proxy in front: the stroke"); + app.run("paint.toggleActive", json!({"fill": true})).unwrap(); app.run("file.new", json!({"width": 200, "height": 200})).unwrap(); frame(&mut app, key()); assert_eq!(opened(&mut app), Some(false), "nothing selected: the fill");