Skip to main content

ThemeMode

Struct ThemeMode 

Source
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: ThemeDefaults

Global defaults inherited by all widgets.

§text_scale: TextScale

Per-role text scale overrides.

§window: WindowTheme

Window chrome: background, title bar, radius, shadow.

§button: ButtonTheme

Push button: colors, sizing, spacing, geometry.

§input: InputTheme

Single-line and multi-line text input fields.

§checkbox: CheckboxTheme

Checkbox and radio button indicator geometry.

§menu: MenuTheme

Popup and context menu appearance.

§tooltip: TooltipTheme

Tooltip popup appearance.

§scrollbar: ScrollbarTheme

Scrollbar colors and geometry.

§slider: SliderTheme

Slider control colors and geometry.

§progress_bar: ProgressBarTheme

Progress bar colors and geometry.

§tab: TabTheme

Tab bar colors and sizing.

§sidebar: SidebarTheme

Sidebar panel background and foreground colors.

§toolbar: ToolbarTheme

Toolbar sizing, spacing, and font.

§status_bar: StatusBarTheme

Status bar font.

§list: ListTheme

List and table colors and row geometry.

§popover: PopoverTheme

Popover / dropdown panel appearance.

§splitter: SplitterTheme

Splitter handle width.

§separator: SeparatorTheme

Separator line color.

§switch: SwitchTheme

Toggle switch track, thumb, and geometry.

§dialog: DialogTheme

Dialog sizing, spacing, button order, and title font.

§spinner: SpinnerTheme

Spinner / indeterminate progress indicator.

§combo_box: ComboBoxTheme

ComboBox / dropdown trigger sizing.

§segmented_control: SegmentedControlTheme

Segmented control sizing.

§card: CardTheme

Card / container colors and geometry.

§expander: ExpanderTheme

Expander / disclosure row geometry.

§link: LinkTheme

Hyperlink colors and underline setting.

Implementations§

Source§

impl ThemeMode

Source

pub fn merge(&mut self, overlay: &Self)

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

pub fn is_empty(&self) -> bool

Returns true if all fields are at their default (None/empty) state.

Source§

impl ThemeMode

Source

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
§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;
Source

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;

Trait Implementations§

Source§

impl Clone for ThemeMode

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ThemeMode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ThemeMode

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ThemeMode

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for ThemeMode

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ThemeMode

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ThemeMode

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more