Module ui

Source
Expand description

Quiet, readable overlay helpers shared by the examples.

ButtonOptions separates application selection from interaction focus. Use Ui::button_with_options or Ui::hud_button_with_options for bounded, clipped menus with the existing pointer capture and keyboard/gamepad handling. The free button_with_options helper retains legacy click-on-press behavior.

Modules§

cards
Borrowed menu/result cards in logical UI units, using the existing modal and atomic composition. Pass bounds inside a responsive viewport’s safe area; coordinates start at zero inside that safe area. Absolute task271 rectangles use a zero-inset responsive viewport. Fitted viewports scale logical units and are a caller choice. Fonts never shrink: title 24, body/stats/actions 18, padding 16, section gaps 12, action gaps 8 and action height 44.
inspector
Checked, borrowed authoring controls in logical screen units.
kit
Modern UI kit: cards, buttons, meters, toasts, key caps and screen transitions drawn with crate::shapes and the modern text face.
meters
Passive, atomic meter compositions over a single caller telemetry snapshot.
scroll
A bounded vertical region composed from the existing UiState and Ui.
stats
Measured, bounded label/value lists in logical UI units.
text_layout
Borrowed word wrapping for the UI’s existing 5×7 bitmap font.

Structs§

ButtonOptions
Application-owned button availability and selection. Focus remains owned by Ui; selection never changes tab order, hit regions, or activation. Disabled takes precedence over selected. The default is enabled/unselected.
ButtonStyle
FittedLabel
A borrowed, single-line prefix and static ASCII ellipsis. Draw the two pieces consecutively at the original font size; no temporary String is needed.
TextStyle
Ui
Reuse one instance across frames. Errors reject a command atomically. Budgets: 1024 commands/widgets, 32 KiB UTF-8, 196608 vertices and 16 clip levels.
UiComposition
Restricted drawing/widget submission inside Ui::compose.
UiElement
Borrowed description of one accepted submission, in composition order. Read after finishing layout/input for current focus. Bounds are the exact logical rectangles used by painting/hit testing, before viewport projection. visible_bounds is their positive-area clip intersection, not ink bounds, occlusion, or a promise that truncated/limited text is all painted. Panels, text and gradients are paint only. Earlier modal scopes remain inspectable.
UiInspection
Allocation-free borrowed traversal; obtained only by opting in before Ui::begin. At most 1024 commands plus the latest modal blocker. IDs may repeat across discarded modal scopes; use order and interaction_registered. All borrows expire before another mutable UI operation, including begin.
UiInteraction
Read-only ownership summary for the most recently finished host frame.
UiRect
Viewport
Logical UI units mapped into a safe-area-aware pixel viewport. Self::fit letterboxes a design canvas; Self::responsive keeps one logical unit per host logical pixel and lets layout reflow.

Enums§

Align
Anchor
Placement within a parent; oversized requests shrink to its available extent. Unlike stretched Anchors, this keeps a fixed HUD size whenever it fits.
UiError
UiInspectionExportError
Diagnostic export failure; UI, input and the caller buffer are unchanged.
UiLabel
Complete original UTF-8 copy, or an explicit inspection-only capacity miss. Missing copy never rejects painting/input and is never silently truncated.
UiRole
Semantic kind of an accepted UI submission. Paint-only items have no ID.

Constants§

AMBER
BACKGROUND
CYAN
INK
LINE
MUTED
PANEL

Functions§

button
Click on press; the platform host maps the primary touch to the pointer.
button_with_options
Legacy click-on-press button with an explicit disabled state. Disabled buttons use muted text, ignore hover/selection, and never activate. Enabled buttons keep button’s hit rectangle and appearance. This helper does not own keyboard focus or pointer capture; use Ui for those menus.
fit_label
Fit monospaced text without shrinking its glyphs or allocating. advance is the positive, finite glyph advance, not the font height. The renderer’s bitmap font uses size * 0.75. Unicode scalar values count as one glyph (unsupported glyphs are rendered as ?); UTF-8 is never split. Newlines end the label and signal truncation. A width fitting fewer than three glyphs shows only as many dots as fit; a zero width returns empty pieces. Work is bounded by the visible prefix, even for very long input strings.
header
Compact lab title and controls; dimensions/backend details live in the host.
hud_slots
Reflow equal-width HUD cells left-to-right, then top-to-bottom, without allocation. Each row fits as many min_width cells as possible (at least one), distributing spare width equally. Rows keep height; a narrow viewport shrinks the one column. The last row keeps the same column widths, even when not full. Cells clip to parent, so overflow rows become empty, non-interactive rectangles. This never scales text: combine with fit_label for long labels.
panel
slots
Equal-width/height slots without temporary layout allocations.
stat
warm_up_font
Glyph geometry is static and needs no texture atlas or DPI prewarming.
warm_up_font_sizes

Type Aliases§

WidgetId