Skip to content

Canvas

[Source]

An absolute-positioning container. Children are placed at explicit (x, y) coordinates with fixed sizes. The user implements render_background() for custom drawing; children are composited on top in registration order (later on top).

Children keep their positions when the canvas resizes — they are clipped at the canvas bounds.

actor tag Canvas is
  CompositeWidget tag

Implements


Constructors

create

[Source]

new tag create(
  p: WidgetParent tag)
: Canvas tag^

Parameters

Returns


Public Behaviours

add

[Source]

Place a child widget at (x, y) with the given size. The child is resized to (w, h) when the canvas receives its own resize. Later-added children draw on top of earlier ones.

be add(
  widget: Widget tag,
  x: USize val,
  y: USize val,
  w: USize val,
  h: USize val)

Parameters


move

[Source]

Reposition a child widget. Size is unchanged.

be move(
  widget: Widget tag,
  x: USize val,
  y: USize val)

Parameters


resize

[Source]

Update canvas size and re-render. Children keep their fixed sizes and positions — they are clipped at the new bounds.

be resize(
  w: USize val,
  h: USize val)

Parameters


receive_grid

[Source]

be receive_grid(
  widget: Any tag,
  grid: Grid val)

Parameters


trigger_render

[Source]

be trigger_render()

receive_key

[Source]

be receive_key(
  key: KeyEvent val)

Parameters


receive_focus

[Source]

be receive_focus()

receive_blur

[Source]

be receive_blur()

set_debug_bg

[Source]

be set_debug_bg(
  color: (Default val | Black val | Red val | 
    Green val | Yellow val | Blue val | 
    Magenta val | Cyan val | White val | 
    BrightBlack val | BrightRed val | BrightGreen val | 
    BrightYellow val | BrightBlue val | BrightMagenta val | 
    BrightCyan val | BrightWhite val | Rainbow val))

Parameters


Public Functions

state

[Source]

fun ref state()
: WidgetState ref

Returns


render

[Source]

Render background, then blit each child at its (x, y) position. Children are composited in registration order (later on top). Clipped at canvas bounds.

fun ref render()
: Grid val

Returns


render_background

[Source]

fun ref render_background()
: Grid val

Returns


register_child

[Source]

fun ref register_child(
  widget: Widget tag)
: None val

Parameters

Returns


render_and_send

[Source]

fun ref render_and_send()
: None val

Returns