Pen: Escape after the path is deselected ends something else

The Pen and the Smart Pen reported a path being drawn to Escape for as
long as they remembered the path, even after Deselect or Undo left it
unselected. That Escape then ended nothing, and isolation mode or a
rotated view needed a second press. Both tools now report the path only
while they would go on drawing it, as the Curvature tool does.

Follows #6405
This commit is contained in:
dotCooCoo
2026-11-11 03:44:25 -08:00
parent 4e0e1c8af7
commit 4cde1aaa1f
3 changed files with 21 additions and 4 deletions
+2 -2
View File
@@ -548,8 +548,8 @@ impl Tool for SmartPenTool {
}
/// A path being drawn: Escape ends it.
fn ends_on_escape(&self, _cx: &ToolContext) -> bool {
self.path.is_some()
fn ends_on_escape(&self, cx: &ToolContext) -> bool {
self.active(cx).is_some()
}
fn deactivate(&mut self, _cx: &ToolContext) -> Vec<Action> {
+2 -2
View File
@@ -243,8 +243,8 @@ impl Tool for PenTool {
self.drag.is_some() || self.handle.is_some() || self.convert.is_some()
}
/// A path being drawn: Escape ends it.
fn ends_on_escape(&self, _cx: &ToolContext) -> bool {
self.path.is_some()
fn ends_on_escape(&self, cx: &ToolContext) -> bool {
self.active(cx).is_some()
}
fn pointer(&mut self, cx: &ToolContext, ev: &PointerEvent) -> Vec<Action> {
let tol = cx.tol(5.0).max(cx.point_tol());
+17
View File
@@ -535,6 +535,23 @@ fn escape_that_ends_a_path_being_drawn_keeps_the_rotation() {
}
}
/// A path that is no longer selected is not being drawn: the next Escape resets the view.
#[test]
fn escape_after_deselecting_the_path_resets_the_view() {
for tool in ["pen", "smartPen", "curvature"] {
let mut w = Window::new();
w.app.select_tool(tool);
let c = w.app.canvas_rect.unwrap().center();
w.click(0.0, egui::PointerButton::Primary, c);
w.click(0.1, egui::PointerButton::Primary, c + egui::vec2(60.0, 10.0));
assert!(w.app.session.tool_ends_on_escape(w.app.view_info()), "{tool}: a path is being drawn");
w.app.run("select.none", json!({})).unwrap();
assert!(!w.app.session.tool_ends_on_escape(w.app.view_info()), "{tool}: the path is not selected");
w.escape(0.2);
assert_eq!(w.rotation(), 0.0, "{tool}: one Escape resets the view");
}
}
/// In isolation mode, an Escape that ends the Pen's path ends only the path: the next Escape leaves
/// isolation mode, and the one after it resets the view.
#[test]