CompositeWidget¶
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).
Implements¶
- Widget tag
- WidgetParent tag
Public Behaviours¶
receive_grid¶
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.
Parameters¶
resize¶
Update size, propagate resize to all children, and re-render.
Parameters¶
trigger_render¶
receive_key¶
Parameters¶
- key: KeyEvent val
receive_focus¶
receive_blur¶
set_debug_bg¶
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¶
- 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)
Public Functions¶
render_background¶
Produce the background grid before children are composited on top. Default: empty grid using the widget's debug_bg color.
Returns¶
- Grid val
register_child¶
Register a child widget. Required before the child can send grids or receive resize propagation. Call from the constructor after creating child widgets.
Parameters¶
- widget: Widget tag
Returns¶
- None val
render¶
Render background, then overlay all child grids on top. Non-empty cells from children overwrite the background.
Returns¶
- Grid val
state¶
Returns¶
- WidgetState ref
render_and_send¶
Returns¶
- None val