plushie/widget/canvas

Canvas widget builder. Layers are managed via widget commands.

Types

pub opaque type Canvas

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

Values

pub fn a11y(c: Canvas, a: a11y.A11y) -> Canvas

Set accessibility properties for this widget.

pub fn alt(c: Canvas, a: String) -> Canvas

Set the alt text for accessibility.

pub fn arrow_mode(c: Canvas, mode: String) -> Canvas

Set the arrow key navigation mode (“wrap”, “clamp”, “linear”, “none”).

pub fn background(c: Canvas, col: color.Color) -> Canvas

Set the background color.

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 description(c: Canvas, d: String) -> Canvas

Set the description text for accessibility.

pub fn event_rate(c: Canvas, rate: Int) -> Canvas

Set the event throttle rate in milliseconds.

pub fn interactive(c: Canvas, enabled: Bool) -> Canvas

Set whether the canvas accepts mouse events.

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 on_move(c: Canvas, enabled: Bool) -> Canvas

Enable the move event.

pub fn on_press(c: Canvas, enabled: Bool) -> Canvas

Enable the press event.

pub fn on_release(c: Canvas, enabled: Bool) -> Canvas

Enable the release event.

pub fn on_scroll(c: Canvas, enabled: Bool) -> Canvas

Enable the scroll event.

pub fn role(c: Canvas, r: String) -> Canvas

Set the accessible role (e.g. “radiogroup”, “toolbar”).

pub fn shapes(c: Canvas, s: List(node.PropValue)) -> Canvas

Set the shape list for the default layer.

pub fn with_opts(c: Canvas, opts: List(Opt)) -> Canvas

Apply a list of options to a canvas builder.

Search Document