Expand description
Passive, atomic meter compositions over a single caller telemetry snapshot.
Label, display and status are mandatory complete caller-authored copy. Display is never parsed or replaced with a computed percentage: it may deliberately show a countdown while the fraction shows energy. The caller owns this relationship, localization, precision and meaningful known/empty/unknown wording. No gameplay availability, input registration, animation or smoothing is added. Rebuild after accepted ticks; reuse the same snapshot during pause.
Text wraps at fixed theme sizes (no shadows, shrink or ellipsis). Every block and mark must fit the supplied logical bounds or construction fails. The caller must reserve these bounds within its viewport/safe area and any outer clips; an outer clip can still hide an otherwise valid composition. Static patterns supplement hue: known fills have canvas dots, Empty a dash, Unknown three separated vertical bars. All three retain explicit caller status text.
use ferravex_play::ui::{meters::*, theme::*};
use ferravex_render::ui::{Ui, UiRect, Viewport, meters::*};
let viewport = Viewport::responsive([352., 400.], [8., 12., 8., 12.])?;
let layout = MeterLayout::meter(viewport.bounds().inset([16.; 4])?,
MeterCopy { label: "BOOST", display: "ENERGY 050%", status: "COOLING 1.2s" },
MeterValue::Known { current: 0.5, capacity: 1. },
&[Threshold { fraction: 0.25, label: "REARM >25%" }],
UiTheme::preset(ThemeMode::Normal))?;
let mut ui = Ui::new();
ui.set_inspection_enabled(true);
ui.begin(viewport);
layout.draw(&mut ui)?; // Also: layout.submit(group) inside a larger compose.
ui.finish(true);
assert!(ui.inspect().unwrap().all(|e| !e.interaction_registered));
ui.paint();Structs§
- Meter
Copy - Mandatory nonblank text, borrowed unchanged. Unsupported bitmap glyphs retain
complete inspection copy but use the existing font’s
?painting fallback. - Meter
Layout - Checked borrowed composition with fixed arrays, no retained clock or cache. Reset is replacement from a new caller snapshot; no prior state can reappear.
- Meter
Regions - Shared logical rectangles used for retained paint/inspection. A future input adapter can consume them explicitly; these passive meters register no hits.
- Threshold
- Explicit normalized threshold and complete description. Its text is placed in a separate row below the track, in caller order, never over a tiny fill. Duplicate/unsorted thresholds are allowed; the caller owns their meaning.
Constants§
- MAX_
METER_ BYTES - A bounded total source budget including threshold labels (UTF-8 bytes).