Skip to content

Symbols panel: drag art in to make a symbol, drag a symbol out to place it - #288

Merged
bflatastic merged 3 commits into
storytold:mainfrom
theironchef:fix/symbols-drag-and-drop
Oct 7, 2026
Merged

bflatastic merged 3 commits into
storytold:mainfrom
theironchef:fix/symbols-drag-and-drop

Conversation

@theironchef

Copy link
Copy Markdown
Contributor

Fixes #285.

Problem: the Symbols panel (crates/ui-egui/src/panels/symbols.rs) took no drag and drop in either direction.

  • Art dragged off the canvas (PanelDrag::Art, which the Graphic Styles and Asset Export panels accept) was ignored when released over it.
  • Its tiles and rows sensed clicks only, so a symbol couldn't be dragged onto the artboard.

Both are the reference app's usual ways to make and to place a symbol.

Change

  • Art onto the panel: the symbol list is a drop zone for dragged art. It's outlined while art is held over it, and on release it runs symbol.new {ids}, which makes the symbol and replaces the art with an instance, like New Symbol. It uses the same pattern as Asset Export's drop_zone.
  • Symbol onto the canvas: tiles and list rows are drag sources for a new PanelDrag::Symbol(name). canvas::panel_drop places it with symbol.place {name, x, y}, centred at the drop point, on empty canvas as well as on art (its hit test runs after this case). On the way, the pointer shows the symbol's thumbnail through the shared pointer_chip (new symbols::chip).
  • Click (make current) and double-click (place at the artboard centre) are unchanged.
  • The other PanelDrag matches (Graphic Styles' drop zone, the Swatches drag preview) cover the new variant.

Tests

  • New panels::symbols::tests::art_dropped_on_the_panel_becomes_a_symbol_and_a_symbol_drags_out, a headless panel:
    • releasing a dragged rectangle over the list makes one symbol, and the rectangle becomes its instance;
    • dragging the new tile out sets PanelDrag::Symbol with its name.
  • New canvas::tests::a_symbol_dropped_on_the_canvas_is_placed_there: a symbol released over empty canvas gives a selected instance of it, centred at the drop point.
  • Both fail when the new handling calls a missing command instead.
  • cargo test -p vectorcraft-ui-egui: 558 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 real mouse drags:
    • dragging a selected star off the canvas onto the Symbols panel made "New Symbol" (History: "New Symbol"), with the star now its instance;
    • dragging that tile onto empty canvas showed its thumbnail at the pointer and placed an instance centred at (300.2, 199.9) for a drop at about (300, 200) (History: "Place Symbol Instance").

Follow-ups not in this PR: the reference app also takes art dropped on the Swatches panel (a pattern swatch) and the Brushes panel (a new brush), and a brush dragged onto a path.

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

🤖 Generated with Claude Code

theironchef and others added 3 commits October 7, 2026 13:19
… typed

egui reports the character a key types, so Cmd+Shift+[ arrives as
Cmd+Shift+{ (], / likewise as }, ?) and Shift+` as the text ~, and these
default shortcuts never matched: Bring to Front, Send to Back, Search
Commands and the Curvature tool. Command chords now also take the
shifted character, single-key tool and command shortcuts also look up
Shift+<typed text>, and the Keyboard Shortcuts editor records such a
chord as its key (Cmd+Shift+], not Cmd+Shift+}), so conflicts show.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e caret there

The Selection tool's double-click on text only switched to the Type
tool, which then had nothing being edited, so typing went to the tool
shortcuts (X swapped the text's fill and stroke). After such a switch
the canvas passes the double-click on to the Type tool as a click, which
starts editing the type with the caret where it was clicked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Art dragged off the canvas and released over the Symbols panel's list
becomes a new symbol (symbol.new with the dragged ids), and a symbol
dragged out of the panel (PanelDrag::Symbol) is placed on the canvas
centred where it is dropped (symbol.place), showing its thumbnail at
the pointer on the way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bflatastic
bflatastic force-pushed the fix/symbols-drag-and-drop branch from bd8f11c to bc688bd Compare October 7, 2026 06:30
@bflatastic
bflatastic merged commit 71efade into storytold:main Oct 7, 2026
@bflatastic

Copy link
Copy Markdown
Member

Thanks @theironchef, merged! I rebased it on main and made two small changes:

  • the panel's tiles and rows now paint their thumbnails with your new symbols::chip (taking the document) instead of a separate closure doing the same thing;
  • a "Panel drag and drop" line in the ROADMAP.

Live check in the app: dragging a selected rectangle onto the Symbols panel made "New Symbol" with the rectangle as its instance, and dragging the tile out placed an instance centred exactly at the drop point. The Swatches and Brushes drops you listed are good follow-ups.

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: The Symbols panel takes no drag and drop: art dropped on it makes no symbol, symbols can't be dragged onto the canvas

2 participants