From b6fdf59eb9e4b34abe423e6ccccf7041456661c3 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 18 Nov 2026 14:50:33 -0800 Subject: [PATCH] Fix #8568: Shift moves check an artboard guide's reach as before A diagonal Shift move that slides onto a ruler guide again checks an artboard guide's run where the move put the bounds, not where the slide would put them, so the guides a Shift move reaches are the same as on main. A selection held by its edge still checks where the slide puts the bounds. A test covers a diagonal Shift move whose middle is beyond an artboard guide's end. The Drawing aids line now names the Selection tool for edge holds and says the slide does not go past the path's ends. --- crates/tools/src/guides/targets.rs | 9 ++++++--- crates/tools/src/select/tests.rs | 17 +++++++++++++++++ docs/target-app-parity.md | 2 +- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/crates/tools/src/guides/targets.rs b/crates/tools/src/guides/targets.rs index c162b1a899..6022ab68fb 100644 --- a/crates/tools/src/guides/targets.rs +++ b/crates/tools/src/guides/targets.rs @@ -1533,15 +1533,18 @@ impl Targets { continue; } let vs = if vertical { [r.x0, r.center().x, r.x1] } else { [r.y0, r.center().y, r.y1] }; - let half = if vertical { r.height() / 2.0 } else { r.width() / 2.0 }; + let (mid, half) = + if vertical { (Point::new(0.0, r.center().y), r.height() / 2.0) } else { (Point::new(r.center().x, 0.0), r.width() / 2.0) }; for g in self.rulers.iter().filter(|g| g.vertical == vertical) { for v in vs { let s = (g.pos - v) / c; if (g.pos - v).abs() > tol || s.abs() > 2.0 * tol || !(lo..=hi).contains(&s) || best.is_some_and(|b| s.abs() >= b.0.abs()) { continue; } - // The guide runs past the bounds where the slide puts them. - if let Some((t, from, _)) = g.line_at(r.center() + u * s, tol + half) { + // The guide runs past the bounds: for a slide held to `within`, where the slide + // puts them; for a Shift move, where the move put them. + let at = if lo.is_finite() || hi.is_finite() { r.center() + u * s } else { mid }; + if let Some((t, from, _)) = g.line_at(at, tol + half) { best = Some((s, t, from, vertical)); } } diff --git a/crates/tools/src/select/tests.rs b/crates/tools/src/select/tests.rs index 5ad467a88d..82588992b7 100644 --- a/crates/tools/src/select/tests.rs +++ b/crates/tools/src/select/tests.rs @@ -1151,6 +1151,23 @@ fn a_shift_move_lands_the_edges_on_a_ruler_guide() { assert!(moved_by(m, (231.0, 0.0)), "{m:?}"); } +/// #4312: a diagonal Shift move reaches an artboard guide only where the move puts the bounds +/// within the guide's run: the middle at x 556 is beyond the guide's end at 500 by more than half +/// the width and the Snapping Tolerance, so the top (506) does not slide onto the guide at 503. +#[test] +fn a_diagonal_shift_move_reaches_an_artboard_guide_where_the_move_puts_it() { + let (mut d, id) = doc_with_rect(); + d.artboards[0].rect = Rect::new(0.0, 0.0, 500.0, 1600.0); + let board = d.artboards[0].id; + d.add_ruler_guide(&vectorcraft_doc::Guide { artboard: Some(board), ..vectorcraft_doc::Guide::new(false, 503.0) }); + let mut s = Selection::default(); + s.add(id); + let p = paint(); + let c = cx(&d, &s, &p); + let (m, _) = shift_moved(&c, (556.0, 556.0)); + assert!(moved_by(m, (406.0, 406.0)), "{m:?}"); +} + /// With Smart Guides on, a moved selection reaches a ruler guide within the Snapping Tolerance /// (4 px), as drawing and handle drags do; with Smart Guides off, Snap to Point reaches it within /// its own distance (2 px). diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index e3e55ff8e7..512a7a4ddc 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1506,7 +1506,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur When more than 8 of its ids name objects in the document (after the list is cut to 100,000), `layer.highlight` in each mode (`set`, `add` and `toggle`) looks each row up in a set of the highlighted rows instead of searching the highlighted rows once for each row; with 8 or fewer it searches them. The Layers panel's preview of a Shift-click or Shift+Ctrl/Cmd-click range, before it sends the command, always looks the rows up in a set. The work grows in step with the number of rows. The rows, their order, the returned rows and the current layer are the same as before. Tests: `tests::layers::layer_highlight_matches_a_search_of_the_rows_for_each_id`, `tests::layers::highlighting_rows_keeps_their_order_with_repeated_unknown_and_excess_ids` and `widgets::drag::row_click_tests::a_large_range_applies_as_a_search_of_the_rows_for_each_id_does`; timing: `cargo test --release -p vectorcraft-engine --lib layer_highlight_timing -- --ignored --nocapture`. With Panel Options › Show Layers Only on, Locate Object is named Locate Layer and highlights the layer that holds the selected object instead of the object's own row, which that mode does not list (help page: https://helpx.adobe.com/illustrator/desktop/manage-layers/create-and-organize-layers/locate-objects-in-the-layers-panel.html). As VectorCraft's own rules, the bottom bar's button and a row's menu are renamed too, the innermost sublayer holding the object is the one highlighted, a layer row locates itself, and the panel opens the layers around it. Locate Object or Locate Layer run again on the row it already highlighted opens the layers around that row again and scrolls to it, VectorCraft's own rule (`locate_layer_highlights_the_layer_holding_the_object` in `crates/engine/src/tests/layers.rs`, `with_show_layers_only_locate_object_becomes_locate_layer` and `a_repeated_locate_reveals_the_row_it_already_highlighted` in `crates/ui-egui/src/panels/layers/tests.rs`). With several objects selected, Locate Object (and Locate Layer) finds the one frontmost in the stacking order, not the one selected last (help page: https://helpx.adobe.com/illustrator/desktop/manage-layers/create-and-organize-layers/locate-objects-in-the-layers-panel.html). Objects on different layers and sublayers are compared by the layers' order. As VectorCraft's own rules, a member selected along with its group counts as in front of the group, and an `id` given to `layer.locate` still wins (`locate_object_finds_the_frontmost_selected_object` in `crates/engine/src/tests/layers.rs`). -- **Drawing aids:** Smart Guides and snapping (moving, with the Selection, Group Selection or Direct Selection tool, and resizing by the bounding-box handles with the Selection or Free Transform tool, Shift and Alt too: the dragged corner or side lands on the other objects' anchors and centres ("anchor", "center") or lines up with their edges and centres (a line and "align"); with Smart Guides › Spacing Guides, a moved selection that lines up with nothing along an axis lands as far from its neighbour as two other objects of its row or column are apart, or halfway between its two neighbours, the equal gaps marked; with View › Snap to Grid on, a moved selection lands on the grid instead, by whichever of its edges is nearest a gridline on each axis (the center does not snap), #740, #1816; the Rotate, Scale, Shear and Reflect tools drag from the anchor they grab and snap the pointer the same way, so a corner dragged onto another object's anchor scales exactly onto it, #482; anchors dragged with Direct Selection: the one pressed on lands on other anchors, its own path's that stay put among them, on path segments or in line with them, the others following, Shift keeps 45° steps, and with Smart Guides off Snap to Point pulls it onto anchors; the Artboard tool snaps artboards, and their bleed, to other artboards, bleeds and art, the grid or whole pixels while moving, copying and resizing them, and the Transform panel shows and edits the active artboard's X/Y/W/H; drawn points, #506: hovering shows where the press goes, the point lands on the other objects' anchors, centres and paths ("anchor", "center", "path") or lines up with their anchors, edges and centres ("align"), the Pen's on the path being drawn too, near a construction guide through the anchor before it on that guide (Preferences › Smart Guides › Construction Guides and Angles), and with Shift kept to its 45° step or a square's diagonal it slides along that way into line; the targets are gathered once per document state, from the art in the window, and the anchors, centres and lines near the pointer are found by bisection, so hovering never rescans the document), guides dragged out of the rulers (#451: they snap as moved guides do, Shift to the ruler's ticks; with the Artboard tool they are artboard guides, which run across their artboard only and move, copy and delete with it, `guide.add {artboard}`) that the Selection, Direct Selection and Group Selection tools then pick and drag (#414: the selected guides highlight and move together, Alt copies them, Shift snaps the dragged one to the ticks, otherwise it snaps to pixels, the grid or the edges, centres (so the sides' midpoints) and anchors of the art and the artboards, or with Smart Guides off Snap to Point pulls it onto anchors; Shift-clicked they join the selected art, and Shift-added art keeps them, so guides and art are selected together in either order, Delete then deleting both in one step; the arrow keys nudge them, Delete deletes them, dragging one back onto its ruler deletes it, Lock Guides and Hide Guides leave them alone; `guide.list`, `guide.select`, `guide.move` and `guide.remove` reach agents), a right-click on either ruler or the origin box to pick the document's units (the current one checked; `document.setUnits`, one undo step, #528), and Draw Normal / Behind / Inside modes. Smart Guides: a point drawn with the Pen or a shape tool, and an anchor dragged with Direct Selection, snaps to where paths and ruler guides cross, labelled "intersect" (#1658, part of #1602; a moved selection's own anchors don't, except the anchor the Selection tool grabbed it by). A selection the Selection tool grabs by one of its anchors snaps that anchor onto the other objects' paths ("path"), and where a path crosses another path or a ruler guide ("intersect"), in the order Direct Selection uses for a dragged anchor; when the anchor lands on a path, the selection's bounds do not also line up with other objects (#7411). A selection held by a point of a path's edge (a press on its stroke or, in Outline view, its outline, or on its fill within 6 screen points of the edge) snaps that point the same way, except that on a straight path the selection then slides along that path, the point staying on it, until its bounds line up with other objects, are spaced evenly with them or line up with a ruler guide, at most twice the Snapping Tolerance (#8568). The archived 2007 [user guide](https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf#page=55) (page 49) says Smart Guides align the pointer of a moved object to existing paths. Snapping onto paths only when the selection was grabbed by an anchor or held by its edge, and the slide along a straight path, are VectorCraft's own rules; a selection grabbed anywhere else still lines its bounds up. Tests: `select::tests::a_move_grabbed_by_an_anchor_lands_it_on_another_path`, `a_move_grabbed_by_an_anchor_lands_it_where_paths_cross`, `a_move_grabbed_by_an_anchor_lands_it_where_a_path_crosses_a_ruler_guide`, `a_move_held_by_a_paths_edge_lands_it_on_another_path`, `a_move_held_by_an_edge_on_a_straight_path_still_lines_its_bounds_up_along_it`, `a_move_held_by_an_edge_slides_only_within_the_path`, `a_move_held_by_an_edge_slides_along_a_straight_path_with_handles`, `a_move_held_by_an_edge_slides_onto_an_artboard_guide_it_reaches`, `a_move_held_by_an_edge_lands_it_where_paths_cross` and `a_copy_held_by_an_edge_slides_along_the_originals_edge`. With Smart Guides › Measurement Labels on, the Line Segment tool labels the segment being drawn with its distance, angle and X and Y offsets (`D`, `Angle`, `dX`, `dY`), and the Pen, Curvature and Smart Pen tools label their rubber band the same way when Enable Rubber Band is on (#2983). +- **Drawing aids:** Smart Guides and snapping (moving, with the Selection, Group Selection or Direct Selection tool, and resizing by the bounding-box handles with the Selection or Free Transform tool, Shift and Alt too: the dragged corner or side lands on the other objects' anchors and centres ("anchor", "center") or lines up with their edges and centres (a line and "align"); with Smart Guides › Spacing Guides, a moved selection that lines up with nothing along an axis lands as far from its neighbour as two other objects of its row or column are apart, or halfway between its two neighbours, the equal gaps marked; with View › Snap to Grid on, a moved selection lands on the grid instead, by whichever of its edges is nearest a gridline on each axis (the center does not snap), #740, #1816; the Rotate, Scale, Shear and Reflect tools drag from the anchor they grab and snap the pointer the same way, so a corner dragged onto another object's anchor scales exactly onto it, #482; anchors dragged with Direct Selection: the one pressed on lands on other anchors, its own path's that stay put among them, on path segments or in line with them, the others following, Shift keeps 45° steps, and with Smart Guides off Snap to Point pulls it onto anchors; the Artboard tool snaps artboards, and their bleed, to other artboards, bleeds and art, the grid or whole pixels while moving, copying and resizing them, and the Transform panel shows and edits the active artboard's X/Y/W/H; drawn points, #506: hovering shows where the press goes, the point lands on the other objects' anchors, centres and paths ("anchor", "center", "path") or lines up with their anchors, edges and centres ("align"), the Pen's on the path being drawn too, near a construction guide through the anchor before it on that guide (Preferences › Smart Guides › Construction Guides and Angles), and with Shift kept to its 45° step or a square's diagonal it slides along that way into line; the targets are gathered once per document state, from the art in the window, and the anchors, centres and lines near the pointer are found by bisection, so hovering never rescans the document), guides dragged out of the rulers (#451: they snap as moved guides do, Shift to the ruler's ticks; with the Artboard tool they are artboard guides, which run across their artboard only and move, copy and delete with it, `guide.add {artboard}`) that the Selection, Direct Selection and Group Selection tools then pick and drag (#414: the selected guides highlight and move together, Alt copies them, Shift snaps the dragged one to the ticks, otherwise it snaps to pixels, the grid or the edges, centres (so the sides' midpoints) and anchors of the art and the artboards, or with Smart Guides off Snap to Point pulls it onto anchors; Shift-clicked they join the selected art, and Shift-added art keeps them, so guides and art are selected together in either order, Delete then deleting both in one step; the arrow keys nudge them, Delete deletes them, dragging one back onto its ruler deletes it, Lock Guides and Hide Guides leave them alone; `guide.list`, `guide.select`, `guide.move` and `guide.remove` reach agents), a right-click on either ruler or the origin box to pick the document's units (the current one checked; `document.setUnits`, one undo step, #528), and Draw Normal / Behind / Inside modes. Smart Guides: a point drawn with the Pen or a shape tool, and an anchor dragged with Direct Selection, snaps to where paths and ruler guides cross, labelled "intersect" (#1658, part of #1602; a moved selection's own anchors don't, except the anchor the Selection tool grabbed it by). A selection the Selection tool grabs by one of its anchors snaps that anchor onto the other objects' paths ("path"), and where a path crosses another path or a ruler guide ("intersect"), in the order Direct Selection uses for a dragged anchor; when the anchor lands on a path, the selection's bounds do not also line up with other objects (#7411). A selection the Selection tool holds by a point of a path's edge (a press on its stroke or, in Outline view, its outline, or on its fill within 6 screen points of the edge) snaps that point the same way, except that on a straight path the selection then slides along that path, the point staying on it, until its bounds line up with other objects, are spaced evenly with them or line up with a ruler guide, at most twice the Snapping Tolerance and not past the path's ends (#8568). The archived 2007 [user guide](https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf#page=55) (page 49) says Smart Guides align the pointer of a moved object to existing paths. Snapping onto paths only when the selection was grabbed by an anchor or held by its edge, and the slide along a straight path, are VectorCraft's own rules; a selection grabbed anywhere else still lines its bounds up. Tests: `select::tests::a_move_grabbed_by_an_anchor_lands_it_on_another_path`, `a_move_grabbed_by_an_anchor_lands_it_where_paths_cross`, `a_move_grabbed_by_an_anchor_lands_it_where_a_path_crosses_a_ruler_guide`, `a_move_held_by_a_paths_edge_lands_it_on_another_path`, `a_move_held_by_an_edge_on_a_straight_path_still_lines_its_bounds_up_along_it`, `a_move_held_by_an_edge_slides_only_within_the_path`, `a_move_held_by_an_edge_slides_along_a_straight_path_with_handles`, `a_move_held_by_an_edge_slides_onto_an_artboard_guide_it_reaches`, `a_move_held_by_an_edge_lands_it_where_paths_cross` and `a_copy_held_by_an_edge_slides_along_the_originals_edge`. With Smart Guides › Measurement Labels on, the Line Segment tool labels the segment being drawn with its distance, angle and X and Y offsets (`D`, `Angle`, `dX`, `dY`), and the Pen, Curvature and Smart Pen tools label their rubber band the same way when Enable Rubber Band is on (#2983). A move that Shift keeps level, upright or diagonal stays on that line when it snaps, with the Selection, Group Selection or Direct Selection tool. It slides along the line until the selection lands on the grid or on whole pixels, lines up with the other objects or is spaced evenly with them, or until the line passes an anchor or crosses a ruler guide near the point the selection was grabbed by. A level or upright move snaps along its own axis only. Snap to Last Location: with Smart Guides on and Preferences › Smart Guides › Snap to Last Location on (off by default, VectorCraft's own choice), a selection moved by dragging with the Selection, Group Selection or Direct Selection tool, Shift too, goes back to where the move began while it is within Snapping Tolerance of it, labeled "last location"; an Alt copy is not pulled back onto its original, and with View › Snap to Grid or Snap to Pixel on the move snaps to the grid or to whole pixels instead (`prefs.set` key `snapToLastLocation`). The public [Smart Guides options](https://helpx.adobe.com/illustrator/desktop/measure-and-align/grids-and-guides/smart-guides-options.html) page lists the option as snapping objects back to their previous position; the distance, the label, the copy rule and the grid and pixel rule are VectorCraft's own. Tests: `select::tests::snap_to_last_location_puts_a_move_back_where_it_began`, `select::tests::snap_to_pixel_wins_over_snap_to_last_location`, `direct::tests::snap_to_last_location_puts_a_path_moved_by_its_anchor_back`, `direct::tests::snap_to_pixel_wins_over_snap_to_last_location_for_a_path_moved_by_its_anchor`, `tests_prefs::snap_to_last_location_puts_a_dragged_square_back`. Pixel Preview: with View › Pixel Preview on, the tools use no Smart Guides. Nothing snaps to Smart Guides or shows their guides, and Snap to Point acts as it does with Smart Guides off. View › Smart Guides keeps its setting and applies again when Pixel Preview is turned off. [Work with Smart Guides](https://helpx.adobe.com/illustrator/desktop/measure-and-align/grids-and-guides/work-with-smart-guides.html) says Smart Guides cannot be used while Pixel Preview is on. Tests: `tests::smartguides::pixel_preview_turns_smart_guides_off`, `canvas::tests::pixel_preview_stops_smart_guides_snapping_a_move`.