Kleidos API Search

In development. It changes without notice.

Topic

Reusable Widgets

A scrolling menu that every board drives with its own inputs, and the header's chip that says the clock is not set.

Files

file src/ui/widgets/clock_chip.h
Shared "clock not set" header warning chip (gate + placement).
file src/ui/widgets/on_device_menu.h
Scrollable on-device menu system with multi-input navigation.

Classes

struct kleidos::MenuItem
One menu item entry. More about kleidos::MenuItem
class kleidos::OnDeviceMenu
Scrollable on-device menu: manages scrolling, selection, and rendering. More about kleidos::OnDeviceMenu

Enumerations

enum class kleidos::MenuItemType : uint8_t { kleidos::MenuItemType::ACTION, kleidos::MenuItemType::TOGGLE, kleidos::MenuItemType::VALUE, kleidos::MenuItemType::SUBMENU, kleidos::MenuItemType::BACK }
Menu item action types. More about kleidos::MenuItemType
enum class kleidos::MenuAction : uint8_t { kleidos::MenuAction::NONE , kleidos::MenuAction::SELECT , kleidos::MenuAction::BACK , kleidos::MenuAction::SCROLL }
Result of a menu interaction for a single frame. More about kleidos::MenuAction

Functions

int16_tkleidos::ui::clockChipReserve (Canvas &canvas, const LayoutContext &layout)
Width (px) the "clock not set" chip needs, or 0 when the clock is trusted.
int16_tkleidos::ui::clockChipGlyphReserve (Canvas &canvas, const LayoutContext &layout)
Width (px) the chip needs as its clock glyph alone, or 0 when the clock is trusted.
int16_tkleidos::ui::drawClockUnsetChip (Canvas &canvas, const LayoutContext &layout, int16_t packRight, int16_t headerH)
Draw the "clock not set" chip packed against a right boundary.
int16_tkleidos::ui::drawClockUnsetChip (Canvas &canvas, const LayoutContext &layout, int16_t packRight, int16_t headerH, int16_t reserve)
Draw the chip from a precomputed clockChipReserve result.

Enumeration Type Documentation

MenuAction #

enum class kleidos::MenuAction : uint8_t

Result of a menu interaction for a single frame.

Enumerator
NONE 

No action this frame.

SELECT 

User activated the selected item.

BACK 

User pressed back.

SCROLL 

Selection changed (for redraw).

MenuItemType #

enum class kleidos::MenuItemType : uint8_t

Menu item action types.

Enumerator
ACTION 

Triggers a callback when selected.

TOGGLE 

Shows on/off state, toggles on select.

VALUE 

Shows a value string (read-only or leads to sub-menu).

SUBMENU 

Opens another menu.

BACK 

"Back" item, drawn with a leading chevron

Function Documentation

clockChipGlyphReserve() #

int16_t kleidos::ui::clockChipGlyphReserve(Canvas & canvas, const LayoutContext & layout)

Width (px) the chip needs as its clock glyph alone, or 0 when the clock is trusted.

The narrower form a header takes where the worded chip would leave its title no room to read (ui::HeaderProps::titleReserveRightCompact): the Sticks' 135 px bar with "Einstellungen" beside "PONER".

Parameters
NameDirectionMeaning
canvasinSurface (for measurement).
layoutinResponsive context (resolved spacing/fonts).
Returns
Chip width in pixels; 0 when no chip will be shown.

clockChipReserve() #

int16_t kleidos::ui::clockChipReserve(Canvas & canvas, const LayoutContext & layout)

Width (px) the "clock not set" chip needs, or 0 when the clock is trusted.

Pass the result to ui::HeaderProps::titleReserveRight so ui::drawHeader keeps the title clear of the chip drawn afterwards by drawClockUnsetChip.

Parameters
NameDirectionMeaning
canvasinSurface (for label measurement).
layoutinResponsive context (resolved spacing/fonts).
Returns
Chip width in pixels; 0 when no chip will be shown.

drawClockUnsetChip() [1/2] #

int16_t kleidos::ui::drawClockUnsetChip(Canvas & canvas, const LayoutContext & layout, int16_t packRight, int16_t headerH)

Draw the "clock not set" chip packed against a right boundary.

The chip's right edge lands on packRight (the caller's title-clamp boundary: for ui::drawHeader callers the returned cluster-left edge, which already includes the pack gap; hand-drawn headers pass their leftmost status token's left edge minus their gap). Vertically centered in a bar of height headerH. No-op while the clock is trusted.

Parameters
NameDirectionMeaning
canvasin, outDrawing surface.
layoutinResponsive context (carries the device profile).
packRightinRight edge (px) the chip packs against.
headerHinHeader bar height (px) the chip centers within.
Returns
The chip's left edge in pixels, or packRight when nothing was drawn — always a valid right clamp boundary for the caller's title.

drawClockUnsetChip() [2/2] #

int16_t kleidos::ui::drawClockUnsetChip(Canvas & canvas, const LayoutContext & layout, int16_t packRight, int16_t headerH, int16_t reserve)

Draw the chip from a precomputed clockChipReserve result.

Same drawing contract as the simple overload, but the trust gate and chip width are taken from reserve instead of being re-evaluated, so a caller that already measured the reserve for its title clamp (the header of the Sticks) evaluates trust + width exactly once per paint — a trust flip between the two computations cannot produce a one-frame reserve/draw mismatch.

Parameters
NameDirectionMeaning
canvasin, outDrawing surface.
layoutinResponsive context (carries the device profile).
packRightinRight edge (px) the chip packs against.
headerHinHeader bar height (px) the chip centers within.
reserveinChip width from clockChipReserve, or from clockChipGlyphReserve for the glyph alone; <= 0 draws nothing.
Returns
The chip's left edge in pixels, or packRight when nothing was drawn — always a valid right clamp boundary for the caller's title.