From 8a30a026fef2e9cade5ea4e9259da493a5f4428d Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 17 Nov 2026 00:21:36 +0000 Subject: [PATCH] The anchor tools' empty-canvas part shows the tool's off-path cursor --- crates/draw/src/ui/pen/anchor_tool.rs | 2 +- crates/draw/src/ui/pen/bezier/mod.rs | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/crates/draw/src/ui/pen/anchor_tool.rs b/crates/draw/src/ui/pen/anchor_tool.rs index cf5869631..e36351012 100644 --- a/crates/draw/src/ui/pen/anchor_tool.rs +++ b/crates/draw/src/ui/pen/anchor_tool.rs @@ -47,7 +47,7 @@ impl<'a> AnchorTool<'a> { } /// The cursor of `tool` off the overlay's parts with `mods` held; `precise` is the canvas's precise cursor. -fn cursor_of(tool: PathTool, mods: Mods, precise: bool) -> PaintedCursor { +pub(super) fn cursor_of(tool: PathTool, mods: Mods, precise: bool) -> PaintedCursor { // The pen's tip is the bottom left corner of the icon's box. let pen = |badge| PaintedCursor::tool(ToolIcon::Pen.icon(), Vec2::Y * ICON_BOX, Some(badge)); match tool { diff --git a/crates/draw/src/ui/pen/bezier/mod.rs b/crates/draw/src/ui/pen/bezier/mod.rs index ccb906b27..32d580dc9 100644 --- a/crates/draw/src/ui/pen/bezier/mod.rs +++ b/crates/draw/src/ui/pen/bezier/mod.rs @@ -14,7 +14,7 @@ mod words; use craft_behavior::geometry::{SelectionOperation, axis_or_diagonal}; use craft_behavior::kurbo::{Point, Rect as DocRect, Vec2}; use craft_behavior::{ - Axis, CanvasView, CursorPriority, EditCommand, GesturePhase, Granularity, HitLevel, HitPriority, HitShape, Intent, MoveMods, NavMove, NavShape, + Axis, CanvasView, Cursor, CursorPriority, EditCommand, GesturePhase, Granularity, HitLevel, HitPriority, HitShape, Intent, MoveMods, NavMove, NavShape, PartKey, PartRef, PointerButton, PressPhase, PressStart, Roving, Sense, }; use craft_keymap::{Chord, Key, Mods}; @@ -41,7 +41,8 @@ pub use model::{AnchorDelete, EditPath, EditSubpath, HandleSide, Knot, KnotRef, pub use style::BezierStyle; pub use words::BezierWords; -use super::PathOptionsSettings; +use super::anchor_tool::cursor_of; +use super::{PathOptionsSettings, PathTool}; /// Insert on a picked anchor adds one halfway along the segment leaving it. const INSERT: Chord = Chord::plain(Key::Insert); @@ -831,9 +832,16 @@ impl<'a> BezierOverlay<'a> { } if matches!(self.tool, BezierTool::AddAnchor | BezierTool::DeleteAnchor) && let Some(result) = cx.part_if_declared(EMPTY) - && matches!(result.press.phase, PressPhase::Down { start, .. } if start.button == PointerButton::Primary) { - self.report.pressed_empty = true; + // The part covers the canvas background, so it owns the cursor the host tool shows off the paths too. + if result.hover_pos.is_some() { + let tool = if self.tool == BezierTool::AddAnchor { PathTool::AddAnchor } else { PathTool::DeleteAnchor }; + let cursor = cursor_of(tool, result.press.mods, space.precise()); + cx.cursor(Cursor::Painted(cursor), CursorPriority::Part); + } + if matches!(result.press.phase, PressPhase::Down { start, .. } if start.button == PointerButton::Primary) { + self.report.pressed_empty = true; + } } // A press none of the parts carries any more (its part went with the paths) is over for the overlay. if !pressed && cx.press_slot::().is_some() {