Module tools

Source
Expand description

Tool bar: a thin, movable strip that sits between the viewport and the timeline (its own dockable pane, so it can also be popped out). One row of icon buttons: Select (V) · Text (T) · Rectangle · Ellipse · Triangle · Polygon · Star · Line · Arrow · Draw (D) · Mask (rect/ellipse/polygon/path) · Zoom plus a magnet button that lights up while snapping is on (S, or Settings.snap’s own N shortcut), then, for shape tools, fill and stroke colour buttons and a stroke-width DragValue; for Draw, a play/record button, the brush colour/width, the playback speed (0.5x / 1x / 2x) and a page toggle.

The active tool changes what a click-drag in the Preview does (see ui::preview): Select edits the selected clip, a shape tool drags out a new Shape clip at the playhead (Shift locks its aspect ratio, Alt grows it from the press point instead of corner-to-corner), Draw records strokes while the mouse is down (timed, so the sketch replays), Mask edits the selected effect’s / clip’s mask.

Structs§

ToolsState

Enums§

Dir 🔒
Which way a triangle / arrow glyph points.
Glyph 🔒
The strip, left to right: (tool, icon, name). Tool::Mask stands for whichever mask shape is selected (the combo next to it picks one), the shape tools each get their own button. What icon_button draws. Painted with the painter, not typed: nearly every obvious character (polygon, pencil, half-disc, magnifier, close, play, reorder arrows) is missing from Segoe UI and egui’s bundled fonts and came out as a tofu box.
Tool

Constants§

SHAPE_CYCLE 🔒
The shape tools in strip order (Draw has its own key, so it is not part of the S cycle).
STRIP 🔒

Functions§

action_glyph 🔒
Built-in icon for a menu action (None = text-only). The user’s Settings → Appearance → Icons override wins over these; abstract actions stay text-only on purpose.
color_chip 🔒
The label-colour swatch every label menu shows: a filled round chip. A Button, so a caller can click it, select it or hang a menu off it.
draw_glyph 🔒
Paint one tool glyph inside rect (a 24x22 button) in fg.
glyph_label 🔒
Paint icon where a plain label would go — no button chrome, no hit area.
glyph_text_button 🔒
A button showing icon and then text. Used wherever a control needs a real-world picture rather than a symbol character (half of those render as tofu boxes in Segoe UI). An empty text gives a bare icon button, centred.
handle_hotkeys
V / T / D / M and Shift+S switch tools (Shift+S also steps through the shape variants; M steps through the mask variants), ignored while a text field has focus or an unlisted modifier is held. Bare S is snapping’s key (see handle_snap_hotkey), not a tool switch. Returns the new tool when it changed; the key is consumed, so calling this twice in a frame is harmless.
handle_snap_hotkey
Bare S (no modifiers) toggles snapping — claimed here, ahead of the action table, so it can never race with Shift+S’s shape cycle above or with the N binding in hotkeys.rs (Action::ToggleSnap, still live and unaffected). *snap flips in place; the caller persists it. Returns true when it fired.
icon_button 🔒
Bare square icon button: accent fill when active, a hover outline otherwise.
next_mask 🔒
next_shape 🔒
on_accent 🔒
Readable text colour on top of the accent fill.
same_tool 🔒
The Mask button lights up for every mask shape (the combo beside it picks one); everything else is an exact match.
show
Returns true when the tool, *snap or the style changed (the app may want to repaint the preview overlay). snap is Settings.snap — owned by the app, not this strip, so it comes in by reference.
style_controls 🔒
Style controls for the active tool. Returns true when anything changed.
tool_hotkey
Single-key shortcut of a tool (used for the tooltips and by handle_hotkeys). The shape tools cycle on Shift+S instead (bare S toggles snapping), so their tooltip is built by hand in show.