Skip to main content

Themes

Struct Themes 

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

The themes known: the built-in ones and any added.

Implementations§

Source§

impl Themes

Source

pub fn add_kit(&mut self, kit: &KitData) -> Option<TokenFile>

Adds a kit’s theme (replacing a theme of the same name, returned), and its other variant’s when it has one. Its faces and handlers are installed by egui_pop_core::kit::KitSource or AppBuilder::kit.

Source§

impl Themes

Source

pub fn add(&mut self, theme: TokenFile) -> Option<TokenFile>

Adds a theme, or replaces the one of the same name (returned).

Source

pub fn add_text( &mut self, name: &str, text: &str, ) -> Result<Vec<Warning>, Error>

Reads a theme file (YAML or JSON, TokenFile::parse) and adds it under name, loaded over its base theme (Themes::check_file). Only a file that cannot be read at all is an error; what was read otherwise than written comes back as warnings.

A file carrying its counterpart (COUNTERPART_EXTENSION) adds it too, under its own name and through the same rule; a counterpart that cannot be read is a warning, the file’s own variant added alone.

Source

pub fn add_path( &mut self, name: &str, path: &Path, ) -> Result<Vec<Warning>, Error>

Reads a theme file from disk (a user’s theme) and adds it under name, as Themes::add_text does. Its YAML goes through the default cache (crate::cache): read again unchanged, it is not parsed again, and the loading rule still runs, so its warnings are the same on a hit.

Source

pub fn add_path_with( &mut self, name: &str, path: &Path, cache: &Cache, ) -> Result<Vec<Warning>, Error>

Themes::add_path through a given cache. An entry that cannot be written is a Warning::NotCached: the file is read all the same.

Source

pub fn check_file(&self, file: TokenFile) -> (TokenFile, Vec<Warning>)

Loads a theme file over its base theme (its $extends, else FALLBACK_THEME), the rule every theme file goes through: the file is brought to the current contract (TokenFile::upgrade), a seed that cannot be read (crate::palette::SEEDS_EXTENSION) is left out, then a token whose value does not load (an unreadable value, an alias to nothing or in a cycle, another type than the base’s or the contract’s) is left out, so the base theme’s value stays. A token the base does not have is kept as the file’s own (a palette, an extension’s component); under a group of the contract, with a term no token of the base uses, it is reported as a likely typo. Nothing here fails: each such thing is a Warning. A base not known yet leaves the tokens unchecked.

Source

pub fn set_density(&mut self, density: Density, overlay: TokenFile)

Replaces a density’s overlay.

Source

pub fn get(&self, name: &str) -> Option<&TokenFile>

Source

pub fn counterpart_of(&self, name: &str) -> Option<&str>

The other variant of a theme, as the token files say (VARIANT_OF_EXTENSION): the theme its own file names, else the first theme (by name) naming it. Only a known theme other than itself counts.

Source

pub fn counterpart(&self, spec: &ThemeSpec) -> Option<String>

The counterpart a spec asks for (ThemeSpec::counterpart): a known theme other than the base, or none.

Source

pub fn resolve_counterpart(&self, spec: &ThemeSpec) -> Option<ResolvedTokens>

Resolves a spec’s counterpart, if it has one (Themes::counterpart), with the spec’s density, accent, reduced motion and overrides, or the counterpart’s own overrides (ThemeSpec::counterpart_variant).

Source

pub fn names(&self) -> impl Iterator<Item = &str>

The names of the themes known, sorted.

Source

pub fn accents(&self, base: &str) -> Vec<String>

The colour scales of a base theme usable as an accent.

Source

pub fn resolve(&self, spec: &ThemeSpec) -> ResolvedTokens

Resolves a spec. Never fails: problems are reported in the result, and every contract token that has one takes the built-in pop-dark value.

Trait Implementations§

Source§

impl Clone for Themes

Source§

fn clone(&self) -> Themes

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 Debug for Themes

Source§

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

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

impl Default for Themes

Source§

fn default() -> Self

The built-in themes and densities.

Auto Trait Implementations§

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> 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.