Skip to main content

Theme

Struct Theme 

Source
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: Font

A block’s type label, drawn slightly smaller than title_font.

§pin_font: Font§pin_subtitle_font: Font

Second line of a pin/port name, drawn smaller than pin_font.

§tag_font: Font§route_font: Font§font_sizes: FontSizes

The 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: Palette

The 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

Source

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.

Source

pub fn resolve(&self, role: Role) -> Color

Source

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.

Source

pub fn palette(&self) -> &Palette

The palette backing this theme, which the shell also derives the host’s own widget colors from.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn font_sizes(&self) -> FontSizes

The active canvas font sizes (px).

Source

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.

Source

fn apply_font_sizes(&mut self, fs: FontSizes)

Rebuild the six Font fields from fs and remember the sizes.

Source

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.

Trait Implementations§

Source§

impl Clone for Theme

Source§

fn clone(&self) -> Theme

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Theme

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Theme

§

impl RefUnwindSafe for Theme

§

impl Send for Theme

§

impl Sync for Theme

§

impl Unpin for Theme

§

impl UnsafeUnpin for Theme

§

impl UnwindSafe for Theme

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more