pub struct ThemeVariant {Show 29 fields
pub defaults: ThemeDefaults,
pub text_scale: TextScale,
pub window: WindowTheme,
pub button: ButtonTheme,
pub input: InputTheme,
pub checkbox: CheckboxTheme,
pub menu: MenuTheme,
pub tooltip: TooltipTheme,
pub scrollbar: ScrollbarTheme,
pub slider: SliderTheme,
pub progress_bar: ProgressBarTheme,
pub tab: TabTheme,
pub sidebar: SidebarTheme,
pub toolbar: ToolbarTheme,
pub status_bar: StatusBarTheme,
pub list: ListTheme,
pub popover: PopoverTheme,
pub splitter: SplitterTheme,
pub separator: SeparatorTheme,
pub switch: SwitchTheme,
pub dialog: DialogTheme,
pub spinner: SpinnerTheme,
pub combo_box: ComboBoxTheme,
pub segmented_control: SegmentedControlTheme,
pub card: CardTheme,
pub expander: ExpanderTheme,
pub link: LinkTheme,
pub icon_set: Option<String>,
pub icon_theme: Option<String>,
}Expand description
A single light or dark theme variant containing all visual properties.
Composes defaults, per-widget structs, and optional text scale into one coherent set. Empty sub-structs are omitted from serialization to keep TOML files clean.
§Examples
use native_theme::{ThemeVariant, Rgba};
let mut variant = ThemeVariant::default();
variant.defaults.accent = Some(Rgba::rgb(0, 120, 215));
variant.defaults.font.family = Some("Inter".into());
assert!(!variant.is_empty());Fields§
§defaults: ThemeDefaultsGlobal defaults inherited by all widgets.
text_scale: TextScalePer-role text scale overrides.
window: WindowThemeWindow chrome: background, title bar, radius, shadow.
Push button: colors, sizing, spacing, geometry.
input: InputThemeSingle-line and multi-line text input fields.
checkbox: CheckboxThemeCheckbox and radio button indicator geometry.
Popup and context menu appearance.
tooltip: TooltipThemeTooltip popup appearance.
scrollbar: ScrollbarThemeScrollbar colors and geometry.
slider: SliderThemeSlider control colors and geometry.
progress_bar: ProgressBarThemeProgress bar colors and geometry.
tab: TabThemeTab bar colors and sizing.
Sidebar panel background and foreground colors.
toolbar: ToolbarThemeToolbar sizing, spacing, and font.
status_bar: StatusBarThemeStatus bar font.
list: ListThemeList and table colors and row geometry.
popover: PopoverThemePopover / dropdown panel appearance.
splitter: SplitterThemeSplitter handle width.
separator: SeparatorThemeSeparator line color.
switch: SwitchThemeToggle switch track, thumb, and geometry.
dialog: DialogThemeDialog sizing, spacing, button order, and title font.
spinner: SpinnerThemeSpinner / indeterminate progress indicator.
combo_box: ComboBoxThemeComboBox / dropdown trigger sizing.
segmented_control: SegmentedControlThemeSegmented control sizing.
card: CardThemeCard / container colors and geometry.
expander: ExpanderThemeExpander / disclosure row geometry.
link: LinkThemeHyperlink colors and underline setting.
icon_set: Option<String>Icon set / naming convention for this variant (e.g., “sf-symbols”, “freedesktop”). When None, resolved at runtime via system_icon_set().
icon_theme: Option<String>Icon theme name for this variant (e.g., “breeze”, “Adwaita”, “material”).
This is the visual icon theme, distinct from the naming convention in icon_set.
When None, resolved at runtime via system_icon_theme().
Implementations§
Source§impl ThemeVariant
impl ThemeVariant
Sourcepub fn merge(&mut self, overlay: &ThemeVariant)
pub fn merge(&mut self, overlay: &ThemeVariant)
Merge an overlay into this value. Some fields in the overlay
replace the corresponding fields in self; None fields are
left unchanged. Nested structs are merged recursively.
Source§impl ThemeVariant
impl ThemeVariant
Sourcepub fn resolve(&mut self)
pub fn resolve(&mut self)
Apply all ~90 inheritance rules in 4-phase order.
After calling resolve(), most Option fields that were None will be filled from defaults or related widget fields. Calling resolve() twice produces the same result (idempotent).
§Phases
- Defaults internal chains – accent derives selection, focus_ring_color; selection derives selection_inactive.
- Safety nets – platform-divergent fields get a reasonable fallback.
- Widget-from-defaults – colors, geometry, fonts, text scale entries all inherit from defaults.
- Widget-to-widget – inactive title bar fields fall back to active.
Sourcepub fn into_resolved(self) -> Result<ResolvedThemeVariant, Error>
pub fn into_resolved(self) -> Result<ResolvedThemeVariant, Error>
Resolve all inheritance rules and validate in one step.
This is the recommended way to convert a ThemeVariant into a
ResolvedThemeVariant. It calls resolve() followed
by validate(), ensuring no fields are left
unresolved.
§Errors
Returns crate::Error::Resolution if any fields remain None after
resolution (e.g., when accent color is missing and cannot be derived).
§Examples
use native_theme::ThemeSpec;
let theme = ThemeSpec::preset("dracula").unwrap();
let variant = theme.dark.unwrap();
let resolved = variant.into_resolved().unwrap();
// All fields are now guaranteed populated
let accent = resolved.defaults.accent;Sourcepub fn validate(&self) -> Result<ResolvedThemeVariant, Error>
pub fn validate(&self) -> Result<ResolvedThemeVariant, Error>
Convert this ThemeVariant into a ResolvedThemeVariant with all fields guaranteed.
Should be called after resolve(). Walks every field
and collects missing (None) field paths. Returns Ok(ResolvedThemeVariant) if all fields
are populated, or Err(Error::Resolution(...)) listing every missing field.
§Errors
Returns crate::Error::Resolution containing a ThemeResolutionError
with all missing field paths if any fields remain None.
Trait Implementations§
Source§impl Clone for ThemeVariant
impl Clone for ThemeVariant
Source§fn clone(&self) -> ThemeVariant
fn clone(&self) -> ThemeVariant
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ThemeVariant
impl Debug for ThemeVariant
Source§impl Default for ThemeVariant
impl Default for ThemeVariant
Source§fn default() -> ThemeVariant
fn default() -> ThemeVariant
Source§impl<'de> Deserialize<'de> for ThemeVariantwhere
ThemeVariant: Default,
impl<'de> Deserialize<'de> for ThemeVariantwhere
ThemeVariant: Default,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ThemeVariant, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ThemeVariant, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for ThemeVariant
impl PartialEq for ThemeVariant
Source§impl Serialize for ThemeVariant
impl Serialize for ThemeVariant
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for ThemeVariant
Auto Trait Implementations§
impl Freeze for ThemeVariant
impl RefUnwindSafe for ThemeVariant
impl Send for ThemeVariant
impl Sync for ThemeVariant
impl Unpin for ThemeVariant
impl UnsafeUnpin for ThemeVariant
impl UnwindSafe for ThemeVariant
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().