Skip to main content

Module theme

Module theme 

Source
Expand description

Theme system — dark / light mode colour palettes.

§Overview

Visuals holds every colour used by the widget library. Two built-in palettes are provided via Visuals::dark and Visuals::light.

The current visuals are stored in a thread-local so widgets can access them from paint() without an extra parameter. Call set_visuals once per frame (before painting) to apply a palette; call current_visuals to read it from inside a widget.

DrawCtx::visuals() is a convenience that delegates to current_visuals, so widget paint methods only need ctx.visuals().

Structs§

Visuals
All colours used by the widget library.

Enums§

AccentColor
Built-in accent swatches exposed by the demo and usable by hosts.
ThemePreference
User preference for which palette to apply.

Functions§

current_visuals
Clone and return the active Visuals.
current_visuals_epoch
Current visuals epoch. See [VISUALS_EPOCH] docstring for how the widget layer uses it.
set_visuals
Replace the active Visuals.