Guide API
Skip to main content

Module theme

Module theme 

Source
Expand description

Theming: a Role → Style map plus a Glyphs holder.

Every widget asks the Theme for colours by semantic role rather than a raw colour — a frame draws with ctx.theme.style(Role::FrameActive), a button with Role::ButtonNormal, and so on — and reaches drawing glyphs (frame corners, scrollbar arrows, check/radio marks, shadows) through Glyphs. Swapping themes (or editing a single role) recolours the whole UI at once.

Role is a first-party closed enum: third parties do not add roles. It covers the frames (active/passive/dragging), the normal/focused/disabled/pressed control quartet, the list-state matrix, and the per-widget families (buttons, labels, menus, the status line, …).

Guide: Theming & colors.

§Turbo Vision heritage

The original framework resolved colours by walking an owner chain of length-prefixed palette strings and scattered drawing glyphs as literals through the widget source. tvision-rs collapses both into one Theme keyed by a semantic Role (deviation D7); each original colour lookup maps to one named role here.

Structs§

Glyphs
Holder for the framework’s drawing glyphs — frame corners/tee-connectors, scrollbar arrows, check/radio marks, shadows, window decorations.
SurfaceRoles
The role triple a focusable content widget paints its surface from, consumed by DrawCtx::content_surface (three-surface rule).
Theme
A theme: a fixed Role → Style map plus a Glyphs holder.

Enums§

Role
A semantic colour role — the key a widget uses to ask the Theme for a Style.