Skip to main content

SystemTheme

Struct SystemTheme 

Source
pub struct SystemTheme {
    pub name: String,
    pub is_dark: bool,
    pub light: ResolvedTheme,
    pub dark: ResolvedTheme,
    pub live_preset: String,
    pub full_preset: String,
    /* private fields */
}
Expand description

Result of the OS-first pipeline. Holds both resolved variants.

Produced by from_system() and from_system_async(). Both light and dark are always populated: the OS-active variant comes from the reader + preset + resolve, the inactive variant comes from the preset + resolve.

Fields§

§name: String

Theme name (from reader or preset).

§is_dark: bool

Whether the OS is currently in dark mode.

§light: ResolvedTheme

Resolved light variant (always populated).

§dark: ResolvedTheme

Resolved dark variant (always populated).

§live_preset: String

The live preset name used for the OS-active variant (e.g., “kde-breeze-live”).

§full_preset: String

The full preset name used for the inactive variant (e.g., “kde-breeze”).

Implementations§

Source§

impl SystemTheme

Source

pub fn active(&self) -> &ResolvedTheme

Returns the OS-active resolved variant.

If is_dark is true, returns &self.dark; otherwise &self.light.

Source

pub fn pick(&self, is_dark: bool) -> &ResolvedTheme

Pick a resolved variant by explicit preference.

pick(true) returns &self.dark, pick(false) returns &self.light.

Source

pub fn with_overlay(self, overlay: &NativeTheme) -> Result<Self>

Apply an app-level TOML overlay and re-resolve.

Merges the overlay onto the pre-resolve ThemeVariant (not the already-resolved ResolvedTheme) so that changed source fields propagate correctly through resolve(). For example, changing defaults.accent in the overlay will cause button.primary_bg, checkbox.checked_bg, slider.fill, etc. to be re-derived from the new accent color.

§Examples
let system = native_theme::from_system().unwrap();
let overlay = native_theme::NativeTheme::from_toml(r##"
    [light.defaults]
    accent = "#ff6600"
    [dark.defaults]
    accent = "#ff6600"
"##).unwrap();
let customized = system.with_overlay(&overlay).unwrap();
// customized.active().defaults.accent is now #ff6600
// and all accent-derived fields are updated
Source

pub fn with_overlay_toml(self, toml: &str) -> Result<Self>

Apply an app overlay from a TOML string.

Parses the TOML as a NativeTheme and calls with_overlay.

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