pub struct ThemeMode {Show 27 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,
}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::theme::ThemeMode;
use native_theme::color::Rgba;
let mut variant = ThemeMode::default();
variant.defaults.accent_color = 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.
Implementations§
Source§impl ThemeMode
impl ThemeMode
Source§impl ThemeMode
impl ThemeMode
Sourcepub fn into_resolved(self, ctx: &ResolutionContext) -> Result<ResolvedTheme>
pub fn into_resolved(self, ctx: &ResolutionContext) -> Result<ResolvedTheme>
Resolve all inheritance rules and validate in one step.
This is the recommended way to convert a ThemeMode into a
ResolvedTheme. It applies every inheritance rule (including
the ctx.button_order platform default) followed by
validate_with_dpi(), ensuring no
fields are left unresolved.
§Arguments
ctx– resolution-time inputs captured once per theme-build. UseResolutionContext::from_systemfor OS-detected values (Linux/Windows ≈ 96 DPI, macOS = 72 DPI, button order per desktop environment), orResolutionContext::for_testsfor deterministic test values (96 DPI,PrimaryRight, noicon_theme). Theresolve_system()shortcut wraps thefrom_system()case.
§Errors
Returns crate::Error::ResolutionIncomplete if any fields
remain None after resolution, or
crate::Error::ResolutionInvalid if range checks fail.
§Examples
use native_theme::resolve::ResolutionContext;
use native_theme::theme::Theme;
let theme = Theme::preset("dracula")?;
let variant = theme.dark.ok_or("no dark variant")?;
let resolved = variant.into_resolved(&ResolutionContext::from_system())?;
// Or use the zero-argument shortcut:
// let resolved = variant.resolve_system()?;
let _accent = resolved.defaults.accent_color;Sourcepub fn resolve_system(self) -> Result<ResolvedTheme>
pub fn resolve_system(self) -> Result<ResolvedTheme>
Resolve using the OS-detected context.
Equivalent to
self.into_resolved(&ResolutionContext::from_system()).
Placed on ThemeMode (not Theme) because Theme has both
light and dark variants — variant selection must be explicit via
Theme::into_variant. See
plan 94-02 objective for the deviation rationale from gap doc §G7
step 4.
§Errors
Returns crate::Error::ResolutionIncomplete if any fields
remain None after resolution, or
crate::Error::ResolutionInvalid if range checks fail.
§Examples
use native_theme::theme::{ColorMode, Theme};
let theme = Theme::preset("dracula")?;
let variant = theme.into_variant(ColorMode::Dark)?;
let resolved = variant.resolve_system()?;
let _accent = resolved.defaults.accent_color;