abstract class
TUI::Widget
- TUI::Widget
- Reference
- Object
Direct Known Subclasses
- TUI::Form::FormFieldCell(M)
- TUI::Form::Host(M)
- TUI::Grid
- TUI::HSplit
- TUI::Popup
- TUI::SplitWindow
- TUI::Window
Defined in:
tui/widget/widget.crConstructors
Instance Method Summary
-
#absolute(row : Int32, col : Int32) : NamedTuple(row: Int32, col: Int32)
Translate a LOCAL (row, col) offset — as used by
#render's own coordinate space, e.g. -
#composite(screen : Screen) : Nil
Called by the compositor (App) once per frame instead of
#render. -
#focus_if(condition : Bool) : Nil
The recommended way to manage focus when multiple widgets are visible at once: recompute it every frame from whatever state determines which widget is active (e.g.
- #focused=(focused : Bool)
- #focused? : Bool
-
#handle_key(ev : KeyEvent) : Bool
Returns true if the key was consumed.
- #height : Int32
- #height=(height : Int32)
-
#local(row : Int32, col : Int32) : NamedTuple(row: Int32, col: Int32)
Inverse of #absolute: translate an ABSOLUTE 1-based terminal coordinate (e.g.
-
#render : Nil
Draw into @buffer using LOCAL coordinates (0, 0 = this widget's own top-left).
-
#render_to(buffer : Buffer) : Nil
Draws this widget into an arbitrary caller-supplied buffer instead of the screen — for a host that owns its own composed buffer rather than the real screen (e.g.
-
#status_hint : String
Plain text describing the actions available in the widget's current state.
- #width : Int32
- #width=(width : Int32)
-
#x : Int32
1-based absolute terminal coordinates and size of this widget within the compositor (see #composite/Screen#blit) — never touched by the widget's own #render, which always draws in its own local (0, 0) space.
-
#x=(x : Int32)
1-based absolute terminal coordinates and size of this widget within the compositor (see #composite/Screen#blit) — never touched by the widget's own #render, which always draws in its own local (0, 0) space.
- #y : Int32
- #y=(y : Int32)
Constructor Detail
Instance Method Detail
Translate a LOCAL (row, col) offset — as used by #render's own
coordinate space, e.g. Form#cursor_offset — into absolute
1-based terminal coordinates suitable for Term.move. Mirrors the
arithmetic #composite already performs internally via Screen#blit.
Called by the compositor (App) once per frame instead of #render.
Owns the buffer lifecycle: resizes/clears it, invokes the subclass's
#render, then blits the result onto the screen at (x, y).
The recommended way to manage focus when multiple widgets are visible
at once: recompute it every frame from whatever state determines which
widget is active (e.g. table_list.focus_if(nav.current.is_a?(NavTableList)))
rather than mutating #focused= incrementally at scattered call sites.
Inverse of #absolute: translate an ABSOLUTE 1-based terminal coordinate (e.g. a KeyEvent's mouse row/col) into this widget's LOCAL coordinate space. Result may fall outside [0, width)/[0, height) if the point is outside this widget's bounds — callers should bounds-check.
Draw into @buffer using LOCAL coordinates (0, 0 = this widget's own
top-left). Widgets never need to know their own x/y offset to draw
themselves — that arithmetic is handled entirely by #composite.
Draws this widget into an arbitrary caller-supplied buffer instead
of the screen — for a host that owns its own composed buffer rather
than the real screen (e.g. ScrollableWidget, adapting a plain
Widget into a SplitWindow pane, which only blits Scrollable content
into a sub-buffer it controls). buffer must already be sized to
width/height; unlike #composite this never blits anywhere itself,
leaving that to the caller.
Plain text describing the actions available in the widget's current state. Rendered by the App in the global status bar at the bottom of the screen — widgets must NOT draw their own hint lines.
1-based absolute terminal coordinates and size of this widget within
the compositor (see #composite/Screen#blit) — never touched by the
widget's own #render, which always draws in its own local (0, 0)
space. #focused? gates whether this widget's #handle_key should be
given a chance to consume the current event; toggle it via #focus_if.
1-based absolute terminal coordinates and size of this widget within
the compositor (see #composite/Screen#blit) — never touched by the
widget's own #render, which always draws in its own local (0, 0)
space. #focused? gates whether this widget's #handle_key should be
given a chance to consume the current event; toggle it via #focus_if.