Skip to main content

Module theme

Module theme 

Source
Expand description

Theme tokens of the UI refresh; read only by ui_kit and its preview so far. Theme tokens: the one place a colour, size, radius, shadow or duration of the refreshed UI is written (section 3).

STATUS: rollout step 1. Nothing in the app reads these tokens except the developer gallery (crate::ui_kit::gallery) and its whole-app PREVIEW, which is off unless the gallery turns it on. With the gallery closed and the preview off the app makes no call into this module.

A Theme is built per mode (dark, light), density (compact, comfortable) and accent. Theme::apply writes it into an egui::Style, which restyles every default egui widget; the crate::ui_kit components read the tokens directly through Theme::of.

Modules§

radius
Corner radii (spec section 3).
space
The 4 px spacing scale (spec section 3).

Structs§

Accent
One accent the owner can choose between (spec section 9, decision 2).
Families
The font families the theme draws with. Until a UI font is chosen and bound (spec section 9, decision 1) all three are egui’s own families, so a theme can always be drawn.
Palette
The colour roles (spec section 3). Every colour is opaque except the three overlays, which are laid over whatever surface the control sits on.
Theme
One theme: every token a component or the base egui style needs.

Enums§

Density
Control heights and spacing. Compact is the proposed default (spec section 2).
Mode
Dark or light chrome. The 3D viewport’s colours are render settings and are not part of the theme.
Text
The type scale (spec section 4).

Constants§

ACCENTS
The accent candidates. The first is the spec’s proposal.
BORDER
Every border is 1 px; a focus ring or an active bar is 2 px.
RING

Functions§

accent
The accent with this key.
classic_bar_metrics
The control metrics the top toolbar and the status bar were laid out with before the theme (ClassicMetrics, whatever the density). The shell draws those two bars with them until the chrome migration (rollout step 4) gives them token metrics: their heights place the 3D view, and every script that clicks in the view pins that rectangle. Colours, radii and fonts are the theme’s. On a touch browser the touch layer’s sizes are left alone.
clear
Forget the stored theme.
contrast
WCAG contrast ratio of two opaque colours (1 to 21).
current
The stored theme, or the default.
install
Make the Appearance settings the app’s style (rollout step 2): write the tokens into the context’s dark and light styles when a setting changed, and store the theme of the mode now showing for the ui_kit components. Called once per frame, before any panel draws; a frame with nothing changed only compares three values.
luminance
WCAG relative luminance of an opaque colour.
mix
a moved t of the way to b (both opaque).
over
top laid over the opaque base at top’s own alpha.
set
Make theme the one Theme::of answers for this context.
stored
The stored theme, if one is stored.