mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-11 02:19:56 -06:00
Enclosing Lasso: a neutral tool id, a longer loop cap, the screen-reader test keeps its doc comment
This commit is contained in:
@@ -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![];
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user