Skip to main content

Crate retroglyph_widgets

Crate retroglyph_widgets 

Source
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) lives in ListState instead. A handful of things that are genuinely just functions (fill_rect, thumb_geometry/offset_for_pos) stay free functions in draw rather than pretending to be widgets. Three more independent layers build on top:

  • Widget/StatefulWidget (widget) render into a Surface, an area-relative, single-layer view over a Grid, and let callers box or store heterogeneous widgets, e.g. a Vec<Box<dyn Widget>> of panes to render each frame, with no Backend type parameter, since drawing touches nothing but cells.
  • Interaction (interact) for hover/click/drag/focus tracking without a retained widget tree: the sibling of ListState for widgets that don’t have a natural selection index of their own.
  • BoxStyle (style) for a Lip-Gloss-style box model (padding, border, margin) rendered into a standalone Grid.
  • join_h/join_v (block) to compose several Grids (e.g. BoxStyle::render output) into one before drawing it.
  • Theme (theme) for named color roles (an app picks Theme::DARK/Theme::LIGHT, or builds its own), independent of how the app decides which one is active.

This crate is itself optional: games that draw manually depend only on retroglyph-core.

Re-exports§

pub use align::Align;
pub use block::blit_into;
pub use block::join_h;
pub use block::join_v;
pub use draw::fill_rect;
pub use draw::offset_for_pos;
pub use draw::thumb_geometry;
pub use interact::DEFAULT_DRAG_THRESHOLD;
pub use interact::Density;
pub use interact::FocusRing;
pub use interact::HitTester;
pub use interact::Interaction;
pub use interact::Pointer;
pub use interact::Response;
pub use interact::Sense;
pub use interact::Shortcuts;
pub use layout::Constraint;
pub use layout::Flex;
pub use layout::centered_rect;
pub use layout::split_h;
pub use layout::split_h_flex;
pub use layout::split_h_spaced;
pub use layout::split_v;
pub use layout::split_v_flex;
pub use layout::split_v_spaced;
pub use state::ListState;
pub use state::ScrollPhysics;
pub use state::ScrollState;
pub use state::SelectionWrap;
pub use style::BoxStyle;
pub use style::Sides;
pub use text::truncate;
pub use text::truncate_owned;
pub use theme::Theme;
pub use widget::Paragraph;egc
pub use widget::BoxBorder;
pub use widget::Button;
pub use widget::Gauge;
pub use widget::List;
pub use widget::Log;
pub use widget::Measure;
pub use widget::Meter;
pub use widget::Modal;
pub use widget::Panel;
pub use widget::PrintLine;
pub use widget::ProgressBar;
pub use widget::Scrollbar;
pub use widget::Sparkline;
pub use widget::StatBar;
pub use widget::StatefulWidget;
pub use widget::Table;
pub use widget::Tabs;
pub use widget::Text;
pub use widget::Widget;

Modules§

align
Align: horizontal alignment of a single line of text within a fixed-width area.
block
Compose Grid values before drawing them.
draw
fill_rect and thumb_geometry/offset_for_pos: the handful of things genuinely useful as standalone functions rather than Widgets.
interact
Pointer and keyboard focus tracking for interactive widgets, without a retained widget tree.
layout
Constraint-based Rect splitter for multi-panel UIs.
state
Reusable widget state, kept separate from drawing.
style
BoxStyle: a Lip-Gloss-style box model (padding, border, margin).
text
Single-line column-clipping, unicode-width aware.
theme
Theme: named color roles for a light/dark-aware app.
widget
Widget/StatefulWidget structs: one file per widget, each a builder that owns its own drawing logic.

Structs§

StyledSurface
A Surface with a Style bound in, returned by Surface::with_style.
Surface
The render target for every drawing call in the workspace: a mutable reference to a Grid plus a fixed layer, scoped to one area.