Expand description
The kit: palette tokens, one scale, one action sink and one nav map, handed to every control a panel is built from.
A template game’s ui/ module builds the same six things by hand — a chunky
button, a square glyph button, an information chip, a card, a label, a
scrim — and each of them repeats the palette blending and the layout anchor
arithmetic. Kit is that set once: the controls read Tokens and the
frame’s Scale, push into the shared Sink, and register themselves in
the NavMap so arrows, Tab, the D-pad and an analog stick can reach them.
The scale is shared behind a cell, so a game builds the kit once and writes
the new viewport scale each frame (kit.set_scale(scale)) without rebuilding
the kit or the closures it handed out.
ⓘ
let kit = Kit::new(Scale::unit(), Tokens::default(), sink);
// once per frame, before composing:
kit.set_scale(Scale::new(viewport, layout::DESIGN)?);
kit.begin_frame();
// then, per panel:
kit.button("Play", UiAction::Play).view()Structs§
- Button
- A button being configured. Add it to a parent view, which builds it.
- Kit
- The scale, tokens, sink and nav map a panel’s controls are built from.
Constants§
- ICON_
FAMILY - Whether a glyph-font family is registered: the kit’s
iconhelpers needMaterial Symbols Outlinedto have been registered by the game.
Functions§
- overlay_
root - The overlay root: full-screen, and deliberately not focusable.