Shape tools: the click-to-open-dialog tolerance is the same on HiDPI displays (#4205) (#4207)

finish_gesture passed the device-pixel zoom (current_zoom) to
shape_dialog::is_click, whose 3-point slop is in egui points, so at
pixels_per_point 2 the tolerance halved and a slightly jittery click drew
a tiny shape instead of opening Create Rectangle/Ellipse/... Pass
point_zoom(), as the marquee already does.

Regression test: a 2 pt jitter at ppp 2 and 100 % opens the dialog and
adds no layer.

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
David MannandClaude Opus 5.5 authored and GitHub committed 2026-10-12 19:58:43 -04:00
1 parent f60202879d
commit 4566f5f55f
2 files changed
+15 -1

No files matched your search

+1 -1
View File
@@ -5176,7 +5176,7 @@ pub(crate) fn finish_gesture(app: &mut PhotocraftApp, d: Drag) {
Tool::FreeformPen => crate::vector_ui::freeform_finish(app, &d.points, d.lasso.as_ref().map_or(&[], |l| l.straight())),
// Photoshop: a click without dragging opens Create Rectangle / Ellipse / … instead.
t if crate::vector_ui::is_shape_tool(t)
&& crate::shape_dialog::is_click(d.start, &d.points, app.current_zoom())
&& crate::shape_dialog::is_click(d.start, &d.points, app.point_zoom())
&& crate::shape_dialog::open(app, t, d.start).is_some() => {}
t if crate::vector_ui::is_shape_tool(t) => crate::vector_ui::finish_shape(app, t, d.start, [end[0], end[1]], d.live),
Tool::PathSelection => crate::vector_ui::path_selection_finish(app, d.start, [end[0], end[1]]),
+14
View File
@@ -141,6 +141,20 @@ fn click_slop_scales_with_zoom() {
assert!(is_click([10.0, 10.0], &[], 0.0));
}
/// #4205: the click slop is in screen points, so on a 2x (HiDPI) display at 100 % a 2 pt jitter
/// (4 device px = 4 document px) is still a click that opens Create Rectangle, not a tiny shape.
#[test]
fn a_click_with_jitter_opens_the_dialog_on_hidpi() {
let mut app = app();
app.ppp = 2.0;
let i = app.session.active_index().unwrap();
app.ui.views[i].zoom = 1.0;
let before = layers(&app);
press(&mut app, Tool::Rectangle, [20.0, 30.0], [24.0, 30.0]);
only_dialog(&app);
assert_eq!(layers(&app), before, "a jittery click draws nothing");
}
#[test]
fn cancel_draws_nothing_and_ok_remembers_the_size() {
let mut app = app();