prioritize bounding-box handles over mirror axis

This commit is contained in:
AJ Richardson
2026-10-18 19:02:44 +07:00
committed by bflatastic
parent 63cebd392a
commit 411f5f7680
7 changed files with 52 additions and 8 deletions
+6 -1
View File
@@ -56,6 +56,11 @@ impl MirrorAxis {
if axis.ends.iter().any(|q| q.distance(p) <= cx.tol(9.0)) {
return Some((axis, true));
}
// The center is its own move handle. Keep it ahead of bounding-box handles when the two
// happen to overlap; the rest of the axis line yields to those handles below.
if axis.center.distance(p) <= cx.tol(7.0) {
return Some((axis, false));
}
let d = axis.ends[1] - axis.ends[0];
let length = d.hypot();
if !length.is_finite() || length <= 0.0 {
@@ -63,7 +68,7 @@ impl MirrorAxis {
}
let unit = d / length;
let along = (p - axis.ends[0]).dot(unit).clamp(0.0, length);
((axis.ends[0] + unit * along).distance(p) <= cx.tol(7.0)).then_some((axis, false))
((axis.ends[0] + unit * along).distance(p) <= cx.tol(7.0) && !crate::select::bbox_handle_at(cx, p)).then_some((axis, false))
}
}
+6
View File
@@ -296,6 +296,12 @@ fn box_hit(cx: &ToolContext, b: &OrientedBox, p: Point) -> Option<BoxHit> {
in_rotate_zone(b.rect, lp, tol, cx.tol(18.0)).map(|_| BoxHit::Rotate)
}
/// Whether the current selection's bounding-box handle is under `p`, using the same geometry as
/// the Selection tool's press handling.
pub(crate) fn bbox_handle_at(cx: &ToolContext, p: Point) -> bool {
cx.show_bbox && selection_box(cx).is_some_and(|b| matches!(box_hit(cx, &b, p), Some(BoxHit::Handle(_))))
}
/// How near (screen points) the pointer must come to an object's centre or anchor for Smart Guides
/// to label it while hovering.
const HOVER_REACH: f64 = 6.0;