diff --git a/crates/tools/src/addons/enclosing_lasso.rs b/crates/tools/src/addons/enclosing_lasso.rs index cd9b0a324..9b92f0833 100644 --- a/crates/tools/src/addons/enclosing_lasso.rs +++ b/crates/tools/src/addons/enclosing_lasso.rs @@ -16,7 +16,10 @@ use crate::xform::{BLUE, polygon}; use crate::{Action, Cursor, Mods, Overlay, PointerEvent, PointerKind, Tool, ToolContext, ToolKey, json_ids}; -pub const ID: &str = "superLasso"; +pub const ID: &str = "enclosingLasso"; +/// The most points a loop keeps (one per screen pixel dragged): room for a loop around a 4K screen +/// many times over. +pub(crate) const MAX_POINTS: usize = 65_536; #[derive(Default)] pub struct EnclosingLassoTool { @@ -114,7 +117,7 @@ impl Tool for EnclosingLassoTool { PointerKind::Drag if self.active => { if self.points.last().is_none_or(|p| p.distance(ev.pos) >= cx.tol(1.0)) { // Cancel rather than testing a truncated loop that could select other art. - if self.points.len() >= 4096 { + if self.points.len() >= MAX_POINTS { self.active = false; self.points.clear(); return vec![]; diff --git a/crates/tools/src/addons/enclosing_lasso/tests.rs b/crates/tools/src/addons/enclosing_lasso/tests.rs index 517461352..836e64030 100644 --- a/crates/tools/src/addons/enclosing_lasso/tests.rs +++ b/crates/tools/src/addons/enclosing_lasso/tests.rs @@ -256,8 +256,8 @@ fn enclosing_lasso_cancels_an_overlong_gesture_instead_of_silently_truncating_it let cx = cx(&d, &s, &p); let mut tool = EnclosingLassoTool::default(); tool.pointer(&cx, &PointerEvent::new(PointerKind::Down, 0.0, 0.0)); - for i in 1..=4096 { - assert!(tool.pointer(&cx, &PointerEvent::new(PointerKind::Drag, f64::from(i), 100.0)).is_empty()); + for i in 1..=MAX_POINTS { + assert!(tool.pointer(&cx, &PointerEvent::new(PointerKind::Drag, i as f64, 100.0)).is_empty()); } assert!(!tool.busy()); assert!(tool.overlays(&cx).is_empty()); diff --git a/crates/ui-egui/src/toolbar/tests.rs b/crates/ui-egui/src/toolbar/tests.rs index c198e1457..e8e5d8f12 100644 --- a/crates/ui-egui/src/toolbar/tests.rs +++ b/crates/ui-egui/src/toolbar/tests.rs @@ -98,8 +98,6 @@ fn the_tool_buttons_are_centred_in_the_panel() { } } -/// Screen readers name each tool button by its tool tip and say which tool is active, and name -/// the title bar's column toggle and grip and the paint buttons under the tools. #[test] fn saved_flyout_choices_must_still_belong_to_the_slot() { let mut app = VectorcraftApp::new(Session::new(), Default::default()); @@ -111,6 +109,8 @@ fn saved_flyout_choices_must_still_belong_to_the_slot() { } } +/// Screen readers name each tool button by its tool tip and say which tool is active, and name +/// the title bar's column toggle and grip and the paint buttons under the tools. #[test] fn screen_readers_name_the_tool_buttons_and_the_active_tool() { let mut app = VectorcraftApp::new(Session::new(), Default::default());