From 6dd5156e5f71e4fdad66de1e54e45f2b2c009e5f Mon Sep 17 00:00:00 2001 From: ljkx <177671075+ljkx@users.noreply.github.com> Date: Mon, 2 Nov 2026 23:21:59 +0100 Subject: [PATCH] Crop: the Shift-corner unit test expects the diagonal size (#10871) --- crates/ui-egui/src/tools/crop_ui/tests.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/tools/crop_ui/tests.rs b/crates/ui-egui/src/tools/crop_ui/tests.rs index 6fba4e57d4..65b35c689a 100644 --- a/crates/ui-egui/src/tools/crop_ui/tests.rs +++ b/crates/ui-egui/src/tools/crop_ui/tests.rs @@ -387,13 +387,14 @@ fn handles_resize_with_shift_and_alt() { // Bottom-right corner, free. drag(&mut app, &[[120.0, 60.0], [140.0, 70.0]], NONE); assert_eq!(app.ui.crop_rect, Some([20.0, 20.0, 140.0, 70.0])); - // ⇧ keeps 120:50 from the top-left corner: the larger relative extent wins. + // ⇧ keeps 120:50 from the top-left corner: the corner follows the frame's diagonal, so the + // drag (−10, −20) projected onto (−120, −50) grows the frame by 2200 / 16900 (#10871). app.ui.crop_rect = Some([20.0, 20.0, 140.0, 70.0]); drag(&mut app, &[[20.0, 20.0], [10.0, 0.0]], SHIFT); let r = app.ui.crop_rect.unwrap(); assert_eq!((r[2], r[3]), (140.0, 70.0), "opposite corner fixed"); assert!(((r[2] - r[0]) / (r[3] - r[1]) - 120.0 / 50.0).abs() < 1e-9, "{r:?}"); - assert_eq!(r[3] - r[1], 70.0); + assert!((r[3] - r[1] - 50.0 * (1.0 + 2200.0 / 16900.0)).abs() < 1e-9, "{r:?}"); // ⌥ resizes about the centre. app.ui.crop_rect = Some([40.0, 20.0, 80.0, 60.0]); drag(&mut app, &[[80.0, 40.0], [90.0, 40.0]], Modifiers::ALT);