Skip to content

Canvas: Ctrl with another tool drags with the selection tool used last - #276

Merged
bflatastic merged 2 commits into
storytold:mainfrom
theironchef:fix/temp-selection-tool
Oct 7, 2026
Merged

bflatastic merged 2 commits into
storytold:mainfrom
theironchef:fix/temp-selection-tool

Conversation

@theironchef

Copy link
Copy Markdown
Contributor

Fixes #270.

Problem: on a Cmd press with any tool outside the selection family, handle_input (crates/ui-egui/src/canvas.rs) switched to the Selection tool for the drag. In the reference app it's the selection tool used last. So with the Pen tool, after using Direct Selection, a Cmd-drag on an anchor moved the whole path instead of that anchor.

Change

  • UiState gets last_selection_tool, default "selection". VectorcraftApp::select_tool sets it whenever Selection, Direct Selection or Group Selection becomes the tool. It's covered by the struct's #[serde(default)].
  • The temporary switch uses it, falling back to Selection if the stored value isn't one of the three.
  • The tool check is now canvas::is_selection_tool, which the canvas and select_tool share.

Tests

  • New canvas::tests::cmd_with_another_tool_drags_with_the_selection_tool_used_last, a headless canvas test with Cmd held (via Event::ModifiersChanged) while the Pen tool is active:
    • with Direct Selection used last, the Cmd-drag is done by Direct Selection, moves only the rectangle's bottom-right anchor, and the Pen comes back;
    • with Group Selection or Selection used last, those are the tools used.
  • With the old select_tool("selection"), the test fails (left: "selection" right: "directSelection").
  • cargo test -p vectorcraft-ui-egui: 555 passed.
  • cargo clippy -p vectorcraft-ui-egui --all-targets -- -D warnings (Rust 1.99): clean.
  • cargo fmt --all -- --check: clean.
  • Checked by hand in a release build on Windows with the real mouse and keyboard: I clicked a triangle with Direct Selection, pressed P, and Ctrl-dragged its anchor at (200, 120) to (240, 100). Direct Selection was active during the drag, only that anchor moved, and the Pen came back.

I didn't run the full cargo xtask ci (wasm step) here.

🤖 Generated with Claude Code

bflatastic and others added 2 commits October 7, 2026 13:02
Dragging a bounding-box handle of area type with the Selection tool now
resizes the type area: the text reflows at its own size (threads too)
instead of being scaled, and History says "Resize Type Area". With other
objects selected they scale as before while the area type resizes its
frame. Direct Selection picks the frame's corners and edges and reshapes
the area ("Reshape Type Area", new command text.reshapeArea), and the
selected frame's anchors and outline show. Area Type Options gains Width
and Height. Point type, rotation, Object > Transform > Scale, the Scale
tool and the Transform panel still transform the type.

Root cause: every handle drag previewed object.transform, which folds the
matrix into the text's xf (TextObject::transform), so area type scaled its
glyphs; and Direct Selection's anchor hit test only looked at paths, so the
frame's corners could not be picked. object.transform now takes
typeAreas, which reshapes the frame in text space (xf^-1 * m * xf), and
the tools use it and text.reshapeArea.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ol used last

The canvas always switched to the Selection tool for a Cmd press with a
non-selection tool. The UI state now remembers which of Selection,
Direct Selection and Group Selection was used last, and the temporary
switch uses it, so Cmd-dragging an anchor while drawing with the Pen
after using Direct Selection moves that anchor, not the whole path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bflatastic
bflatastic force-pushed the fix/temp-selection-tool branch from 2eba7cd to 47104f5 Compare October 7, 2026 06:12
@bflatastic
bflatastic merged commit a20e680 into storytold:main Oct 7, 2026
@bflatastic

Copy link
Copy Markdown
Member

Thanks @theironchef, merged! I rebased it on main (it now sits with #279, whose canvas test landed right next to yours) and added a ROADMAP line ("Temporary tools"). I also checked it live in the app: with the Pen tool, a Cmd-drag on a corner moved just that anchor when Direct Selection was used last, moved the whole object when Selection was, and the Pen tool came back afterwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Ctrl with another tool always switches to the Selection tool, not the last-used selection tool

2 participants