Repository navigation
Pen: Auto Add/Delete on a selected path - #312
Conversation
Between paths, the Pen now adds an anchor where a click lands on a segment of a selected path and deletes the anchor a click lands on, with the add and delete cursors while hovering, as in the reference app. The ends of a selected open path still continue it. Shift held, or General > Disable Auto Add/Delete (a stored preference nothing read until now, passed to tools as ToolContext::auto_add_delete), starts a new path instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sts (review of storytold#312) The Pen's Auto Add/Delete had its own copy of the anchor and segment hit tests and of the path.insertAnchor / path.removeAnchor actions the Add and Delete Anchor Point tools build. draw2 now exposes anchor_in / segment_in (the hit tests over a given set of paths) and insert_anchor / remove_anchor, which both tools use. Adds the ROADMAP entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
b8aaf5c to
7feeb73
Compare
|
Thanks @theironchef, merged! The Pen now adds and deletes anchors on a selected path, Shift turns it off while held, and Preferences › General › Disable Auto Add/Delete is finally read. I rebased it on main and added one commit on top. The Pen now reuses the Add/Delete Anchor Point tools' hit tests and action builders ( Live check: a click on a selected path's segment went from 3 to 4 anchors, and a click on an anchor went back to 3. History shows "Add Anchor Point" / "Delete Anchor Point" with the + / − cursors. A Shift-click, or |
Fixes #311.
Problem: the Pen had no Auto Add/Delete. Over a segment or an anchor of a selected path, it showed the plain Pen cursor and a click started a new path on top of it. The "Disable Auto Add/Delete" preference (
Prefs::disable_auto_add_delete) was stored but never read. In Illustrator, the Pen acts as the Add Anchor Point tool over a selected path and as the Delete Anchor Point tool over one of its anchors. Shift while hovering, or that preference, turns this off.Change
crates/tools/src/pen.rs, newauto_add_delete(cx, p, mods, tol), for the selected, editable, non-guide paths:path.removeAnchor;path.insertAnchorat that point (both are the commands the Add and Delete Anchor Point tools already run);Nonewhen Shift is held or the preference turns it off.cursorshowsPenAdd/PenDeletefor the same cases.ToolContext::auto_add_delete(tools) carries the preference. The engine fills it with!prefs.disable_auto_add_deleteinwith_tool_cx.Tests
pen::tests::clicking_a_selected_path_adds_or_deletes_an_anchor:Pen, notPenAdd).pen_click_on_a_selected_path_adds_an_anchor_unless_disabled, through the session:prefs.set {"key": "disableAutoAddDelete", "value": true}, the same click starts a second path and leaves 3.cargo test -p vectorcraft-tools: 189 passed.cargo test -p vectorcraft-engine: 1251 unit tests and the integration tests passed.cargo clippy -p vectorcraft-tools -p vectorcraft-engine --all-targets -- -D warnings(Rust 1.99): clean.cargo fmt --all -- --check: clean.disableAutoAddDeleteon. With it off again, the click added an anchor.I didn't run the full
cargo xtask ci(wasm step) here. The Pen's hint bar text is unchanged.Two things are left out. Paths inside a selected group aren't covered: only directly selected paths count, as for continuing a path. Clicking the last anchor of the path being drawn, to retract its handle, isn't handled either.
This touches different lines of
pen.rsthan #310 (Alt mid-drag) and #241 (Alt-click on an anchor).🤖 Generated with Claude Code