#[non_exhaustive]pub struct ThemeVariant {Show 28 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>,
}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 (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.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().
Implementations§
Source§impl ThemeVariant
impl ThemeVariant
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 validate(&self) -> Result<ResolvedTheme>
pub fn validate(&self) -> Result<ResolvedTheme>
Convert this ThemeVariant into a ResolvedTheme with all fields guaranteed.
Should be called after resolve(). Walks every field
and collects missing (None) field paths. Returns Ok(ResolvedTheme) 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 more