M1: the drag-from-inside fallback tests the selection's turned box (#910)

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Muamer Mustafic
2026-10-22 00:19:13 +02:00
co-authored by Cursor
parent 795567f016
commit 84b48bc797
2 changed files with 14 additions and 1 deletions
@@ -352,6 +352,19 @@ fn a_drag_inside_the_selection_box_moves_it_where_nothing_is_hit() {
assert!(s.undo().unwrap(), "{why}: one undo step");
}
}
// A turned layer's box is turned with it: the corners of its page-aligned bounds are outside.
ex(&mut s, "node.set", json!({"ids": [k.r], "props": {"rotation": 45}}));
let b = s.doc().unwrap().world_bounds(k.r).unwrap();
ex(&mut s, "select.set", json!({"ids": [k.r]}));
drag(&mut s, (b.x0 + 2.0, b.y0 + 2.0), (b.x0 + 12.0, b.y0 + 12.0), NONE);
assert_eq!(at(&s, k.r), b.origin(), "a press outside a turned layer's box is a marquee: it doesn't move the layer");
ex(&mut s, "select.set", json!({"ids": [k.r]}));
let c = b.center();
drag(&mut s, (c.x, c.y), (c.x + 10.0, c.y + 10.0), NONE);
assert_eq!(s.selection(), vec![k.r], "inside the turned box it drags");
// Pixel snapping rounds the turned box's origin, so the move is about the pointer's.
let d = at(&s, k.r) - b.origin();
assert!((d.x - 10.0).abs() < 2.0 && (d.y - 10.0).abs() < 2.0, "it moves with the pointer: {d:?}");
}
#[test]
+1 -1
View File
@@ -1201,7 +1201,7 @@ impl Session {
// inside, or the frame or canvas behind it) drags the selection.
let behind_sel = |t: Option<NodeId>| t.is_none_or(|t| sel.iter().any(|s| *s != t && doc.is_ancestor(t, *s)));
let target = match sel.iter().copied().find(|s| !locked_in(&doc, *s)) {
Some(first) if label.is_none() && !ev.shift && behind_sel(target) && doc.bounds_of(&sel).is_some_and(|b| b.contains(ev.p())) => {
Some(first) if label.is_none() && !ev.shift && behind_sel(target) && selection_box(&doc, &sel).is_some_and(|q| in_quad(&q, ev.p())) => {
Some(first)
}
_ => target,