Skip to content

CompositeWidget

[Source]

A widget that contains child widgets. Extends Widget with child grid storage, compositing, and resize propagation.

Uses dirty-flag coalescing: when a child grid arrives, the grid is stored and the widget marks itself dirty. A deferred self-message triggers the actual recompose. Multiple grids arriving in quick succession are batched into a single render pass.

The user implements state(). Override render_background() to draw custom content behind children (default is an empty grid). Override render() for custom child compositing (e.g. HBox/VBox).

trait tag CompositeWidget is
  Widget tag,
  WidgetParent tag

Implements


Public Behaviours

receive_grid

[Source]

Receive a child's grid and store it. Only updates grids for children previously registered via register_child, pack_start/pack_end, or set_child. Unknown senders are ignored.

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

Parameters


resize

[Source]

Update size, propagate resize to all children, and re-render.

be resize(
  w: USize val,
  h: USize 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

render_background

[Source]

Produce the background grid before children are composited on top. Default: empty grid using the widget's debug_bg color.

fun ref render_background()
: Grid val

Returns


register_child

[Source]

Register a child widget. Required before the child can send grids or receive resize propagation. Call from the constructor after creating child widgets.

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

Parameters

Returns


render

[Source]

Render background, then overlay all child grids on top. Non-empty cells from children overwrite the background.

fun ref render()
: Grid val

Returns


state

[Source]

fun ref state()
: WidgetState ref

Returns


render_and_send

[Source]

fun ref render_and_send()
: None val

Returns