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: StringTheme name (from reader or preset).
is_dark: boolWhether the OS is currently in dark mode.
light: ResolvedThemeResolved light variant (always populated).
dark: ResolvedThemeResolved dark variant (always populated).
live_preset: StringThe live preset name used for the OS-active variant (e.g., “kde-breeze-live”).
full_preset: StringThe full preset name used for the inactive variant (e.g., “kde-breeze”).
Implementations§
Source§impl SystemTheme
impl SystemTheme
Sourcepub fn active(&self) -> &ResolvedTheme
pub fn active(&self) -> &ResolvedTheme
Returns the OS-active resolved variant.
If is_dark is true, returns &self.dark; otherwise &self.light.
Sourcepub fn pick(&self, is_dark: bool) -> &ResolvedTheme
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.
Sourcepub fn with_overlay(self, overlay: &NativeTheme) -> Result<Self>
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 updatedSourcepub fn with_overlay_toml(self, toml: &str) -> Result<Self>
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.