Sketch: the arc's sweep box no longer covers the end-point pick (#2201) (#2242)

Thanks @DuBearte.
This commit is contained in:
DuBearte authored and GitHub committed 2026-10-18 01:10:53 -04:00
1 parent 6422ef84d5
commit 33cd031701
3 files changed
+100 -3

No files matched your search

+23
View File
@@ -2,6 +2,7 @@
use serde_json::json;
use super::{BOX, in_view};
use crate::scenario::Harness;
fn drawing(command: &str) -> Harness {
@@ -316,3 +317,25 @@ fn a_line_end_on_a_circle_outside_the_axis_snap_stays_at_the_cursor() {
let end = sk.point(b).unwrap();
assert!((end.len() - 30.0).abs() < 1e-9 && end.dist(at) < 0.5, "{end:?}");
}
/// A value box set off the cursor stays in the drawing area (#2201): past an edge it goes to the
/// cursor's other side, still clear of it; with no room either side it is pushed inside.
#[test]
fn value_boxes_stay_in_view_and_off_the_cursor() {
let view = egui::Rect::from_min_max(egui::pos2(250.0, 130.0), egui::pos2(1650.0, 960.0));
let cursor = egui::pos2(565.0, 142.0);
// 50 px above the cursor: over the ribbon.
let above = cursor + egui::vec2(-34.0, -11.0 - 50.0);
let p = in_view(above, Some(view), Some(cursor));
let rect = egui::Rect::from_min_size(p, BOX);
assert!(view.contains_rect(rect), "{rect:?} in {view:?}");
assert!(!rect.expand(2.0).contains(cursor), "{rect:?} clear of {cursor:?}");
assert!(rect.min.y > cursor.y, "below the cursor now");
// A box that fits stays where it is; without a view nothing moves.
let inside = egui::pos2(700.0, 500.0);
assert_eq!(in_view(inside, Some(view), Some(cursor)), inside);
assert_eq!(in_view(above, None, Some(cursor)), above);
// No room on either side: inside the view all the same.
let tiny = egui::Rect::from_min_size(egui::pos2(0.0, 0.0), egui::vec2(80.0, 30.0));
assert!(tiny.contains_rect(egui::Rect::from_min_size(in_view(egui::pos2(-200.0, -200.0), Some(tiny), Some(egui::pos2(40.0, 15.0))), BOX)));
}