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.
This commit is contained in:
dotCooCoo
2026-11-18 14:50:33 -08:00
parent cb3d274550
commit b6fdf59eb9
3 changed files with 24 additions and 4 deletions
+6 -3
View File
@@ -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));
}
}
+17
View File
@@ -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).
File diff suppressed because one or more lines are too long