From d572f3ce711a0c80947aad0e529b075d119b5997 Mon Sep 17 00:00:00 2001 From: FractalEncrypt <59615752+FractalEncrypt@users.noreply.github.com> Date: Fri, 6 Nov 2026 11:38:22 -0500 Subject: [PATCH] Shape tools: the tool methods this pull request changes say what they do The `Tool` implementation's `busy`, `pointer`, `key`, `claims_key`, `overlays` and `cursor` in shape.rs, and `pointer` and `cursor` in select.rs, are the ones this pull request edits; each now has a doc comment, so the docstring coverage of the functions the diff touches is complete. --- crates/tools/src/select.rs | 4 ++++ crates/tools/src/shape.rs | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/crates/tools/src/select.rs b/crates/tools/src/select.rs index 61d215069e..0f879cb557 100644 --- a/crates/tools/src/select.rs +++ b/crates/tools/src/select.rs @@ -804,6 +804,8 @@ impl Tool for SelectionTool { } } + /// A press takes the selection's widgets, a ruler guide, a selected object's centre point or + /// the art; the drags then move, scale, rotate, marquee or drag what it took. fn pointer(&mut self, cx: &ToolContext, ev: &PointerEvent) -> Vec { self.note_loaded_at_press(ev.kind); let hovering = ev.kind == PointerKind::Move && matches!(self.state, State::Idle); @@ -1061,6 +1063,8 @@ impl Tool for SelectionTool { o } + /// The pointer for the drag in progress, else the one for what a press would take: a widget, + /// a ruler guide, the box's handles or rotate zone, a selected object's centre point or the art. fn cursor(&self, cx: &ToolContext, p: Point, m: Mods) -> Cursor { if let State::Mirror(d) = &self.state { return d.cursor(cx, p); diff --git a/crates/tools/src/shape.rs b/crates/tools/src/shape.rs index d513b1f5e4..076525be44 100644 --- a/crates/tools/src/shape.rs +++ b/crates/tools/src/shape.rs @@ -391,9 +391,13 @@ impl Tool for ShapeTool { fn id(&self) -> &'static str { self.id } + /// A shape being drawn, a Live Shape widget dragged, or the selection moved or turned is a + /// gesture in progress. fn busy(&self) -> bool { self.start.is_some() || self.widget.is_some() || self.selection.is_some() } + /// A widget or selection drag takes the pointer; otherwise a press draws, unless it lands on + /// the selection's centre point or in the rotate zone just outside its box's corner. fn pointer(&mut self, cx: &ToolContext, ev: &PointerEvent) -> Vec { if let Some(out) = self.widget_pointer(cx, ev) { return out; @@ -469,6 +473,8 @@ impl Tool for ShapeTool { _ => vec![], } } + /// ↑/↓ change a polygon's sides, a star's points or the rounded rectangle's radius while it is + /// drawn; Escape turns a widget or selection drag back. fn key(&mut self, cx: &ToolContext, key: ToolKey, _mods: Mods) -> Vec { // A drag of the selection: Escape turns it back, as with the Selection tool. if self.selection.is_some() { @@ -540,6 +546,8 @@ impl Tool for ShapeTool { }, } } + /// ↑/↓ step a corner's kind while its widget is dragged, and Escape ends a drag of the + /// selection. fn claims_key(&self, _cx: &ToolContext, key: ToolKey) -> bool { match (&self.widget, &self.selection) { (Some(WidgetDrag::Corner(_)), _) => matches!(key, ToolKey::Up | ToolKey::Down), @@ -547,6 +555,8 @@ impl Tool for ShapeTool { _ => false, } } + /// The widget being dragged, the Smart Guides of the shape being drawn or the selection being + /// moved, and its size, angle or offset label. fn overlays(&self, cx: &ToolContext) -> Vec { match &self.widget { Some(WidgetDrag::Corner(c)) => return c.overlays(cx), @@ -588,6 +598,9 @@ impl Tool for ShapeTool { } o } + /// The Selection tool's pointer over a Live Shape widget, the selection's centre point or the + /// rotate zone just outside its box's corner; the crosshair everywhere else, where a press + /// draws. fn cursor(&self, cx: &ToolContext, p: Point, m: Mods) -> Cursor { // Over a widget a press would drag (or dragging one), the Selection tool's pointer for it. let idle = self.start.is_none();