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};

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 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 progress_indicator(&self) -> &ProgressIndicatorMetrics

Resolves progress indicator control geometry metrics.

Source

pub fn table_view(&self) -> &TableViewMetrics

Resolves table view and header geometry metrics.

Source

pub fn token_field(&self) -> &TokenFieldMetrics

Resolves token field pill input geometry metrics.

Source

pub fn level_indicator(&self) -> &LevelIndicatorMetrics

Resolves level indicator meter geometry metrics.

Source

pub fn trim_scrubber(&self) -> &TrimScrubberMetrics

Resolves trim scrubber timeline geometry metrics.

Source

pub fn path_control(&self) -> &PathControlMetrics

Resolves path control breadcrumb geometry metrics.

Source

pub fn disclosure_group(&self) -> &DisclosureGroupMetrics

Resolves disclosure group and button geometry metrics.

Source

pub fn combo_box(&self) -> &ComboBoxMetrics

Resolves combo box geometry metrics.

Source

pub fn tab_view(&self) -> &TabViewMetrics

Resolves tab view layout and content insets metrics.

Source

pub fn date_picker(&self) -> &DatePickerMetrics

Resolves date picker geometry metrics.

Source

pub fn collection_view(&self) -> &CollectionViewMetrics

Resolves collection view flow layout and selection metrics.

Source

pub fn player_view(&self) -> &PlayerViewMetrics

Resolves player view media presentation metrics.

Source

pub fn box_view(&self) -> &BoxViewMetrics

Resolves box view container and separator metrics.

Source

pub fn rule_editor(&self) -> &RuleEditorMetrics

Resolves rule editor layout and button metrics.

Source

pub fn navigation_metrics(&self) -> &NavigationMetrics

Resolves navigation and feedback metrics collection.

Source

pub fn menu_bar_metrics(&self) -> &MenuBarMetrics

Resolves menu bar and dropdown geometry metrics.

Source

pub fn footer_metrics(&self) -> &FooterMetrics

Resolves canvas footer geometry metrics.

Source

pub fn palette_metrics(&self) -> &PaletteMetrics

Resolves command palette modal geometry metrics.

Source

pub fn context_menu_metrics(&self) -> &ContextMenuMetrics

Resolves context menu geometry metrics.

Source

pub fn toast_metrics(&self) -> &ToastMetrics

Resolves toast notification 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 disabled_opacity(&self) -> f32

Resolves opacity multiplier for disabled controls (0.45).

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.

Source

pub fn paint_focus_ring( &self, painter: &Painter, rect: Rect, corner_radius: f32, )

Renders an AppKit outer keyboard focus ring (NSFocusRingPlacementOutside) around rect.

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 from_ctx(ctx: &Context) -> Self

Retrieves the active MacTheme stored in egui::Context by MacTheme::apply_to_egui, falling back to MacTheme::default (Aqua) if none was registered.

Source

pub fn resolve<'a>(theme: Option<&'a Self>, ctx: &Context) -> Cow<'a, Self>

Resolves an optional borrowed MacTheme, falling back to MacTheme::from_ctx.

Source

pub fn resolve_or_default<'a>(theme: Option<&'a Self>) -> Cow<'a, Self>

Resolves an optional borrowed MacTheme, falling back to the cached MacTheme::default without allocating an egui::Context.

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 system_green(&self) -> Color32

Resolves Apple system green semantic color (systemGreenColor).

Source

pub fn system_yellow(&self) -> Color32

Resolves Apple system yellow/amber semantic color (systemYellowColor).

Source

pub fn system_orange(&self) -> Color32

Resolves Apple system orange semantic color (systemOrangeColor).

Source

pub fn system_red(&self) -> Color32

Resolves Apple system red semantic color (systemRedColor).

Source

pub fn alternating_row_even(&self) -> Color32

Resolves even table row background color (alternatingContentBackgroundColors[0]).

Source

pub fn alternating_row_odd(&self) -> Color32

Resolves odd table row background color (alternatingContentBackgroundColors[1]).

Source

pub fn alternating_content_background(&self, row_index: usize) -> Color32

Resolves alternating content background color for the given row index (row_index % 2).

Source

pub fn scrubber_selection_border(&self) -> Color32

Resolves QuickTime / AVKit trim selection border and handle color.

Source

pub fn scrubber_outside_dim(&self) -> Color32

Resolves dimming overlay color for timeline regions outside active trim bounds.

Source

pub fn scrubber_waveform(&self) -> Color32

Resolves waveform amplitude bar color inside trim scrubber track.

Source

pub fn scrubber_playhead(&self) -> Color32

Resolves playhead cursor line and timecode badge accent color.

Source

pub fn on_accent_text(&self) -> Color32

Resolves high-contrast white text color used on accent fills.

Source

pub fn knob_fill(&self) -> Color32

Resolves white thumb knob fill color for switches and sliders.

Source

pub fn drop_shadow(&self) -> Color32

Resolves subtle ambient drop shadow color for controls and floating surfaces.

Source

pub fn backdrop_dim(&self) -> Color32

Resolves modal backdrop dimming overlay color.

Source

pub fn hud_background(&self) -> Color32

Resolves translucent dark HUD palette background color (SPEC-006 §2.2).

Source

pub fn hud_border(&self) -> Color32

Resolves dark HUD palette hairline border color.

Source

pub fn hud_text(&self) -> Color32

Resolves dark HUD palette primary text color.

Source

pub fn hud_secondary_text(&self) -> Color32

Resolves dark HUD palette secondary label color.

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 traffic_light_glyph(&self) -> Color32

Interior glyph color for hovered macOS traffic light buttons.

Source

pub fn windows_caption_close_hover_bg(&self) -> Color32

Background color for Windows 11 close caption button on hover (#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 scrollbar_thumb_color(&self, active: bool, alpha_factor: f32) -> Color32

Overlay scrollbar thumb color scaled by fade alpha_factor in [0.0, 1.0].

Source

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

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

Performs an $O(1)$ short-circuit when the active MacTheme stored in ctx already matches the current appearance, window controls style, accent override, and token catalog pointer.

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.