Skip to main content

Module canvas

Module canvas 

Source
Expand description

What the core needs from a host that is live: a pointer, a cursor, a keyed easing, an in-place text editor, and a repaint request.

Renderer is enough to draw a diagram; a tool needs these as well. They are the three immediate-mode habits the render path has — polling animation, asking for a text editor as a struct the host renders next frame, and requesting a repaint — stated as methods, so a retained-mode host answers them with a timer, a widget and a no-op.

Structs§

AnimKey
Identity of one keyed easing. Each animated affordance mints its own from what distinguishes it — the corner, the pin slot, the anchor — so the easings run independently and hold their value between frames.
EditColors
The colours an in-place editor is painted in.
EditId
Identity of an in-place text editor across frames: the host keeps the editor’s focus, selection and scroll under this key, so a tool that asks for “the editor for this pin’s name” twice gets the same editor.
EditText
What a tool asks for when it opens an in-place editor: where it sits in the world, what it opens on, and how the text is drawn. Passed to Canvas::set_edit_text; the host runs an editor of its own there and answers with how the edit ended, as a TextEvent.

Enums§

Cursor
The pointer shapes the tools ask for.
PointerKind
What is driving the pointer. A fingertip covers several times what a cursor aims with and has no hover phase to aim by, so the affordances it grabs are sized differently.

Traits§

Animator
The frame-driven half of a live canvas: where the pointer is, and what a keyed easing is currently worth. Split out of Canvas because the generic render path reaches it through Renderer::animator on a &dyn — an offline backend has no pointer and no clock, and those overlays fall back to a static draw.
Canvas
A Renderer that is also live: the conveniences a tool needs from the host beyond putting marks on the diagram.

Functions§

hash_of 🔒
A stable u64 minted from anything hashable — the shape both keyed-animation and text-editor identity take. Both newtypes below are this, so the pattern is written once.