Skip to main content

Theme

Struct Theme 

Source
pub struct Theme { /* private fields */ }
Expand description

A fully resolved theme, ready to style widgets.

Implementations§

Source§

impl Theme

Source

pub fn id(&self) -> &str

The theme id, which is its file stem.

Source

pub fn name(&self) -> &str

The display name from [meta] name.

Source

pub fn color(&self, token: &str) -> Option<Rgb>

A colour token such as "accent".

Source

pub fn solid(&self, expression: &str) -> Result<Rgb, String>

Resolves a colour written the way theme files write it ("$danger", "#38BDF8", "mix($accent, $danger, 50%)") against this theme’s tokens.

§Errors

A message explaining why expression is not a single colour: it does not parse, names an unknown token, or uses pulse(), which breathes and so has no single colour.

Source

pub fn series_color(&self, index: usize) -> Rgb

The tone of the index-th series of a chart, counted from zero.

A theme carries SERIES_COLORS series tones, so the tones wrap around: series five takes the tone of series zero. Wrapping is why a chart must name its series with a Legend instead of leaving the meaning in the colour, and why a chart that needs more than five kinds is better off grouping the small ones together.

Source

pub fn colors(&self) -> impl Iterator<Item = (&str, Rgb)>

Every colour token, sorted by name.

Source

pub fn motion(&self) -> Motion

Motion timing.

Source

pub fn typography(&self, role: &str) -> Option<&StyleProps>

A typography role such as "title".

Source

pub fn icon_set(&self) -> &str

The icon set this theme uses.

Source

pub fn icon_overrides(&self) -> &BTreeMap<String, IconGlyphs>

Icons this theme overrides on top of its icon set.

Source

pub fn animation_overrides(&self) -> &BTreeMap<String, Arc<CellAnimation>>

Animations this theme defines or replaces on top of its icon set’s.

Source

pub fn style( &self, widget: &str, variant: Option<&str>, states: &[State], ) -> StyleProps

The style of widget drawn with variant in states: every matching rule layered from least to most specific.

The result is remembered for the lifetime of the theme, so asking again (as widgets do every frame) is a lookup, and the returned properties share their storage.

Trait Implementations§

Source§

impl Clone for Theme

Source§

fn clone(&self) -> Theme

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Theme

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Theme

Source§

fn eq(&self, other: &Theme) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Theme

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.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.