Skip to content

VectorCraft: An open-source, vector art tool written by scratch in pure Rust

Blob Brush: a release away from the press point paints with Alt down

dotCooCoo46721fe09346
diff --git a/crates/tools/src/draw2/gesture.rs b/crates/tools/src/draw2/gesture.rs
index 57a3293ff..ee01a4e34 100644
--- a/crates/tools/src/draw2/gesture.rs
+++ b/crates/tools/src/draw2/gesture.rs
@@ -519,6 +519,8 @@ impl Tool for GestureTool {
if !self.active {
return vec![];
}
+ // A release away from the press point counts as movement.
+ self.moved |= self.points.first().is_some_and(|start| p.distance(*start) > vectorcraft_geom::EPS);
// Alt pressed while the pointer stood still at the press point switches the release too.
if self.blob_alt_smooths(ev.mods) {
self.smoothing = true;
diff --git a/crates/tools/src/draw2/gesture/tests.rs b/crates/tools/src/draw2/gesture/tests.rs
index 59112ab9c..653efb6cf 100644
--- a/crates/tools/src/draw2/gesture/tests.rs
+++ b/crates/tools/src/draw2/gesture/tests.rs
@@ -409,6 +409,10 @@ fn blob_brush_alt_switches_to_the_smooth_tool() {
assert_eq!(t.cursor(&cx, at, alt), Cursor::Smooth);
let acts = t.pointer(&cx, &PointerEvent::new(PointerKind::Up, 50.0, 150.0).with_mods(alt));
assert!(acts.is_empty(), "{acts:?}");
+ // A release away from the press point with no drag before it paints when Alt goes down.
+ t.pointer(&cx, &PointerEvent::new(PointerKind::Down, 50.0, 150.0));
+ let acts = t.pointer(&cx, &PointerEvent::new(PointerKind::Up, 150.0, 150.0).with_mods(alt));
+ assert!(matches!(acts.as_slice(), [Action::Exec(c, _)] if c == "path.blob"), "{acts:?}");
// With nothing selected an Alt drag sends nothing.
let none = Selection::default();
let empty = crate::testutil::cx(&d, &none, &p);