Skip to main content

MacTheme

Struct MacTheme 

Source
pub struct MacTheme {
    pub appearance: MacAppearance,
    pub window_controls_style: WindowControlsStyle,
    /* private fields */
}
Expand description

Dynamic theme resolving AppKit semantic styling from MacDesignTokens.

§Example

use egui_macview::{MacAppearance, MacTheme, WindowControlsStyle};

// Create a dark aqua macOS theme
let theme = MacTheme::new(MacAppearance::DarkAqua)
    .with_window_controls_style(WindowControlsStyle::AppleTrafficLights);

let bg = theme.window_background();
let text_color = theme.label();
let corner_radius = theme.button().regular.corner_radius.points();
assert_eq!(corner_radius, 6.0);

Fields§

§appearance: MacAppearance

Active macOS appearance mode (MacAppearance::Aqua or MacAppearance::DarkAqua).

§window_controls_style: WindowControlsStyle

Window caption controls presentation style.

Implementations§

Source§

impl MacTheme

Source

pub fn new(appearance: MacAppearance) -> Self

Creates a new MacTheme for the given appearance using the embedded default token catalog.

Source

pub fn with_window_controls_style(self, style: WindowControlsStyle) -> Self

Sets the window controls presentation style (Strategy 2).

Source

pub fn window_controls_style(&self) -> WindowControlsStyle

Returns the active window controls presentation style.

Source

pub fn with_accent(self, accent: Color32) -> Self

Sets a dynamic system accent color override (matching macOS System Settings Appearance Accent).

Source

pub fn with_tokens(appearance: MacAppearance, tokens: MacDesignTokens) -> Self

Creates a MacTheme with custom loaded tokens.

Source

pub fn with_arc_tokens( appearance: MacAppearance, tokens: Arc<MacDesignTokens>, ) -> Self

Creates a MacTheme with custom loaded tokens wrapped in an Arc.

Source

pub fn tokens(&self) -> &MacDesignTokens

Returns the underlying design token catalog.

Source

pub fn colors(&self) -> &MacAppearanceColors

Active appearance color palette.

Source

pub fn window_background(&self) -> Color32

Resolves windowBackgroundColor (NSColor) for the active appearance.

Source

pub fn control_background(&self) -> Color32

Resolves controlBackgroundColor (NSColor) for the active appearance.

Source

pub fn control(&self) -> Color32

Resolves controlColor (NSColor) for the active appearance.

Source

pub fn control_accent(&self) -> Color32

Resolves controlAccentColor (NSColor) or custom accent override.

Source

pub fn selected_control(&self) -> Color32

Resolves selectedControlColor (NSColor) or custom accent override.

Source

pub fn selected_control_inactive(&self) -> Color32

Resolves selectedControlColor (NSColor) when the window or control is inactive/unfocused.

Source

pub fn separator(&self) -> Color32

Resolves separatorColor (NSColor) for hairlines and borders.

Source

pub fn placeholder_text(&self) -> Color32

Resolves placeholderTextColor (NSColor) for empty text fields and search inputs.

Source

pub fn keyboard_focus_indicator(&self) -> Color32

Resolves keyboardFocusIndicatorColor (NSColor) for focus rings.

Source

pub fn label(&self) -> Color32

Resolves primary labelColor (NSColor).

Source

pub fn secondary_label(&self) -> Color32

Resolves secondaryLabelColor (NSColor) for captions, subtitles, and section headers.

Source

pub fn apply_to_egui(&self, ctx: &Context)

Synchronizes egui::Context theme and visuals with the macOS appearance.

Source

pub fn control_metrics(&self) -> &MacControlMetrics

Resolves top-level control metrics collection.

Source

pub fn focus_ring(&self) -> &FocusRingMetrics

Resolves focus ring geometry metrics.

Source

pub fn text_field(&self) -> &TextFieldMetrics

Resolves text field geometry metrics.

Source

pub fn button(&self) -> &ButtonMetrics

Resolves push button geometry metrics.

Source

pub fn segmented(&self) -> &SegmentedMetrics

Resolves segmented control geometry metrics.

Source

pub fn popover_metrics(&self) -> &PopoverMetrics

Resolves popover and HUD panel geometry metrics.

Source

pub fn toolbar_metrics(&self) -> &ToolbarMetrics

Resolves window toolbar geometry metrics.

Source

pub fn slider(&self) -> &SliderMetrics

Resolves slider control geometry metrics.

Source

pub fn thumbnail(&self) -> &ThumbnailCellMetrics

Resolves thumbnail cell geometry metrics.

Source

pub fn split_view(&self) -> &SplitViewMetrics

Resolves split view divider and handle geometry metrics.

Source

pub fn layout_metrics(&self) -> &LayoutMetrics

Resolves layout container geometry metrics.

Source

pub fn scroll_view(&self) -> &ScrollViewMetrics

Resolves scroll view and overlay scrollbar geometry metrics.

Source

pub fn stack_view(&self) -> &StackViewMetrics

Resolves stack view linear layout geometry metrics.

Source

pub fn outline_view(&self) -> &OutlineViewMetrics

Resolves outline view hierarchical table geometry metrics.

Source

pub fn popup_button(&self) -> &PopUpButtonMetrics

Resolves pop-up button geometry metrics.

Source

pub fn search_field(&self) -> &SearchFieldMetrics

Resolves search field geometry metrics.

Source

pub fn stepper(&self) -> &StepperMetrics

Resolves numeric stepper control geometry metrics.

Source

pub fn color_well(&self) -> &ColorWellMetrics

Resolves color well swatch control geometry metrics.

Source

pub fn toggle(&self) -> &ToggleMetrics

Resolves toggle switch control geometry metrics.

Source

pub fn motion(&self) -> &MacMotionTokens

Resolves CoreAnimation motion preset tokens.

Source

pub fn typography(&self) -> &MacTypographyTokens

Resolves typography and SF Pro tracking tokens.

Source

pub fn system_green(&self) -> Color32

Resolves Apple system green semantic color (systemGreenColor).

Source

pub fn traffic_light_close(&self) -> (Color32, Color32)

Resolves macOS window close traffic light fill and border colors (fill, border).

Source

pub fn traffic_light_minimize(&self) -> (Color32, Color32)

Resolves macOS window minimize traffic light fill and border colors (fill, border).

Source

pub fn traffic_light_zoom(&self) -> (Color32, Color32)

Resolves macOS window zoom/fullscreen traffic light fill and border colors (fill, border).

Source

pub fn windows_caption_close_hover_bg(&self) -> Color32

Background color for Windows 11 close caption button on hover (Fluent crimson red #E81123).

Source

pub fn windows_caption_close_pressed_bg(&self) -> Color32

Background color for Windows 11 close caption button when pressed (#C42B1C).

Source

pub fn windows_caption_hover_bg(&self) -> Color32

Background color for Windows 11 minimize/maximize caption buttons on hover.

Source

pub fn windows_caption_pressed_bg(&self) -> Color32

Background color for Windows 11 minimize/maximize caption buttons when pressed.

Source

pub fn background_style(&self, bg: Color32) -> MacBackgroundStyle

Resolves the MacBackgroundStyle (Light or Dark) for any background color.

Source

pub fn window_background_style(&self) -> MacBackgroundStyle

Resolves the MacBackgroundStyle for the window background.

Source

pub fn control_background_style(&self) -> MacBackgroundStyle

Resolves the MacBackgroundStyle for the control background.

Source

pub fn selected_control_background_style(&self) -> MacBackgroundStyle

Resolves the MacBackgroundStyle for the selected control background.

Trait Implementations§

Source§

impl Clone for MacTheme

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 MacTheme

Source§

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

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

impl Default for MacTheme

Source§

fn default() -> Self

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

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

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.