plushie/widget/canvas
Canvas widget builder. Layers are managed via widget commands.
Types
Option type for canvas properties.
pub type Opt {
Layers(dict.Dict(String, List(node.PropValue)))
Shapes(List(node.PropValue))
Layer(String, List(node.PropValue))
Background(color.Color)
Interactive(Bool)
OnPress(Bool)
OnRelease(Bool)
OnMove(Bool)
OnScroll(Bool)
Alt(String)
Description(String)
Role(String)
ArrowMode(String)
EventRate(Int)
A11y(a11y.A11y)
}
Constructors
-
Layers(dict.Dict(String, List(node.PropValue))) -
Shapes(List(node.PropValue)) -
Layer(String, List(node.PropValue)) -
Background(color.Color) -
Interactive(Bool) -
OnPress(Bool) -
OnRelease(Bool) -
OnMove(Bool) -
OnScroll(Bool) -
Alt(String) -
Description(String) -
Role(String) -
ArrowMode(String) -
EventRate(Int) -
A11y(a11y.A11y)
Values
pub fn arrow_mode(c: Canvas, mode: String) -> Canvas
Set the arrow key navigation mode (“wrap”, “clamp”, “linear”, “none”).
pub fn build(c: Canvas) -> node.Node
Build the canvas into a renderable Node.
Shapes are promoted to tree children (not props) matching the renderer’s expected format. The renderer reads shapes from canvas children, not from a “shapes” or “layers” prop.
- With layers: each layer becomes a
__layer__child node containing shape children. - Without layers (flat shapes): shapes become direct children, treated by the renderer as a “default” layer.
pub fn layer(
c: Canvas,
name: String,
s: List(node.PropValue),
) -> Canvas
Add a single named layer to the canvas. Merges with existing layers.
pub fn layers(
c: Canvas,
l: dict.Dict(String, List(node.PropValue)),
) -> Canvas
Set all canvas layers as a dict of named shape lists.
pub fn new(
id: String,
width: length.Length,
height: length.Length,
) -> Canvas
Create a new canvas builder.
pub fn shapes(c: Canvas, s: List(node.PropValue)) -> Canvas
Set the shape list for the default layer.