Skip to main content

Module theme

Module theme 

Source
Expand description

The colours: light and dark, three contrast levels, an accent of the user’s.

A theme is a grid. Its rows are Tones — lightness levels from the sunken background to strong text — and its columns are Swatches, each a hue and a chroma. Every colour is one cell, so every colour, the accent and the status colours alike, takes its lightness from where it is used: switching light and dark, or the contrast, carries all of them with it.

The lightness is OKLCH’s, which follows perceived lightness: one tone gives about the same contrast whatever the hue.

Structs§

Theme
The colours of one theme: every Tone of every Swatch, worked out when built.
ThemeSettings
What the user chose: what the app saves, and hands to install at start.
TintPicker
Picks a Tint: a palette (Default, the theme’s swatches, Random) over a disk of hues around and chromas outwards, and optionally a preview of the tint in use.

Enums§

Contrast
How far apart the text and the background are.
Swatch
A hue and a chroma. Red to Purple line up with Base16’s base08 to base0E.
Tint
A colour with no lightness of its own: where it is used decides that.
Tone
A lightness level, from the background side to the text side.

Functions§

current
The theme ctx draws with now: the dark or the light one, as egui’s theme is. Before install, the default settings’ (egui’s own look is left as it is).
install
Use settings in ctx: build the light and the dark theme, give egui both looks, and follow settings.preference. Call it at start and whenever the settings change.
is_installed
Whether install has been called on ctx.
settings_ui
Light / dark / system, the contrast, and the accent (a TintPicker with its preview). A change is installed at once, so dragging on the accent’s disk previews live; true comes once the change is made — a click, or the end of a drag — so save settings then.