Intent
Represents a user action or system event that should change the drawing state.
Intent is the input to the MVI (Model-View-Intent) pattern. All state changes flow through this sealed class:
User Action → Intent → Reducer → New State → UI UpdateIntent instances are immutable data classes that capture the parameters of what the user wants to do. The io.ak1.drawbox.presentation.reducer.Reducer interprets these intents and produces new state.
See also
for how intents are processed
for the resulting state after intent handling
Inheritors
Types
Add a new element to the canvas
Open an erase session. Resets State.erasingSessionDirty so the next EraseAt that actually removes an element will snapshot history once. A session that never lands on an element snapshots nothing — taps and drags through empty space consume no undo slot.
Push the current elements onto the undo history. Use at the start of a gesture that mutates the selection across many tiny updates (drag move, resize, rotate) so a single undo reverts the whole gesture.
Move selected elements to the top of the z-order. Snapshots history.
Clear the current selection.
Finalize a marquee selection: select every element whose bounding box intersects rect. Also clears State.marqueeRect.
Delete an element from the canvas
Delete every element in State.selectedIds.
Close an erase session. Clears State.erasingSessionDirty so the next session starts fresh. Also serves as a transaction-end signal for sync / autosave observers (see EndTransform).
Marks the end of a drag-driven mutation. State is already up to date by this point; the reducer treats this as a no-op. Provided as a hint for transaction-aware observers (sync layers, autosave debouncers, analytics): a coherent gesture just ended, commit/flush now.
Delete every element whose body intersects a disk of radius around point (world space). Snapshots history lazily on the first hit within the current erase session (see BeginErase). Subsequent hits inside the same session mutate elements in place without snapshotting, so a single undo reverts the entire sweep. No-op when no element is hit — no snapshot is pushed and no State copy is emitted.
Recompute connector bindings for an ARROW based on where its endpoints currently sit. Called at drag-end after creating or moving the arrow.
Place an Element.Image at position in world space, sized from intrinsicSize so the placed bitmap preserves its source aspect ratio by default. Hosts that want different placement can dispatch SetElementBounds right after.
Start a new freehand path at the specified offset.
Start a new shape at the specified offset.
Insert an Element.Text at position with the given style. The wrap box is sized from a sensible default width; embedders that want a different layout can dispatch SetElementBounds immediately after. Snapshots history once.
Load a previously saved drawing from storage
Translate every selected element by delta. Does not snapshot history.
Request in-place text editing at offset (dispatched on a double-tap in Mode.SELECT). Selects the topmost Element.Text under the point within tolerance; when one is hit, the controller emits Event.TextEditRequested. A no-op when the topmost hit is not a text element. Not undoable — selection changes only.
Reset the viewport to identity (offset = Zero, scale = 1). Not undoable.
Move selected elements to the bottom of the z-order. Snapshots history.
Set or clear the repeating background pattern painted above SetBgColor and below all drawing elements.
Change the canvas background color
Default corner radius applied to new RECTANGLE / TRIANGLE shapes. Has no effect on shapes that ignore it (circle, line, arrow) and on shapes already on the canvas.
Set the absolute bounding box of a single element. Used during resize. Does not snapshot history (caller should dispatch BeginTransform first).
Replace the points list of a single element. Used when dragging the endpoint of a LINE/ARROW. Does not snapshot history.
Set the absolute rotation in degrees of a single element. Used during rotate. Does not snapshot history.
Change the world-space eraser radius used by Mode.ERASER.
Default fill color for new Element.Shapes. null clears the fill so new shapes render stroke-only. Has no effect on shapes already on the canvas; use SetSelectedFillColor to retro-edit those.
Default font family key for future text inserts. Not history-tracked.
Default font size for future text inserts. Mirrors SetStrokeWidth for shapes: mutates the State default without touching any existing element. Not history-tracked — the default is session-level UI state.
Update the curve deflection of a LINE/ARROW. Does not snapshot history.
Replace the current marquee rectangle (or clear with null). Not undoable.
Change the opacity/alpha for new drawings (0.0 to 1.0)
Set the corner radius of every selected RECTANGLE / TRIANGLE shape. Snapshots history. Other shape types in the selection are left alone.
Replace the fill color of every selected Element.Shape. Pass null to clear the fill so the shape renders stroke-only. Paths and images in the selection are left untouched. Snapshots history.
Replace font family key on every selected text element. Snapshots history.
Replace font size on every selected text element. Snapshots history.
Replace the stroke color of every selected element. Snapshots history.
Toggle the stroke pass on every selected Element.Shape. false makes the shape fill-only; true restores the outline. Paths and images (always stroked) are left untouched. Snapshots history.
Set the stroke pattern of every selected Element.Shape. Snapshots history. Freehand paths in the selection are left alone.
Replace the stroke width of every selected element. Snapshots history.
Replace text alignment on every selected text element. Snapshots history.
Change the stroke color for new drawings
Default outline pass for new Element.Shapes. When false, new shapes render fill-only. Has no effect on shapes already on the canvas; use SetSelectedStrokeEnabled to retro-edit those.
Default stroke pattern applied to new shapes. Has no effect on existing shapes on the canvas; use SetSelectedStrokeStyle to retro-edit those.
Change the stroke width for new drawings
Toggle the transient pan-while-held flag (e.g. for space bar). Not undoable.
Default text alignment for future text inserts. Not history-tracked.
Renderer-driven height reconciliation for a single text element.
Update an existing element in place
Add a new point to the current path being drawn.
Update the current shape's dimensions by providing the end point.
Replace the text content of an existing Element.Text. Snapshots history so a typing session can be undone as a single revision when the embedder commits with a single dispatch (typical for modal editors); embedders implementing inline editing should batch their own undo boundaries.