mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-01 02:35:37 +01:00
Merge pull request #5272 from ljkx/fine-nudge-5258
Nudge: Ctrl/Cmd+arrow moves by a tenth of the keyboard increment (#5258)
This commit is contained in:
18 files changed
+167
-36
No files matched your search
@@ -171,7 +171,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"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 (Snap to Grid doesn't apply), as the arrow keys do with the Perspective Selection tool → {ids}",
|
||||
has_selection,
|
||||
persp_nudge
|
||||
),
|
||||
|
||||
@@ -563,13 +563,16 @@ pub(super) fn plane_match(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
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<Value> {
|
||||
const C: &str = "perspective.nudge";
|
||||
let (dx, dy) = (number_or(p, "dx", 0.0, C)?, number_or(p, "dy", 0.0, C)?);
|
||||
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.
|
||||
@@ -578,7 +581,12 @@ pub(super) fn persp_nudge(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
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::<Vec<_>>(), "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::<Vec<_>>(), "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<Value> {
|
||||
|
||||
@@ -41,5 +41,5 @@ pub(crate) use pixelgrid::{
|
||||
snap_if_aligned, snap_symbol_art,
|
||||
};
|
||||
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};
|
||||
pub use transform::{reflect_axis, scale_factors, shear_tangent};
|
||||
@@ -79,7 +79,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"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), interpolate?: bool (as path.moveAnchors's; default: prefs interpolateControlPoints)} arrow-key nudge by the keyboard increment (the selected anchors (a selected curved segment bends instead: its anchors stay and its handles keep their directions while its middle moves by the step), 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), interpolate?: bool (as path.moveAnchors's; default: prefs interpolateControlPoints)} arrow-key nudge by the keyboard increment (the selected anchors (a selected curved segment bends instead: its anchors stay and its handles keep their directions while its middle moves by the step), 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
|
||||
),
|
||||
|
||||
@@ -438,11 +438,16 @@ pub(crate) fn along_constrain_angle(dx: f64, dy: f64, deg: f64) -> (f64, f64) {
|
||||
(v.x, v.y)
|
||||
}
|
||||
|
||||
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
|
||||
/// direction, in one undo step.
|
||||
pub(super) fn nudge(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
check_numbers(p, &["dx", "dy"], "object.nudge")?;
|
||||
check_switches(p, &TRANSFORM_SWITCHES, "object.nudge")?;
|
||||
check_switches(p, &["big", "interpolate"], "object.nudge")?;
|
||||
let k = s.prefs.keyboard_increment * if bool_or(p, "big", false) { 10.0 } else { 1.0 };
|
||||
check_switches(p, &["big", "fine", "interpolate"], "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);
|
||||
|
||||
@@ -1517,6 +1517,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"),
|
||||
|
||||
@@ -835,9 +835,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();
|
||||
@@ -869,8 +870,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();
|
||||
@@ -881,12 +882,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}");
|
||||
@@ -898,7 +894,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]
|
||||
@@ -916,7 +912,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}");
|
||||
@@ -924,7 +920,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}");
|
||||
|
||||
@@ -561,6 +561,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();
|
||||
@@ -581,6 +616,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();
|
||||
|
||||
@@ -64,6 +64,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.ruler_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();
|
||||
|
||||
@@ -679,6 +679,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})),
|
||||
|
||||
@@ -409,11 +409,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<Vec2> {
|
||||
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),
|
||||
@@ -486,3 +487,15 @@ impl ToolContext<'_> {
|
||||
vectorcraft_doc::hit::HitOptions { clip_outlines: true, unfilled_interiors: 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,
|
||||
}
|
||||
}
|
||||
@@ -681,7 +681,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})),
|
||||
@@ -691,6 +692,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);
|
||||
|
||||
@@ -337,7 +337,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.
|
||||
|
||||
@@ -67,7 +67,7 @@ mod cursor;
|
||||
mod input;
|
||||
mod readout;
|
||||
|
||||
pub use context::{GlyphSnap, MarqueeMode, PaintDefaults, PixelOp, PixelSnap, ScreenFrame, ToolContext, ordinary_isolation};
|
||||
pub use context::{GlyphSnap, MarqueeMode, PaintDefaults, PixelOp, PixelSnap, ScreenFrame, ToolContext, nudge_step, ordinary_isolation};
|
||||
pub use cursor::Cursor;
|
||||
pub use input::{Action, Mods, PenPose, PointerEvent, PointerKind, ToolKey};
|
||||
pub use readout::Readout;
|
||||
|
||||
@@ -225,7 +225,7 @@ fn escape_ends_one_thing(app: &mut VectorcraftApp, ctx: &egui::Context) {
|
||||
|
||||
/// An arrow nudge of the window or of a tool that left it. `direction` points the way of the arrow. In
|
||||
/// Presentation Mode Left and Right step the artboard and nothing moves; with only type selected, Alt steps the
|
||||
/// type's spacing; otherwise the selection moves (Shift ×10, Alt copies, `patterns_only` moves pattern fills only).
|
||||
/// type's spacing; otherwise the selection moves (Shift ×10, Ctrl/Cmd ÷10, Alt copies, `patterns_only` moves pattern fills only).
|
||||
pub(crate) fn nudge(app: &mut VectorcraftApp, direction: egui::Vec2, mods: Mods, patterns_only: bool) {
|
||||
if app.ui.screen_mode == 3 {
|
||||
if direction.x != 0.0 {
|
||||
@@ -249,7 +249,7 @@ pub(crate) fn nudge(app: &mut VectorcraftApp, direction: egui::Vec2, mods: Mods,
|
||||
return;
|
||||
}
|
||||
if app.session.active().is_some_and(|d| d.selection.has_objects_or_guides()) {
|
||||
let mut params = json!({"dx": f64::from(direction.x), "dy": f64::from(direction.y), "big": mods.shift, "copy": mods.alt});
|
||||
let mut params = json!({"dx": f64::from(direction.x), "dy": f64::from(direction.y), "big": mods.shift, "fine": mods.cmd, "copy": mods.alt});
|
||||
if patterns_only {
|
||||
params["objects"] = json!(false);
|
||||
params["patterns"] = json!(true);
|
||||
|
||||
@@ -1172,6 +1172,24 @@ fn selected_vertical_area_and_path_type_use_vertical_spacing_chords() {
|
||||
}
|
||||
}
|
||||
|
||||
/// #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 = new_app();
|
||||
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(NodeId(id)).unwrap().geometric_bounds().unwrap().x0;
|
||||
let ctx = ready(&mut app);
|
||||
let before = undo_len(&app);
|
||||
for (m, x, n) in [(cmd(), 20.1, 1), (cmd() | Modifiers::SHIFT, 21.1, 2), (Modifiers::NONE, 22.1, 3)] {
|
||||
key_frame(&mut app, &ctx, tap(Key::ArrowRight, m));
|
||||
assert!((x0(&app) - x).abs() < 1e-9, "{m:?}: {}", x0(&app));
|
||||
assert_eq!(undo_len(&app), before + n, "{m:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Alt+arrows step a selected type object instead of copying it; a rectangle with Alt is copied.
|
||||
#[test]
|
||||
fn alt_arrows_step_selected_type_object() {
|
||||
|
||||
+5
-5
@@ -2524,7 +2524,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`, `releaseOutside` and `drawBehind` in `object.transform`; `big` in `object.nudge`;
|
||||
`object.transformAgain` and `object.setBounds`; `anchors`, `releaseOutside` and `drawBehind` 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`, `relativeRadii`, `strokes` and `patterns` in `object.setLiveShape`. A null is read as a
|
||||
@@ -16161,8 +16161,8 @@ edge also lands only when it ends within a quarter cell of a gridline: a horizon
|
||||
edge on its own axis, and a 45° move lands the edge on the axis whose nonzero correction is smaller. When no edge on
|
||||
those axes is that close, the move does not snap. A perpendicular move does not snap.
|
||||
`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}]}}
|
||||
@@ -16174,8 +16174,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.
|
||||
|
||||
+3
-2
@@ -1,7 +1,7 @@
|
||||
# UI and interaction parity
|
||||
|
||||
> Status-bar snapping quick access (#8687, #8779): the bottom right offers Smart Guides, Snap to Point and Snap to Grid toggles plus the same live Snapping menu as the Control bar. Both use existing commands. Framework fit ranks omit the direct group first, then the dropdown, before the existing readouts or core status content narrow. The native buttons expose their current selected state. Scores and estimates are unchanged.
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-29 · **Change:** minor (Smart Guides: in a document with more than 20,000 anchors, the snap targets are gathered topmost first, so the objects in front, the newest, keep their anchors, edges and centre as targets for ruler guides, moves, scaling and drawing (#8531); scores and estimates unchanged; previously: 3D effect options: unchanged values preserve the document and add no Undo; scores and estimates unchanged); previously: minor (G12: History row menus adapted to shared Craft list/menu controls after rebase (#8845); scores and estimates unchanged; previously: G12/M14: History row context menus, pending-edit snapshot targeting, keyboard access and document-switch dismissal (#8845); scores and estimates unchanged; previously: Pencil Edit Selected Paths follows lifted strokes, carves, loops, closes and redraws compound paths; Layers: a targeted item with an appearance of its own keeps its inner ring visible around a smaller appearance dot, so the target circle's four looks differ, #8711; scores and estimates unchanged; previously: G12: Asset Export tile context menus; scores and estimates unchanged; previously: Properties panel per context (G12): contextual text Quick Actions (Create Outlines, Retype, Find and Replace…); scores and estimates unchanged; previously: Layers: a targeted item with an appearance of its own keeps its inner ring visible around a smaller appearance dot, so the target circle's four looks differ, #8711; scores and estimates unchanged; previously: Trim View hides the ruler guides, guide paths and the grid while it is on and greys out Show/Hide Guides and Show/Hide Grid, #8363; scores and estimates unchanged; previously: Scissors shows the actual proposed cut point while hovering, using its existing snapping and cut target (#8655); scores and estimates unchanged; previously: Graphic Styles panel: right-click item context menu for tiles and rows with Options, Duplicate, Delete, Redefine, Break Link; scores and estimates unchanged; previously: Artboard tool: Shift held once a move or Alt-copy drag is under way keeps it to the level, upright or 45° line, #8580; scores and estimates unchanged; previously: Image Trace Ignore Color keeps the canvas View and stays armed on a missed pixel (#8068); Canvas context menu: a right-click on a path offers Simplify… next to Smooth…, opening the Simplify slider, or the Simplify dialog kept for next time, as Object › Path › Simplify… does, #8344; scores and estimates unchanged; previously: a tool drag held near an edge of the canvas scrolls the view, #8551; scores and estimates unchanged; previously: G12: Place: show progress window with Cancel for slow placed files exceeding 0.4 s, part of #5930; scores and estimates unchanged; previously: All Tools drawer: a tool the toolbar holds is dimmed in the readable dim text colour, not the disabled colour that was unreadable against the panel, and a hovered dimmed row takes the panel's darker fill so it stays readable, #8294; scores and estimates unchanged; previously: : selected guide rows stay highlighted after the pointer leaves (#7344); scores and estimates unchanged; previously: Layersselected Dimension extension-line color and weight in Properties (#7078; four focused UI regressions passed); scores and estimates unchanged; previously: Brush Options Key Color: restore canvas input for the existing one-shot pick, then resume the retained draft and previous tool (#8284; six full-app input regressions passed); scores and estimates unchanged; previously: Ellipse: Up/Down changes Anchors while drawing (#7840); scores and estimates unchanged; previously: Windows/Linux menu access keys and localized cues (#6596); previously: Backquote/~ arrow pattern nudges (#7717); scores and estimates unchanged; previously: Window > Toolbars > Compact Tools offers optional denser main Tools spacing (#7234); default layout, scores and estimates unchanged; previously: Direct Selection: Space during an ordinary path's handle drag repositions its anchor and handles, including a Pen loan (#7237, request 3 only; scores and estimates unchanged); previously: Floating panels keep their window level while focus moves between the app's windows, so a press on one panel's bar no longer hands the keyboard to another, #6986; scores and estimates unchanged; previously minor: Lock Guides: a selection marquee (Selection, Direct Selection, Group Selection, Enclosing Lasso) leaves out paths made into guides inside groups and compound paths too, as clicks do (#3074), so a group is no longer selected by a locked guide in it; an enclosing marquee measures a group without its locked or hidden guides, and Direct Selection takes no anchor or segment of a guide that can't be picked; a guide in a group still moves with its group (#8538); scores and estimates unchanged; previously: Production Preflight: output-aware fonts, text overflow, linked files and effective image resolutionLine truncated
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-29 · **Change:** minor (Ctrl/Cmd+arrow fine nudge, #5258; scores and estimates unchanged; previously: Smart Guides: in a document with more than 20,000 anchors, the snap targets are gathered topmost first, so the objects in front, the newest, keep their anchors, edges and centre as targets for ruler guides, moves, scaling and drawing (#8531); scores and estimates unchanged; previously: 3D effect options: unchanged values preserve the document and add no Undo; scores and estimates unchanged); previously: minor (G12: History row menus adapted to shared Craft list/menu controls after rebase (#8845); scores and estimates unchanged; previously: G12/M14: History row context menus, pending-edit snapshot targeting, keyboard access and document-switch dismissal (#8845); scores and estimates unchanged; previously: Pencil Edit Selected Paths follows lifted strokes, carves, loops, closes and redraws compound paths; Layers: a targeted item with an appearance of its own keeps its inner ring visible around a smaller appearance dot, so the target circle's four looks differ, #8711; scores and estimates unchanged; previously: G12: Asset Export tile context menus; scores and estimates unchanged; previously: Properties panel per context (G12): contextual text Quick Actions (Create Outlines, Retype, Find and Replace…); scores and estimates unchanged; previously: Layers: a targeted item with an appearance of its own keeps its inner ring visible around a smaller appearance dot, so the target circle's four looks differ, #8711; scores and estimates unchanged; previously: Trim View hides the ruler guides, guide paths and the grid while it is on and greys out Show/Hide Guides and Show/Hide Grid, #8363; scores and estimates unchanged; previously: Scissors shows the actual proposed cut point while hovering, using its existing snapping and cut target (#8655); scores and estimates unchanged; previously: Graphic Styles panel: right-click item context menu for tiles and rows with Options, Duplicate, Delete, Redefine, Break Link; scores and estimates unchanged; previously: Artboard tool: Shift held once a move or Alt-copy drag is under way keeps it to the level, upright or 45° line, #8580; scores and estimates unchanged; previously: Image Trace Ignore Color keeps the canvas View and stays armed on a missed pixel (#8068); Canvas context menu: a right-click on a path offers Simplify… next to Smooth…, opening the Simplify slider, or the Simplify dialog kept for next time, as Object › Path › Simplify… does, #8344; scores and estimates unchanged; previously: a tool drag held near an edge of the canvas scrolls the view, #8551; scores and estimates unchanged; previously: G12: Place: show progress window with Cancel for slow placed files exceeding 0.4 s, part of #5930; scores and estimates unchanged; previously: All Tools drawer: a tool the toolbar holds is dimmed in the readable dim text colour, not the disabled colour that was unreadable against the panel, and a hovered dimmed row takes the panel's darker fill so it stays readable, #8294; scores and estimates unchanged; previously: : selected guide rows stay highlighted after the pointer leaves (#7344); scores and estimates unchanged; previously: Layersselected Dimension extension-line color and weight in Properties (#7078; four focused UI regressions passed); scores and estimates unchanged; previously: Brush Options Key Color: restore canvas input for the existing one-shot pick, then resume the retained draft and previous tool (#8284; six full-app input regressions passed); scores and estimates unchanged; previously: Ellipse: Up/Down changes Anchors while drawing (#7840); scores and estimates unchanged; previously: Windows/Linux menu access keys and localized cues (#6596); previously: Backquote/~ arrow pattern nudges (#7717); scores and estimates unchanged; previously: Window > Toolbars > Compact Tools offers optional denser main Tools spacing (#7234); default layout, scores and estimates unchanged; previously: Direct Selection: Space during an ordinary path's handle drag repositions its anchor and handles, including a Pen loan (#7237, request 3 only; scores and estimates unchanged); previously: Floating panels keep their window level while focus moves between the app's windows, so a press on one panel's bar no longer hands the keyboard to another, #6986; scores and estimates unchanged; previously minor: Lock Guides: a selection marquee (Selection, Direct Selection, Group Selection, Enclosing Lasso) leaves out paths made into guides inside groups and compound paths too, as clicks do (#3074), so a group is no longer selected by a locked guide in it; an enclosing marquee measures a group without its locked or hidden guides, and Direct Selection takes no anchor or segment of a guide that can't be picked; a guide in a group still moves with its group (#8538); scores and estimates unchanged; previously: Production Preflight: Line truncated
|
||||
|
||||
> Panel readout copy (#8432, #8826): Info values and paint names, Links information, and named Document Info rows with no separate value follow the guarded immediate-copy policy landed in #9353. A plain first click copies the full value and reports "Copied the value"; accessible activation copies it too. Selectable readouts retain word selection on double-click, Shift/drag selection and keyboard Copy/Cut. Links Location retains #9521's path fitting and full-path tooltip as static text, with the same full-value primary/accessible copy and a native Copy Location button for keyboard use. Scores and estimates are unchanged.
|
||||
>
|
||||
@@ -352,7 +352,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. The field takes the wheel only when the pointer was moved onto it after the field last moved or was covered by a window or overlay, and the wheel stream began there; a stream that began elsewhere stays there until 0.5 s pass with no wheel input. This rule and its 0.5 s are VectorCraft's choices. 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 hovered field without a click; 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. The field takes the wheel only when the pointer was moved onto it after the field last moved or was covered by a window or overlay, and the wheel stream began there; a stream that began elsewhere stays there until 0.5 s pass with no wheel input or the pointer is pressed on a field, so a panel scrolled under a still pointer keeps scrolling past the field. This rule and its 0.5 s are VectorCraft's choices. |
|
||||
| Numeric spinner arrows step once on a click and keep repeating while held with the mouse | done | #6307; headless test `a_held_spinner_arrow_repeats` holds past egui's click timeout and checks release. |
|
||||
@@ -722,6 +722,7 @@ before release (#6373). [Paint faces and edges](https://helpx.adobe.com/illustra
|
||||
| 2026-11-10 | minor | Held numeric spinner arrows keep stepping past the click timeout and stop on release (#6307). Scores and estimates unchanged. |
|
||||
| 2026-11-10 | minor | Vector Halftone Preview leaves the dots unobscured and keeps the selection box (#6369). Scores and estimates unchanged. |
|
||||
| 2026-11-09 | minor | Interim macOS canvas cursor delivery (#2292): existing artwork in aligned 1×/2× AppKit representations, visible system fallback and host-owned restoration. Headless routing, bitmap and ownership coverage; native timing, menus, focus/handback, mixed displays, Spotlight and full-screen Spaces remain unverified. Scores and estimates unchanged. |
|
||||
| 2026-11-09 | 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-09 | minor | Numeric fields step on wheel hover without taking focus; keyboard focus and existing rounding rules remain (#5949). Scores and estimates unchanged. |
|
||||
| 2026-11-08 | minor | Floating tab groups collapse into the side icon rail and opened rail panels fold back into it (#5925, in part); tab groups remain intact. Scores and estimates unchanged. |
|
||||
| 2026-11-07 | minor | Pen and Curvature tool with Cmd/Ctrl held: Edit › Copy and Cut take the anchors and segments the lent Direct Selection picked, as with Direct Selection chosen, not the whole path; with the Pen's own last anchor selected Copy still takes the whole path (#6123); scores and estimates unchanged |
|
||||
|
||||
Reference in new issue
Block a user