From 8861fd358bbea99da6fecc82a2f7c662c579818c Mon Sep 17 00:00:00 2001 From: ljkx <177671075+ljkx@users.noreply.github.com> Date: Mon, 2 Nov 2026 19:02:12 +0100 Subject: [PATCH 1/3] Nudge: Ctrl/Cmd+arrow moves by a tenth of the keyboard increment (#5258) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The arrow keys nudged by the keyboard increment and Shift+arrow by ten, but there was no fine step on the canvas, although the Transform panel's fields step by 0.1 with Ctrl. object.nudge and perspective.nudge now take `fine` (÷10; with `big`, one increment), and Ctrl/Cmd+arrow passes it for art, direct-selected anchors, ruler guides and the Perspective Selection tool. Each press stays one undo step. Fixes #5258 --- crates/engine/src/cmd/distortcmds.rs | 2 +- .../engine/src/cmd/distortcmds/perspective.rs | 2 +- crates/engine/src/cmd/object.rs | 2 +- crates/engine/src/cmd/object/commands.rs | 2 +- crates/engine/src/cmd/object/transform.rs | 16 ++++++- crates/engine/src/tests/persp_select.rs | 7 +++ crates/engine/src/tests/prefs.rs | 43 +++++++++++++++++++ crates/engine/tests/command_sweep.rs | 1 + crates/tools/src/distort/perspective/tools.rs | 2 +- crates/ui-egui/src/shortcuts.rs | 4 +- docs/ui-parity.md | 5 ++- 11 files changed, 75 insertions(+), 11 deletions(-) diff --git a/crates/engine/src/cmd/distortcmds.rs b/crates/engine/src/cmd/distortcmds.rs index 9e0841de66..d72fa442da 100644 --- a/crates/engine/src/cmd/distortcmds.rs +++ b/crates/engine/src/cmd/distortcmds.rs @@ -171,7 +171,7 @@ pub fn specs() -> Vec { "Nudge in Perspective", [], None, - "{dx, dy: arrow direction (-1, 0 or 1), big?: bool (×10), copy?: bool} move the selection in perspective by the keyboard increment, as the arrow keys do with the Perspective Selection tool → {ids}", + "{dx, dy: arrow direction (-1, 0 or 1), big?: bool (×10), fine?: bool (÷10; with big, one increment), copy?: bool} move the selection in perspective by the keyboard increment, as the arrow keys do with the Perspective Selection tool → {ids}", has_selection, persp_nudge ), diff --git a/crates/engine/src/cmd/distortcmds/perspective.rs b/crates/engine/src/cmd/distortcmds/perspective.rs index 786d0d9568..042f6c8dcc 100644 --- a/crates/engine/src/cmd/distortcmds/perspective.rs +++ b/crates/engine/src/cmd/distortcmds/perspective.rs @@ -503,7 +503,7 @@ pub(super) fn persp_nudge(s: &mut Session, p: &Value) -> Result { if !(dx.is_finite() && dy.is_finite()) || (dx == 0.0 && dy == 0.0) { return Err(bad(C, "dx and dy give the arrow's direction")); } - let k = s.prefs.keyboard_increment * if switch_or(p, "big", false, C)? { 10.0 } else { 1.0 }; + let k = crate::cmd::object::nudge_step(s.prefs.keyboard_increment, switch_or(p, "big", false, C)?, switch_or(p, "fine", false, C)?); let copy = switch_or(p, "copy", false, C)?; let ids = selected_roots(s)?; // The step is measured on the page at the centre of the selection's perspective box. diff --git a/crates/engine/src/cmd/object.rs b/crates/engine/src/cmd/object.rs index bac3540fad..b1c02d08b5 100644 --- a/crates/engine/src/cmd/object.rs +++ b/crates/engine/src/cmd/object.rs @@ -36,4 +36,4 @@ pub(crate) use bounds::{bounds_rewrite, object_bounds_transform}; pub use commands::specs; pub(super) use compound::{as_clipping_path, make_clipping_path, release_clip}; pub(super) use shape::recut; -pub(crate) use transform::{apply_transform, preview_copies, scaling, transform_node, transform_patterns, transforms_objects}; +pub(crate) use transform::{apply_transform, nudge_step, preview_copies, scaling, transform_node, transform_patterns, transforms_objects}; diff --git a/crates/engine/src/cmd/object/commands.rs b/crates/engine/src/cmd/object/commands.rs index 69f464edb1..584b48b61b 100644 --- a/crates/engine/src/cmd/object/commands.rs +++ b/crates/engine/src/cmd/object/commands.rs @@ -78,7 +78,7 @@ pub fn specs() -> Vec { "Nudge", [], None, - "{dx: -1|0|1, dy: -1|0|1, big?: bool (×10), copy?: bool, patterns?: bool (Transform Patterns: pattern fills and strokes transform with the objects that move whole; default: prefs transformPatternTiles), typeAreas?: bool (area type: the frame is reshaped and the text reflows at its size), objects?: bool (Transform Objects, as object.move)} arrow-key nudge by the keyboard increment (the selected anchors, else objects, along the x and y axes turned by the constrainAngle preference; else ruler guides, along the page axes)", + "{dx: -1|0|1, dy: -1|0|1, big?: bool (×10), fine?: bool (÷10; with big, one increment), copy?: bool, patterns?: bool (Transform Patterns: pattern fills and strokes transform with the objects that move whole; default: prefs transformPatternTiles), typeAreas?: bool (area type: the frame is reshaped and the text reflows at its size), objects?: bool (Transform Objects, as object.move)} arrow-key nudge by the keyboard increment (the selected anchors, else objects, along the x and y axes turned by the constrainAngle preference; else ruler guides, along the page axes)", has_selection_or_guides, nudge ), diff --git a/crates/engine/src/cmd/object/transform.rs b/crates/engine/src/cmd/object/transform.rs index bed6e6c381..2c1cbc3db6 100644 --- a/crates/engine/src/cmd/object/transform.rs +++ b/crates/engine/src/cmd/object/transform.rs @@ -290,11 +290,23 @@ pub(crate) fn along_constrain_angle(dx: f64, dy: f64, deg: f64) -> (f64, f64) { (v.x, v.y) } +/// The arrow keys' step: the keyboard increment, ×10 with Shift (`big`) and ÷10 with Ctrl/Cmd +/// (`fine`), so Shift+Ctrl+arrow moves by one increment. Divided, not multiplied by 0.1, so a tenth +/// of a 1 pt increment is the nearest `f64` to 0.1. +pub(crate) fn nudge_step(increment: f64, big: bool, fine: bool) -> f64 { + match (big, fine) { + (true, true) => increment, + (true, false) => increment * 10.0, + (false, true) => increment / 10.0, + (false, false) => increment, + } +} + pub(super) fn nudge(s: &mut Session, p: &Value) -> Result { check_numbers(p, &["dx", "dy"], "object.nudge")?; check_switches(p, &TRANSFORM_SWITCHES, "object.nudge")?; - check_switches(p, &["big"], "object.nudge")?; - let k = s.prefs.keyboard_increment * if bool_or(p, "big", false) { 10.0 } else { 1.0 }; + check_switches(p, &["big", "fine"], "object.nudge")?; + let k = nudge_step(s.prefs.keyboard_increment, bool_or(p, "big", false), bool_or(p, "fine", false)); let (dx, dy) = (f64_or(p, "dx", 0.0) * k, f64_or(p, "dy", 0.0) * k); // Guides keep to the page's axes; art and anchors move along the constrain angle's. let (gx, gy) = (dx, dy); diff --git a/crates/engine/src/tests/persp_select.rs b/crates/engine/src/tests/persp_select.rs index 4ca4b46faf..60fd1dcfb0 100644 --- a/crates/engine/src/tests/persp_select.rs +++ b/crates/engine/src/tests/persp_select.rs @@ -508,6 +508,13 @@ fn arrow_keys_nudge_in_perspective() { let c = bounds_of(&before).center(); let step = h.apply(c + d).unwrap() - h.apply(c).unwrap(); assert!((step - Vec2::new(s.prefs.keyboard_increment, 0.0)).hypot() < 1e-6, "{step:?}"); + // Ctrl/Cmd takes a tenth of a step. + let before = plane_pts(&s, id, Plane::Right, 0.0); + s.tool_key(ToolKey::Right, Mods { cmd: true, ..Default::default() }, v).unwrap(); + let after = plane_pts(&s, id, Plane::Right, 0.0); + let c = bounds_of(&before).center(); + let step = h.apply(c + (after[0] - before[0])).unwrap() - h.apply(c).unwrap(); + assert!((step - Vec2::new(s.prefs.keyboard_increment / 10.0, 0.0)).hypot() < 1e-6, "{step:?}"); // Alt copies; Shift takes ten steps. s.tool_key(ToolKey::Left, Mods { alt: true, shift: true, ..Default::default() }, v).unwrap(); let copy = *s.doc().unwrap().selection.objects.first().unwrap(); diff --git a/crates/engine/src/tests/prefs.rs b/crates/engine/src/tests/prefs.rs index b590e3c289..46a9c24a12 100644 --- a/crates/engine/src/tests/prefs.rs +++ b/crates/engine/src/tests/prefs.rs @@ -38,6 +38,49 @@ fn set_and_get_keyboard_increment_drives_nudge() { assert!((b.x0 - 15.0).abs() < 1e-9); } +/// Ctrl/Cmd+arrow (`fine`) nudges by a tenth of the keyboard increment, and Shift+Ctrl+arrow +/// (`big` and `fine`) by one increment: art, direct-selected anchors and ruler guides, one undo +/// step per press, and repeated fine nudges add up to whole increments. +#[test] +fn fine_nudge_moves_a_tenth_of_the_keyboard_increment() { + let mut s = Session::new(); + s.execute("prefs.set", &json!({"key": "keyboardIncrement", "value": 5})).unwrap(); + s.execute("file.new", &json!({"width": 400, "height": 400})).unwrap(); + let r = s.execute("shape.rectangle", &json!({"x": 10, "y": 10, "width": 20, "height": 20})).unwrap(); + let id = NodeId(r["id"].as_u64().unwrap()); + let x0 = |s: &Session| s.doc().unwrap().doc.node(id).unwrap().geometric_bounds().unwrap().x0; + let undo = |s: &Session| s.doc().unwrap().history.undo.len(); + let n = undo(&s); + s.execute("object.nudge", &json!({"dx": 1, "dy": 0, "fine": true})).unwrap(); + assert!((x0(&s) - 10.5).abs() < 1e-9, "{}", x0(&s)); + assert_eq!(undo(&s), n + 1, "one undo step per press"); + s.execute("object.nudge", &json!({"dx": -1, "dy": 0, "big": true, "fine": true})).unwrap(); + assert!((x0(&s) - 5.5).abs() < 1e-9, "Shift+Ctrl: one increment, {}", x0(&s)); + for _ in 0..10 { + s.execute("object.nudge", &json!({"dx": 1, "dy": 0, "fine": true})).unwrap(); + } + assert!((x0(&s) - 10.5).abs() < 1e-9, "ten fine nudges are one increment, {}", x0(&s)); + assert_eq!(undo(&s), n + 12); + + // Direct-selected anchors. + s.execute("select.anchors", &json!({"id": id.0, "anchors": [[0, 0]]})).unwrap(); + let p0 = |s: &Session| s.doc().unwrap().doc.node(id).unwrap().path_data().unwrap().subpaths[0].anchors[0].p; + let before = p0(&s); + s.execute("object.nudge", &json!({"dx": 0, "dy": 1, "fine": true})).unwrap(); + let d = p0(&s) - before; + assert!(d.x.abs() < 1e-9 && (d.y - 0.5).abs() < 1e-9, "{d:?}"); + + // Ruler guides. + s.execute("select.none", &json!({})).unwrap(); + s.execute("guide.add", &json!({"vertical": true, "pos": 100})).unwrap(); + s.execute("guide.select", &json!({"indexes": [0]})).unwrap(); + s.execute("object.nudge", &json!({"dx": 1, "dy": 0, "fine": true})).unwrap(); + let pos = s.doc().unwrap().doc.guides[0].pos; + assert!((pos - 100.5).abs() < 1e-9, "{pos}"); + + assert!(s.execute("object.nudge", &json!({"dx": 1, "fine": "true"})).is_err()); +} + #[test] fn set_rejects_out_of_range_and_wrong_types() { let mut s = Session::new(); diff --git a/crates/engine/tests/command_sweep.rs b/crates/engine/tests/command_sweep.rs index 45f6b47680..223269a873 100644 --- a/crates/engine/tests/command_sweep.rs +++ b/crates/engine/tests/command_sweep.rs @@ -336,6 +336,7 @@ fn structured_junk() { ("perspective.transform", json!({"matrix": [1, 0, 0, 1, 0, 0], "depth": -1e9, "plane": "left", "copy": true})), ("perspective.transform", json!({"matrix": [1, 0, 0, 1, 1e300, 0], "plane": "left"})), ("perspective.nudge", json!({"dx": 1e308, "dy": -1e308, "big": true, "copy": true})), + ("perspective.nudge", json!({"dx": 1e308, "dy": -1e308, "fine": true})), ("perspective.plane.move", json!({"plane": "ground", "offset": 1e308, "objects": "copy"})), ("perspective.plane.move", json!({"plane": "left", "by": -1e7, "objects": "move"})), ("perspective.plane.move", json!({"plane": "none", "offset": 0})), diff --git a/crates/tools/src/distort/perspective/tools.rs b/crates/tools/src/distort/perspective/tools.rs index 915e4a8835..4e501e3339 100644 --- a/crates/tools/src/distort/perspective/tools.rs +++ b/crates/tools/src/distort/perspective/tools.rs @@ -330,7 +330,7 @@ impl Tool for PerspectiveSelectionTool { if !self.claims_key(cx, key) { return vec![]; } - vec![Action::Exec("perspective.nudge".into(), json!({"dx": dx, "dy": dy, "big": mods.shift, "copy": mods.alt}))] + vec![Action::Exec("perspective.nudge".into(), json!({"dx": dx, "dy": dy, "big": mods.shift, "fine": mods.cmd, "copy": mods.alt}))] } fn claims_key(&self, cx: &ToolContext, key: ToolKey) -> bool { // The arrows nudge a selection in perspective. diff --git a/crates/ui-egui/src/shortcuts.rs b/crates/ui-egui/src/shortcuts.rs index 9c62eb1885..0af986dc36 100644 --- a/crates/ui-egui/src/shortcuts.rs +++ b/crates/ui-egui/src/shortcuts.rs @@ -508,12 +508,12 @@ fn type_tool_input(app: &mut VectorcraftApp, ctx: &egui::Context, composing: boo /// Apply arrow-key movement and clear selected art when no text editor owns input, unless a Layers /// or Appearance row has Delete/Backspace (`rows_keys`). fn nudge_and_clear(app: &mut VectorcraftApp, ctx: &egui::Context, rows_keys: bool) { - // Arrow nudges (Shift = ×10, Alt = copy). + // Arrow nudges (Shift = ×10, Ctrl/Cmd = ÷10, Alt = copy). let arrows = [(Key::ArrowLeft, -1.0, 0.0), (Key::ArrowRight, 1.0, 0.0), (Key::ArrowUp, 0.0, -1.0), (Key::ArrowDown, 0.0, 1.0)]; for (k, dx, dy) in arrows { let m = ctx.input(|i| i.modifiers); if ctx.input_mut(|i| i.consume_key(m, k)) && app.session.active().is_some_and(|d| d.selection.has_objects_or_guides()) { - let _ = app.run("object.nudge", json!({"dx": dx, "dy": dy, "big": m.shift, "copy": m.alt})); + let _ = app.run("object.nudge", json!({"dx": dx, "dy": dy, "big": m.shift, "fine": m.command, "copy": m.alt})); } } // Delete / Backspace clear the selection. diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 26d3dd6790..7a946e35a1 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-03 · **Change:** minor (Type on a Path Options has a Preview checkbox, #5360; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x; Units › East Asian Type acts, with Q and Ha units; scores unchanged) · **Target:** Adobe Illustrator 2026 (30.x) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-03 · **Change:** minor (Type on a Path Options has a Preview checkbox, #5360; Ctrl/Cmd+arrow fine nudge, #5258; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x; Units › East Asian Type acts, with Q and Ha units; scores unchanged) · **Target:** Adobe Illustrator 2026 (30.x) ## Feature submission evidence @@ -210,7 +210,7 @@ tools, never checked side by side) isn't captured row by row. | Behaviour | Status | Notes | |---|---|---| | Wheel over a closed font-family field in Character, Properties or Control | done | #5253: applies the next or previous family to selected text, one undo step per notch; uses saved font filters, ignores search text and stops at the list's ends. Escape and pointer departure keep the change. Other font-picking menus and modifier-wheel input keep their existing behavior. | -| Arrow keys nudge by Keyboard Increment (0.001–1296 pt); Shift ×10; Alt copies | done | | +| Arrow keys nudge by Keyboard Increment (0.001–1296 pt); Shift ×10; Ctrl/Cmd ÷10 (Shift+Ctrl/Cmd: one increment), as the Transform panel fields step; Alt copies | done | Ctrl/Cmd ÷10 is VectorCraft's own addition (#5258) | | Fields commit what was typed on a click away or a move to another field, as Enter does; Escape discards it | done | #1787 | | Number fields: Up/Down step, Shift ×10, Cmd/Ctrl ÷10, wheel over a focused field; steps, the wheel and label scrubs stop at the field's bounds (a stroke weight at 0, a miter limit at 1) | done | Shift+arrow in the Stroke weight field doesn't step by 10 (#991); bounds #3370 | | Arithmetic in fields (`+ - * /`, and `%` of the value before it: `3cm*50%`, `50pt+25%`) and unit suffixes (`3 mm`, `1in`, `2p6`) | done | `Unit::parse`; mixed units in one expression not verified | @@ -418,6 +418,7 @@ separate. Scores and hours unchanged. [Behavior and command details](development | Date | Change | Summary | |---|---|---| +| 2026-11-02 | minor | Arrow keys: Ctrl/Cmd+arrow nudges art, direct-selected anchors, ruler guides and a selection in perspective by a tenth of the Keyboard Increment, and Shift+Ctrl/Cmd+arrow by one increment; `object.nudge` and `perspective.nudge` take `fine` (#5258); scores and estimates unchanged | | 2026-11-03 | minor | Enclosing Lasso selects fully enclosed objects with a freehand loop under Object › Plug-ins; scores and estimates unchanged. | | 2026-11-03 | minor | Type on a Path Options has a Preview checkbox (#5360, as public tutorials of the dialog show); scores and estimates unchanged | | 2026-11-02 | minor | Font-family fields in Character, Properties and Control accept the wheel without opening the menu (#5253); scores and estimates unchanged. | From b9e385404065ff33e55f8ec5651a98100392e443 Mon Sep 17 00:00:00 2001 From: ljkx <177671075+ljkx@users.noreply.github.com> Date: Tue, 3 Nov 2026 01:59:18 +0100 Subject: [PATCH 2/3] Perspective nudge: skip Snap to Grid so grid-aligned art moves Snap to Grid pulled an edge within a quarter cell of a gridline back onto it, so an arrow-key nudge (1 pt or 0.1 pt) of art on the gridlines moved nothing and recorded no undo step. `perspective.nudge` now passes `snap: false`; `perspective.move` still snaps. Also: `fine` is covered by both commands' non-boolean refusal tests, and the no-op test no longer lists the snapped nudge. --- crates/engine/src/cmd/distortcmds.rs | 2 +- .../engine/src/cmd/distortcmds/perspective.rs | 10 +++++- crates/engine/src/cmd/object/transform.rs | 3 ++ crates/engine/src/tests.rs | 1 + crates/engine/src/tests/distort.rs | 24 ++++++------- crates/engine/src/tests/persp_select.rs | 35 +++++++++++++++++++ crates/ui-egui/src/shortcuts/tests.rs | 22 ++++++++++++ docs/mcp.md | 10 +++--- docs/ui-parity.md | 2 +- 9 files changed, 87 insertions(+), 22 deletions(-) diff --git a/crates/engine/src/cmd/distortcmds.rs b/crates/engine/src/cmd/distortcmds.rs index d72fa442da..aa580d31a9 100644 --- a/crates/engine/src/cmd/distortcmds.rs +++ b/crates/engine/src/cmd/distortcmds.rs @@ -171,7 +171,7 @@ pub fn specs() -> Vec { "Nudge in Perspective", [], None, - "{dx, dy: arrow direction (-1, 0 or 1), big?: bool (×10), fine?: bool (÷10; with big, one increment), copy?: bool} move the selection in perspective by the keyboard increment, as the arrow keys do with the Perspective Selection tool → {ids}", + "{dx, dy: arrow direction (-1, 0 or 1), big?: bool (×10), fine?: bool (÷10; with big, one increment), copy?: bool} move the selection in perspective by the keyboard increment (Snap to Grid doesn't apply), as the arrow keys do with the Perspective Selection tool → {ids}", has_selection, persp_nudge ), diff --git a/crates/engine/src/cmd/distortcmds/perspective.rs b/crates/engine/src/cmd/distortcmds/perspective.rs index 042f6c8dcc..4b46da1718 100644 --- a/crates/engine/src/cmd/distortcmds/perspective.rs +++ b/crates/engine/src/cmd/distortcmds/perspective.rs @@ -497,6 +497,9 @@ pub(super) fn plane_match(s: &mut Session, p: &Value) -> Result { Ok(json!({ "plane": plane.id(), "offset": depth })) } +/// `perspective.nudge`, the arrow keys with the Perspective Selection tool: the selection moves +/// within its plane by [`nudge_step`](crate::cmd::object::nudge_step), measured on the page at the +/// centre of its perspective box, without Snap to Grid. pub(super) fn persp_nudge(s: &mut Session, p: &Value) -> Result { const C: &str = "perspective.nudge"; let (dx, dy) = (number_or(p, "dx", 0.0, C)?, number_or(p, "dy", 0.0, C)?); @@ -512,7 +515,12 @@ pub(super) fn persp_nudge(s: &mut Session, p: &Value) -> Result { let (plane, depth, rect) = g.plane_bounds(&st.doc, &ids).ok_or_else(|| EngineError::Other("the selection isn't in perspective".into()))?; let from = g.homography_at(plane, depth).and_then(|h| h.apply(rect.center())).ok_or_else(beyond_horizon)?; let to = from + vectorcraft_geom::Vec2::new(dx.clamp(-1.0, 1.0), dy.clamp(-1.0, 1.0)) * k; - persp_move(s, &json!({"ids": ids.iter().map(|i| i.0).collect::>(), "from": [from.x, from.y], "to": [to.x, to.y], "copy": copy})) + // The arrow keys move by the step: Snap to Grid would pull an edge on a gridline back onto it, + // so a nudge smaller than a quarter cell would move nothing. + persp_move( + s, + &json!({"ids": ids.iter().map(|i| i.0).collect::>(), "from": [from.x, from.y], "to": [to.x, to.y], "copy": copy, "snap": false}), + ) } pub(super) fn persp_draw(s: &mut Session, p: &Value) -> Result { diff --git a/crates/engine/src/cmd/object/transform.rs b/crates/engine/src/cmd/object/transform.rs index 2c1cbc3db6..4c686d3fc0 100644 --- a/crates/engine/src/cmd/object/transform.rs +++ b/crates/engine/src/cmd/object/transform.rs @@ -302,6 +302,9 @@ pub(crate) fn nudge_step(increment: f64, big: bool, fine: bool) -> f64 { } } +/// `object.nudge`, the arrow keys: the selected anchors, else the selected objects (and the guides +/// that move with them), else the selected ruler guides move by [`nudge_step`] in the arrow's +/// direction, in one undo step. pub(super) fn nudge(s: &mut Session, p: &Value) -> Result { check_numbers(p, &["dx", "dy"], "object.nudge")?; check_switches(p, &TRANSFORM_SWITCHES, "object.nudge")?; diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index b1f1c2599d..ef231cddd4 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -1396,6 +1396,7 @@ fn a_boolean_given_as_text_for_a_transform_is_an_error() { ("object.move", json!({"dx": 5, "copy": "true"}), "copy"), ("object.move", json!({"dx": 5, "objects": 0}), "objects"), ("object.nudge", json!({"dx": 1, "big": "true"}), "big"), + ("object.nudge", json!({"dx": 1, "fine": "true"}), "fine"), ("object.rotate", json!({"angle": 45, "absolute": "true"}), "absolute"), ("object.scale", json!({"sx": 200, "strokes": "false"}), "strokes"), ("object.scale", json!({"sx": 200, "corners": [true]}), "corners"), diff --git a/crates/engine/src/tests/distort.rs b/crates/engine/src/tests/distort.rs index d033fadee6..a2e1b8df62 100644 --- a/crates/engine/src/tests/distort.rs +++ b/crates/engine/src/tests/distort.rs @@ -796,9 +796,10 @@ fn perspective_grid_commands_refuse_a_boolean_given_as_text() { /// For an object in perspective, Move in Perspective by 0 (along its plane or its normal), /// Transform in Perspective by the identity, Transform Again after each, and a Perspective Selection -/// drag that ends where it started record no undo step. So do a Move by 0 and a 1 pt Nudge that -/// Snap to Grid takes back to the gridlines the object's edges are on, and Transform Again after -/// each. With Copy, the identity copies the object in one undo step. +/// drag that ends where it started record no undo step. So do a Move by 0 of an object Snap to Grid +/// keeps on the gridlines its edges are on, and Transform Again after it. With Copy, the identity +/// copies the object in one undo step. (A Nudge in Perspective isn't snapped: it moves by its step, +/// see `arrow_keys_nudge_in_perspective_by_the_step_with_snap_to_grid`.) #[test] fn perspective_moves_that_move_nothing_record_no_undo_step() { let mut s = session(); @@ -830,8 +831,8 @@ fn perspective_moves_that_move_nothing_record_no_undo_step() { assert_eq!(s.journal.last().unwrap().0, "perspective.move"); let (undo, redo, _) = history(&s); assert_eq!(((undo, redo), path(&s, a)), ((before.0, before.1), shape.clone()), "a drag back to its start"); - // Snap to Grid takes a move that ends 0.3 pt past a gridline crossing onto the crossing. Then it - // takes a move by 0 and a 1 pt nudge back there, and Transform Again after each moves nothing. + // Snap to Grid takes a move that ends 0.3 pt past a gridline crossing onto the crossing. Then a + // move by 0 there, and Transform Again after it, moves nothing. s.execute("perspective.grid.snap", &json!({"on": true})).unwrap(); let g = grid(&s); let (_, _, b) = g.plane_bounds(&s.doc().unwrap().doc, &[a]).unwrap(); @@ -842,12 +843,7 @@ fn perspective_moves_that_move_nothing_record_no_undo_step() { with_a_step_to_redo(&mut s); let before = history(&s); let on_grid = path(&s, a); - let calls = [ - ("perspective.move", json!({"from": [to.x, to.y], "to": [to.x, to.y]})), - ("object.transformAgain", json!({})), - ("perspective.nudge", json!({"dx": 1, "dy": 0})), - ("object.transformAgain", json!({})), - ]; + let calls = [("perspective.move", json!({"from": [to.x, to.y], "to": [to.x, to.y]})), ("object.transformAgain", json!({}))]; for (c, p) in calls { assert_eq!(s.execute(c, &p).unwrap(), json!({"ids": [a.0]}), "{c} {p}"); assert_eq!((history(&s), path(&s, a)), (before, on_grid.clone()), "{c} {p}"); @@ -859,7 +855,7 @@ fn perspective_moves_that_move_nothing_record_no_undo_step() { } /// Move in Perspective refuses a `copy`, `perpendicular` or `snap`, Transform in Perspective a `copy`, -/// and Nudge in Perspective a `big` or `copy`, given as text or as another value that is not true or +/// and Nudge in Perspective a `big`, `fine` or `copy`, given as text or as another value that is not true or /// false: the object stays where it is, nothing is copied, and the undo history stays as it was. Null /// is read as the key left out. #[test] @@ -877,7 +873,7 @@ fn perspective_moves_refuse_a_boolean_given_as_text() { refuses_non_boolean(&mut s, "perspective.move", &json!({"from": from, "to": to, key: v}), key); } refuses_non_boolean(&mut s, "perspective.transform", &json!({"matrix": [1.5, 0, 0, 1.5, 0, 0], "copy": v}), "copy"); - for key in ["big", "copy"] { + for key in ["big", "fine", "copy"] { refuses_non_boolean(&mut s, "perspective.nudge", &json!({"dx": 1, "dy": 0, key: v}), key); } assert_eq!(state(&s), before, "{v}"); @@ -885,7 +881,7 @@ fn perspective_moves_refuse_a_boolean_given_as_text() { let calls = [ ("perspective.move", json!({"from": from, "to": to, "copy": null, "perpendicular": null, "snap": null})), ("perspective.transform", json!({"matrix": [1.5, 0, 0, 1.5, 0, 0], "copy": null})), - ("perspective.nudge", json!({"dx": 1, "dy": 0, "big": null, "copy": null})), + ("perspective.nudge", json!({"dx": 1, "dy": 0, "big": null, "fine": null, "copy": null})), ]; for (i, (c, p)) in calls.into_iter().enumerate() { assert_eq!(s.execute(c, &p).unwrap(), json!({"ids": [a.0]}), "{c} {p}"); diff --git a/crates/engine/src/tests/persp_select.rs b/crates/engine/src/tests/persp_select.rs index 60fd1dcfb0..0131468927 100644 --- a/crates/engine/src/tests/persp_select.rs +++ b/crates/engine/src/tests/persp_select.rs @@ -488,6 +488,41 @@ fn transform_again_repeats_a_perspective_scale_and_copies() { assert!(s.execute("perspective.transform", &json!({"matrix": [1, 0, 0, 1, 0, 0], "depth": f64::MAX})).is_err()); } +/// Snap to Grid (on by default) leaves the arrow keys' step alone: art whose edges are on +/// gridlines moves by the step (a tenth of it with Ctrl/Cmd) in one undo step each, instead of +/// being pulled back onto the gridlines and not moving at all. +#[test] +fn arrow_keys_nudge_in_perspective_by_the_step_with_snap_to_grid() { + let (mut s, id) = persp_session(); + s.execute("perspective.grid.snap", &json!({"on": true})).unwrap(); + // A move that ends 0.3 pt past a gridline crossing snaps the corner onto it. + let g = grid(&s); + let b = bounds_of(&plane_pts(&s, id, Plane::Right, 0.0)); + let past = |v: f64| (v / g.cell).ceil() * g.cell + 0.3 - v; + let (c, dv) = (b.center(), Vec2::new(past(b.x0), past(b.y0))); + let (from, to) = (g.to_page(Plane::Right, c).unwrap(), g.to_page(Plane::Right, c + dv).unwrap()); + s.execute("perspective.move", &json!({"from": [from.x, from.y], "to": [to.x, to.y]})).unwrap(); + let on_grid = bounds_of(&plane_pts(&s, id, Plane::Right, 0.0)); + assert!((on_grid.x0 / g.cell - (on_grid.x0 / g.cell).round()).abs() < 1e-6, "{on_grid:?}"); + // The page step measured at the centre of the selection, as `perspective.nudge` measures it. + let page_step = |s: &Session, before: &[Point]| { + let after = plane_pts(s, id, Plane::Right, 0.0); + let h = grid(s).homography(Plane::Right).unwrap(); + let c = bounds_of(before).center(); + h.apply(c + (after[0] - before[0])).unwrap() - h.apply(c).unwrap() + }; + let v = ViewInfo::default(); + s.select_tool("perspectiveSelection", v).unwrap(); + let k = s.prefs.keyboard_increment; + for (mods, step) in [(Mods::default(), k), (Mods { cmd: true, ..Default::default() }, k / 10.0)] { + let (before, n) = (plane_pts(&s, id, Plane::Right, 0.0), undo_len(&s)); + s.tool_key(ToolKey::Right, mods, v).unwrap(); + assert_eq!(undo_len(&s), n + 1, "{mods:?}"); + let d = page_step(&s, &before); + assert!((d - Vec2::new(step, 0.0)).hypot() < 1e-6, "{mods:?} {d:?}"); + } +} + #[test] fn arrow_keys_nudge_in_perspective() { let (mut s, id) = persp_session(); diff --git a/crates/ui-egui/src/shortcuts/tests.rs b/crates/ui-egui/src/shortcuts/tests.rs index efe9917492..64b5ba15ab 100644 --- a/crates/ui-egui/src/shortcuts/tests.rs +++ b/crates/ui-egui/src/shortcuts/tests.rs @@ -1551,6 +1551,28 @@ fn selected_vertical_area_and_path_type_use_vertical_spacing_chords() { } /// #3786: Alt+arrows step a selected text object's spacing instead of copying and nudging it. +/// #5258: Ctrl/Cmd+arrow nudges the selection by a tenth of the keyboard increment, and +/// Shift+Ctrl/Cmd+arrow by one increment, one undo step each. +#[test] +fn command_arrows_nudge_by_a_tenth_of_the_keyboard_increment() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + app.session.execute("file.new", &json!({"width": 200, "height": 200})).unwrap(); + let id = app.session.execute("shape.rectangle", &json!({"x": 20, "y": 20, "width": 10, "height": 10})).unwrap()["id"].as_u64().unwrap(); + app.select_tool("selection"); + app.session.execute("select.set", &json!({"ids": [id]})).unwrap(); + let x0 = |app: &VectorcraftApp| app.session.active().unwrap().doc.node(vectorcraft_doc::NodeId(id)).unwrap().geometric_bounds().unwrap().x0; + let undo = |app: &VectorcraftApp| app.session.active().unwrap().history.undo.len(); + + let press = |key, modifiers| egui::Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers }; + let shift_command = Modifiers::SHIFT | Modifiers::COMMAND; + let before = undo(&app); + for (m, x, n) in [(Modifiers::COMMAND, 20.1, 1), (shift_command, 21.1, 2), (Modifiers::NONE, 22.1, 3)] { + frame(&mut app, vec![egui::Event::ModifiersChanged(m), press(Key::ArrowRight, m)]); + assert!((x0(&app) - x).abs() < 1e-9, "{m:?}: {}", x0(&app)); + assert_eq!(undo(&app), before + n, "{m:?}"); + } +} + #[test] fn alt_arrows_step_selected_type_object() { let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); diff --git a/docs/mcp.md b/docs/mcp.md index 0ca4e32353..6f523f4b93 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -1142,7 +1142,7 @@ The transform, Align, Object Properties and Live Shape Properties commands refus that is not true or false with `` `strokes` must be true or false ``, naming the key, and leave the document and its undo history as they were: the options `copy`, `strokes`, `corners`, `patterns`, `objects` and `typeAreas` in `object.transform`, `object.move`, `object.nudge`, `object.rotate`, `object.scale`, `object.reflect`, `object.shear`, -`object.transformAgain` and `object.setBounds`; `anchors` and `releaseOutside` in `object.transform`; `big` in `object.nudge`; +`object.transformAgain` and `object.setBounds`; `anchors` and `releaseOutside` in `object.transform`; `big` and `fine` in `object.nudge`; `absolute` in `object.rotate`; `proportional` in `object.setBounds`; `patterns` in `object.align`, `object.distribute` and `object.distributeSpacing`; `visible`, `locked`, `isolate` and `knockoutShape` in `object.setProps`; and `invertPie`, `makeSidesEqual` and `relativeRadii` in `object.setLiveShape`. A null is read as a key left out. @@ -5971,8 +5971,8 @@ back). Holding Shift during an in-plane move constrains each object's displaceme own plane. `perspective.move` accepts `constrain: true` (default false) and adjusts Snap to Grid along the constrained direction on the first object's plane and depth. `press_key` Escape during a move, a resize or a plane widget drag cancels it and puts the objects and the -grid back. The arrow keys nudge a selection in perspective by the keyboard increment (`perspective.nudge`; Shift ×10, Alt -copies). Object › Transform › Transform Again repeats the last perspective move or scale in plane space. +grid back. The arrow keys nudge a selection in perspective by the keyboard increment (`perspective.nudge`; Shift ×10, +Ctrl/Cmd ÷10 (`fine`), Shift+Ctrl/Cmd one increment, Alt copies); Snap to Grid doesn't pull a nudge onto the gridlines. Object › Transform › Transform Again repeats the last perspective move or scale in plane space. ```json {"name":"pointer_gesture","arguments":{"tool":"perspectiveSelection","events":[{"kind":"down","x":480,"y":410},{"kind":"drag","x":470,"y":405}]}} @@ -5984,8 +5984,8 @@ copies). Object › Transform › Transform Again repeats the last perspective m The perspective, width point, Liquify and Puppet Warp commands refuse a string, a number or another value that is not true or false with `` `copy` must be true or false ``, naming the key, and leave the document and its undo history as -they were: `copy`, `perpendicular` and `snap` in `perspective.move`; `copy` in `perspective.transform`; `big` and -`copy` in `perspective.nudge`; `snap` in `perspective.draw`; `reproject` in `perspective.grid.set`; `visible` in +they were: `copy`, `perpendicular` and `snap` in `perspective.move`; `copy` in `perspective.transform`; `big`, `fine` +and `copy` in `perspective.nudge`; `snap` in `perspective.draw`; `reproject` in `perspective.grid.set`; `visible` in `perspective.grid.show`; `adjustAdjoining` in `stroke.widthPoint.set`; `usePressure`, `simplifyOn`, `affectAnchors`, `affectIn` and `affectOut` in `object.liquify`, with any `tool`; and `rest` in `object.puppetWarp`. A null is read as a key left out. diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 7a946e35a1..adfbfe04a9 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -418,7 +418,7 @@ separate. Scores and hours unchanged. [Behavior and command details](development | Date | Change | Summary | |---|---|---| -| 2026-11-02 | minor | Arrow keys: Ctrl/Cmd+arrow nudges art, direct-selected anchors, ruler guides and a selection in perspective by a tenth of the Keyboard Increment, and Shift+Ctrl/Cmd+arrow by one increment; `object.nudge` and `perspective.nudge` take `fine` (#5258); scores and estimates unchanged | +| 2026-11-02 | minor | Arrow keys: Ctrl/Cmd+arrow nudges art, direct-selected anchors, ruler guides and a selection in perspective by a tenth of the Keyboard Increment, and Shift+Ctrl/Cmd+arrow by one increment; `object.nudge` and `perspective.nudge` take `fine`; Snap to Grid no longer pulls a nudge in perspective back onto the gridlines, which left grid-aligned art unmoved (#5258); scores and estimates unchanged | | 2026-11-03 | minor | Enclosing Lasso selects fully enclosed objects with a freehand loop under Object › Plug-ins; scores and estimates unchanged. | | 2026-11-03 | minor | Type on a Path Options has a Preview checkbox (#5360, as public tutorials of the dialog show); scores and estimates unchanged | | 2026-11-02 | minor | Font-family fields in Character, Properties and Control accept the wheel without opening the menu (#5253); scores and estimates unchanged. | From ffe68938cec9d9fc2ff1a585bf46ff78d5e7b600 Mon Sep 17 00:00:00 2001 From: ljkx <177671075+ljkx@users.noreply.github.com> Date: Thu, 12 Nov 2026 11:02:54 +0100 Subject: [PATCH 3/3] Nudge: Ctrl/Cmd+arrow moves Direct Selection's frame anchors and mesh points by a tenth too Direct Selection nudges selected area-type frame anchors and gradient-mesh points itself (ToolContext::arrow_nudge), before object.nudge sees the key, and that step ignored Ctrl/Cmd. nudge_step moves into vectorcraft-tools, the engine re-exports it, and arrow_nudge uses it, so every arrow nudge takes the same step: x10 with Shift, /10 with Ctrl/Cmd, one increment with both. --- crates/engine/src/cmd/object/transform.rs | 12 +----------- crates/tools/src/context.rs | 19 ++++++++++++++++--- crates/tools/src/direct/tests.rs | 5 ++++- crates/tools/src/lib.rs | 2 +- crates/ui-egui/src/shortcuts/tests.rs | 2 +- 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/crates/engine/src/cmd/object/transform.rs b/crates/engine/src/cmd/object/transform.rs index 694946a83a..3d9eb4ef67 100644 --- a/crates/engine/src/cmd/object/transform.rs +++ b/crates/engine/src/cmd/object/transform.rs @@ -301,17 +301,7 @@ pub(crate) fn along_constrain_angle(dx: f64, dy: f64, deg: f64) -> (f64, f64) { (v.x, v.y) } -/// The arrow keys' step: the keyboard increment, ×10 with Shift (`big`) and ÷10 with Ctrl/Cmd -/// (`fine`), so Shift+Ctrl+arrow moves by one increment. Divided, not multiplied by 0.1, so a tenth -/// of a 1 pt increment is the nearest `f64` to 0.1. -pub(crate) fn nudge_step(increment: f64, big: bool, fine: bool) -> f64 { - match (big, fine) { - (true, true) => increment, - (true, false) => increment * 10.0, - (false, true) => increment / 10.0, - (false, false) => increment, - } -} +pub(crate) use vectorcraft_tools::nudge_step; /// `object.nudge`, the arrow keys: the selected anchors, else the selected objects (and the guides /// that move with them), else the selected ruler guides move by [`nudge_step`] in the arrow's diff --git a/crates/tools/src/context.rs b/crates/tools/src/context.rs index 741e962290..fe6bf82ea1 100644 --- a/crates/tools/src/context.rs +++ b/crates/tools/src/context.rs @@ -319,11 +319,12 @@ impl ToolContext<'_> { pub fn star_radii_label(&self, outer: f64, inner: f64) -> String { format!("R1: {}\nR2: {}", self.len(outer), self.len(inner)) } - /// The move an arrow key nudges by: General › Keyboard Increment (ten times with Shift), - /// along General › Constrain Angle's axes; `None` for other keys. + /// The move an arrow key nudges by: General › Keyboard Increment, ten times with Shift and a + /// tenth with Ctrl/Cmd ([`nudge_step`]), along General › Constrain Angle's axes; `None` for + /// other keys. pub fn arrow_nudge(&self, key: crate::ToolKey, mods: crate::Mods) -> Option { use crate::ToolKey; - let step = self.keyboard_increment * if mods.shift { 10.0 } else { 1.0 }; + let step = nudge_step(self.keyboard_increment, mods.shift, mods.cmd); let d = match key { ToolKey::Left => Point::new(-step, 0.0), ToolKey::Right => Point::new(step, 0.0), @@ -380,3 +381,15 @@ impl ToolContext<'_> { vectorcraft_doc::hit::HitOptions { clip_outlines: true, ..self.hit_options() } } } + +/// The arrow keys' step: the keyboard increment, ×10 with Shift (`big`) and ÷10 with Ctrl/Cmd +/// (`fine`), so Shift+Ctrl+arrow moves by one increment. Divided, not multiplied by 0.1, so a tenth +/// of a 1 pt increment is the nearest `f64` to 0.1. +pub fn nudge_step(increment: f64, big: bool, fine: bool) -> f64 { + match (big, fine) { + (true, true) => increment, + (true, false) => increment * 10.0, + (false, true) => increment / 10.0, + (false, false) => increment, + } +} diff --git a/crates/tools/src/direct/tests.rs b/crates/tools/src/direct/tests.rs index 0ac443c731..6cf5f6797e 100644 --- a/crates/tools/src/direct/tests.rs +++ b/crates/tools/src/direct/tests.rs @@ -415,7 +415,8 @@ fn a_marquee_selects_frame_anchors_of_area_type() { assert_eq!(a[0], Action::Begin("Reshape Type Area".into())); assert_eq!(a[1], Action::Preview("text.reshapeArea".into(), json!({"id": text.0, "anchors": [[0, 1], [0, 2]], "dx": 20.0, "dy": 20.0}))); assert_eq!(t.pointer(&cx2, &ev(PointerKind::Up, 440.0, 360.0)), vec![Action::Commit, Action::Notify(FRAME_PICKED.into())]); - // The arrow keys nudge them by the keyboard increment, ten times that with Shift. + // The arrow keys nudge them by the keyboard increment, ten times that with Shift, a tenth with + // Ctrl/Cmd and one increment with both (#5258). let nudged = |anchors: Value, dx: f64, dy: f64| { vec![ Action::Exec("text.reshapeArea".into(), json!({"id": text.0, "anchors": anchors, "dx": dx, "dy": dy})), @@ -425,6 +426,8 @@ fn a_marquee_selects_frame_anchors_of_area_type() { assert!(t.claims_key(&cx2, ToolKey::Right) && !t.claims_key(&cx2, ToolKey::Enter)); assert_eq!(t.key(&cx2, ToolKey::Right, Mods::default()), nudged(json!([[0, 1], [0, 2]]), 1.0, 0.0)); assert_eq!(t.key(&cx2, ToolKey::Up, Mods { shift: true, ..Mods::default() }), nudged(json!([[0, 1], [0, 2]]), 0.0, -10.0)); + assert_eq!(t.key(&cx2, ToolKey::Left, Mods { cmd: true, ..Mods::default() }), nudged(json!([[0, 1], [0, 2]]), -0.1, 0.0)); + assert_eq!(t.key(&cx2, ToolKey::Down, Mods { shift: true, cmd: true, ..Mods::default() }), nudged(json!([[0, 1], [0, 2]]), 0.0, 1.0)); // Any other change of the document or the selection (Deselect, then the same type selected // again) leaves the type selected whole: the arrow keys are no longer the tool's. let mut later = cx(&d, &s, &p); diff --git a/crates/tools/src/lib.rs b/crates/tools/src/lib.rs index c397231495..198c70e27d 100644 --- a/crates/tools/src/lib.rs +++ b/crates/tools/src/lib.rs @@ -57,7 +57,7 @@ mod context; mod cursor; mod input; -pub use context::{GlyphSnap, MarqueeMode, PaintDefaults, ScreenFrame, ToolContext}; +pub use context::{GlyphSnap, MarqueeMode, PaintDefaults, ScreenFrame, ToolContext, nudge_step}; pub use cursor::Cursor; pub use input::{Action, Mods, PenPose, PointerEvent, PointerKind, ToolKey}; diff --git a/crates/ui-egui/src/shortcuts/tests.rs b/crates/ui-egui/src/shortcuts/tests.rs index e66a27b22f..dd7f7fba26 100644 --- a/crates/ui-egui/src/shortcuts/tests.rs +++ b/crates/ui-egui/src/shortcuts/tests.rs @@ -2095,7 +2095,6 @@ fn selected_vertical_area_and_path_type_use_vertical_spacing_chords() { } } -/// #3786: Alt+arrows step a selected text object's spacing instead of copying and nudging it. /// #5258: Ctrl/Cmd+arrow nudges the selection by a tenth of the keyboard increment, and /// Shift+Ctrl/Cmd+arrow by one increment, one undo step each. #[test] @@ -2118,6 +2117,7 @@ fn command_arrows_nudge_by_a_tenth_of_the_keyboard_increment() { } } +/// #3786: Alt+arrows step a selected text object's spacing instead of copying and nudging it. #[test] fn alt_arrows_step_selected_type_object() { let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default());