Skip to main content

Module widget

Module widget 

Source
Expand description

Widget/StatefulWidget structs: one file per widget, each a builder that owns its own drawing logic.

new() takes only the arguments a widget cannot mean anything without (the content: a value, a label, a slice of samples/rows). Every other knob (styles, offsets, titles) has a default and is set through a chainable #[must_use] fn field(mut self, ...) -> Self method, the same shape as Panel::title or Log::offset. See crates/ui/AGENTS.md for the rule this is enforcing and why.

A few widgets share logic: Gauge and StatBar both delegate to a crate-private bar module, and Sparkline/Gauge/StatBar all use Meter for their ratio-to-color ramp. Paragraph, List, Table, Log, and Panel additionally implement Measure, so a caller can report a height before rendering instead of guessing a fixed height or a full-remaining-space fill: Paragraph reports its wrapped line count (with the egc feature enabled, via retroglyph_core::layout::TextLayout’s grapheme-aware word-wrap, otherwise via its own char-boundary-safe fallback); List/Table/ Log report their item/row/message count directly, since none of them wrap; Panel reports its border-plus-padding chrome height, since it owns no content of its own to measure.

Structs§

AnimatedPerfOverlay
PerfOverlay’s AnimatedWidget counterpart.
BoxBorder
A single-line box border drawn around a Rect.
Button
A filled, centered label, styled by a Response the caller resolves via Interaction::interact (or, through InteractiveWidget, has resolved automatically).
Gauge
A labeled gauge: a label, then a bar filling ratio (0.0-1.0) of the remaining width, colored by super::Meter, with a trailing percentage.
List
A scrollable, single-column list of plain-text items with a ListState-driven highlighted item: Table’s single-column sibling, sharing its windowing and selection story.
Log
The tail of messages that fits in the area it’s rendered into, oldest at top, newest at the bottom, each line clipped to area.width() via PrintLine.
Meter
A load ratio in 0.0..=1.0, mapped to a green→yellow→red color ramp.
Modal
A bordered, filled box centered in a screen Rect.
Panel
A bordered panel: a filled background with a box border and, optionally, one or more titles along the top and/or bottom edge.
PanelTitle
One title added via Panel::add_title: its text, which edge it’s drawn on, and its alignment.
Paragraph
Word-wrapped text in a single Style.
PerfOverlay
A bordered panel showing live FrameStats.
PrintLine
A Line, drawn on the first row of the area it’s rendered into and clipped to area.width() columns. Only the first row is used.
ProgressBar
A horizontal progress bar that fills value / max of the area it’s rendered into.
Scrollbar
A vertical scrollbar (typically one cell wide) covering total_len items in a visible_len-row viewport.
Sparkline
A single-row sparkline of samples, scaled to the sample max, using the eight vertical block glyphs ▁▂▃▄▅▆▇█.
StatBar
A labeled stat bar: label, a bar filling current / max of the remaining width colored by super::Meter, and a trailing "current/max" readout.
Table
A fixed-column, scrollable table with a ListState-driven highlighted row.
Tabs
A horizontal strip of titles with the tab at selected highlighted.
Text
A single line of text in one Style, clipped (not wrapped) to area.width() columns. Only the first row of area is used.
TextInput
A single-line editable text field: the stateless drawing half of TextInputState, the same split List has with ListState.

Enums§

BorderType
The box-drawing glyph set BoxBorder, Panel, and Modal draw their corners and edges with.
HighlightSpacing
Whether List’s highlight_symbol marker column reserves width even when ListState::selected is None.
ListDirection
Which end of a List’s area its items render from.
TitlePosition
Which border edge a PanelTitle is drawn into.

Traits§

AnimatedWidget
Like StatefulWidget, but for widgets whose state evolves with wall-clock time.
InteractiveWidget
A widget that renders itself styled by an already-resolved Response, with the Sense it needs fixed by the widget rather than chosen at the call site.
Measure
A widget that can report the height it needs for a given width, before ever being rendered.
StatefulWidget
Like Widget, but for widgets that read (and may update) externally owned state (a selection index, a scroll offset) that outlives a single render call. See crate::ListState.
Widget
A type that draws itself into a Surface, without retaining any state: the minimal shape shared by every widget-like consumer.