Expand description
Immediate-mode drawing helpers over a Rect.
Box borders, filled panels, gauges, tables, sparklines, and a small
constraint-based Rect splitter with
ratatui-style Fixed/Percent/Fill/Min/Max constraints and Flex
alignment (layout).
Every widget (widget) is a builder struct that draws itself into a
Grid via Widget/StatefulWidget and
retains no state of its own: state that outlives one render call (a
selection index, a scroll offset, a text field’s value and cursor)
lives in ListState/TextInputState instead. A
handful of things that are genuinely just functions (fill_rect,
thumb_geometry/offset_for_pos in draw; truncate/truncate_owned in
text) stay free functions rather than pretending to be widgets. Three more independent
layers build on top:
Widget/StatefulWidget(widget) render into aSurface, an area-relative, single-layer view over aGrid, and let callers box or store heterogeneous widgets, e.g. aVec<Box<dyn Widget>>of panes to render each frame, with noBackendtype parameter, since drawing touches nothing but cells.AnimatedWidgetisStatefulWidget’s sibling for state that evolves with wall-clock time (e.g.ScrollState’s momentum physics) instead of only in response to input; see its own docs.InteractiveWidgetis the sibling trait for widgets that also read aResponse(Button,Scrollbar,List,Tabs). For a bordered box drawn straight into thatSurface– with titles,BorderTypeglyph sets,padding, and theming – reach forPanelfirst; it’s the default answer to “draw me a box”.Interaction(interact) for hover/click/drag/focus tracking without a retained widget tree: the sibling ofListStatefor widgets that don’t have a natural selection index of their own.Uipairs one frame’sSurfacewith anInteraction, viaInteraction::frame:Ui::showis how anInteractiveWidgetgets hit-tested and drawn from the one area/id a call site names.BoxStyle(style) is the standalone alternative toPanel: a Lip-Gloss-style box model (padding, border, margin) rendered into its ownGrid, independent of anySurface/Backend/Terminal. Reach for it instead ofPanelwhen composing a box outside a frame, laying several boxes out withjoin_h/join_vbelow, or needingmargin(space outside the border, whichPanelhas no concept of); it has no titles,BorderType, or theming.join_h/join_v(block) to compose severalGrids (e.g.BoxStyle::renderoutput) into one;retroglyph_core::surface::Surface::blitstamps the result onto a surface.Theme(theme) for named color roles (an app picksTheme::DARK/Theme::LIGHT, or builds its own), independent of how the app decides which one is active.HalfBlockCanvas/QuadrantCanvas/SextantCanvas/BrailleCanvas(canvas) for sub-cell drawing: plot points at higher-than-one-per-cell resolution, then read a frame’s worth of glyphs back out, one per cell.
This crate is itself optional: games that draw manually depend only on
retroglyph-core.
This crate is no_std-compatible: disable the std feature and enable libm instead (also
requires an allocator). See the std and libm features below.
§Features
Default features: std.
§dev
⚪ Optional.
Forwards retroglyph-core’s dev feature, which forces development diagnostics on in a build
that would otherwise compile them out (see retroglyph_core::dev).
§egc
⚪ Optional.
Forwards to retroglyph-core’s egc feature.
Upgrades Paragraph’s word-wrap (always available) to grapheme-cluster-aware correctness.
§libm
⚪ Optional.
Uses retroglyph-core’s libm feature (the no_std float backend: easing curves and
tweens, scrollbar geometry, gauge/sparkline/bar percentage rounding, scroll momentum decay)
instead of std’s own float intrinsics. See std below; a build needs exactly one of the two.
§serde
⚪ Optional.
Adds Serialize/Deserialize impls for Theme and Density, forwarding to
retroglyph-core’s serde feature.
Theme round-trips through Color’s own serde impl.
§std
🟢 Enabled by default.
Enables retroglyph-core/std, whose float intrinsics back this crate’s own float use (see
libm above for the no_std alternative).
Disabling this feature (--no-default-features) builds this crate no_std (requires an
allocator and one of std/libm; see the crate-level compile_error! in src/lib.rs).
§testing
⚪ Optional.
Enables testing’s WidgetHarness, the sibling of retroglyph-core’s
testing::TestHarness for driving a bare Interaction<Id>/Ui (no App required) against
Headless for tests, with synthetic input queuing and a step that drains it.
Test-only surface, off by default so it never ships in a release build by accident. Headless
is unconditionally available in retroglyph-core, so this needs no feature forwarding there.
Modules§
- align
Align: horizontal alignment of a single line of text within a fixed-width area.- animate
- Time-driven value animation: easing curves, a stateful
Tween, and a periodic oscillator. - block
- Compose
Gridvalues before drawing them. - camera
- A scrolling viewport into a world larger than the screen. A scrolling viewport into a world larger than the screen.
- canvas
- Sub-cell drawing: plot points/pixels at higher-than-one-per-cell resolution and read them
back as glyphs, via
retroglyph_core::symbols’s quantizers. Sub-cell drawing: a buffer to plot into before there are pixels to posterize. - draw
fill_rectandthumb_geometry/offset_for_pos: the handful of things genuinely useful as standalone functions rather thanWidgets.- interact
- Pointer and keyboard focus tracking for interactive widgets, without a retained widget tree.
- layout
- Constraint-based
Rectsplitter for multi-panel UIs. - state
- Reusable widget state, kept separate from drawing.
- style
BoxStyle: a Lip-Gloss-style box model (padding, border, margin).- testing
- Headless widget-level test harness:
WidgetHarnessdrives a bareInteraction<Id>/UiagainstHeadless, without anApp. - text
- Single-line column-clipping, unicode-width aware.
- theme
Theme: named color roles for a light/dark-aware app.- ui
Ui: one frame’sSurfaceandInteractionpaired, so a call site names anarea/idonce and gets both hit-testing and drawing from it.- widget
Widget/StatefulWidgetstructs: one file per widget, each a builder that owns its own drawing logic.
Structs§
- Styled
Surface - A
Surfacewith aStylebound in, returned bySurface::with_style. - Surface
- The render target for every drawing call in the workspace: a mutable reference to a
Gridplus a fixedlayer, scoped to anareaand clipped to acliprect.
Enums§
- Layer
- A named z-order tier for
Surface::on_tier, covering the split most apps with overlapping UI actually need.