pub struct Theme {
pub title_font: Font,
pub type_font: Font,
pub pin_font: Font,
pub pin_subtitle_font: Font,
pub tag_font: Font,
pub route_font: Font,
font_sizes: FontSizes,
palette: Palette,
tones: [Swatch; 84],
}Fields§
§title_font: Font§type_font: FontA block’s type label, drawn slightly smaller than title_font.
pin_font: Font§pin_subtitle_font: FontSecond line of a pin/port name, drawn smaller than pin_font.
tag_font: Font§route_font: Font§font_sizes: FontSizesThe sizes the six font fields above were built from, so the font editor
can read them back and re-derive the Fonts on a change.
palette: PaletteThe 16 base colors every role resolves into.
tones: [Swatch; 84]Role → Swatch mapping (base slot + alpha), indexed by role as usize.
Implementations§
Source§impl Theme
impl Theme
Sourcepub fn editor_colors(&self, ink: Role, fill: Role) -> EditColors
pub fn editor_colors(&self, ink: Role, fill: Role) -> EditColors
The concrete color for a role: its Swatch resolved against the
palette. Role::Transparent and any role mapped to None resolve to a
fully transparent color. For code that paints outside the
Renderer API — the shell’s chrome, the theme
editor’s and role picker’s swatches; the render path passes a
Swatch/PaletteStroke to the canvas instead.
The colours an in-place editor is painted in: ink and fill for
the text and its field — the editor’s own roles, or the roles of the
label it replaces — and the caret, selection, hint and border every
editor shares.
pub fn resolve(&self, role: Role) -> Color
Sourcepub fn swatch(&self, role: Role) -> Swatch
pub fn swatch(&self, role: Role) -> Swatch
The palette Swatch a role resolves to (its base slot plus alpha).
Role::Transparent is always the transparent swatch. This is the
hand-off point to the palette-based canvas: app roles become swatches
here, and the renderer turns swatches into colors.
Sourcepub fn palette(&self) -> &Palette
pub fn palette(&self) -> &Palette
The palette backing this theme, which the shell also derives the host’s own widget colors from.
Sourcepub fn set_palette(&mut self, palette: Palette)
pub fn set_palette(&mut self, palette: Palette)
Swap the backing palette (e.g. when the user picks a different scheme).
The role → base tones table is palette-independent, so every role
restyles at once.
Sourcepub fn base_of(&self, role: Role) -> Option<Base>
pub fn base_of(&self, role: Role) -> Option<Base>
The palette slot a role resolves through, or None if it draws nothing
(transparent). Alpha is ignored here.
Sourcepub fn set_base(&mut self, role: Role, base: Option<Base>)
pub fn set_base(&mut self, role: Role, base: Option<Base>)
Repoint a role at a different palette slot (or None for transparent),
preserving its alpha. Role::Transparent is fixed, so it is untouched.
Sourcepub fn overrides(&self) -> IndexMap<Role, Option<Base>>
pub fn overrides(&self) -> IndexMap<Role, Option<Base>>
The full role → base mapping, in declaration order, excluding
Role::Transparent (which is always transparent). A role with no base
serializes as null. This is what the theme editor writes to theme.json.
Sourcepub fn font_sizes(&self) -> FontSizes
pub fn font_sizes(&self) -> FontSizes
The active canvas font sizes (px).
Sourcepub fn set_font_sizes(&mut self, fs: FontSizes)
pub fn set_font_sizes(&mut self, fs: FontSizes)
Retune the six canvas fonts to fs (rebuilding each Font) and record
the sizes. The font editor writes these to font_sizes.json on exit.
Sourcefn apply_font_sizes(&mut self, fs: FontSizes)
fn apply_font_sizes(&mut self, fs: FontSizes)
Rebuild the six Font fields from fs and remember the sizes.
Sourcepub fn from_embedded() -> Self
pub fn from_embedded() -> Self
The compile-time default theme: Theme::default (fonts, alphas, and a
fallback base for every role) with the role → base overrides from the
embedded theme.json, then the embedded font_sizes.json, layered on
top. A null value maps the role to no color. A malformed file falls back
to the built-in defaults rather than failing to start.