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 tracking_for_font_size(&self, size_pt: f32) -> f32

Resolves Apple HIG / SF Pro optical tracking (extra_letter_spacing in points) for size_pt from self.typography().tracking_table, falling back to crate::tokens::sf_pro_tracking for fractional or out-of-range font sizes.

Source

pub fn semibold_font_id(&self, ui: &Ui, size_pt: f32) -> (FontId, bool)

Resolves the Inter-SemiBold FontId when registered in ui.ctx(), or falls back to FontId::proportional, returning (font_id, has_semibold_family) with zero per-widget Arc<str> or Vec<FontFamily> heap allocations.

Source

pub fn tracked_text_format(&self, font_id: FontId, color: Color32) -> TextFormat

Constructs an egui::TextFormat populated with optical letter spacing (extra_letter_spacing) from the Apple HIG tracking table for font_id.size.

Source

pub fn layout_tracked_galley( &self, ui: &Ui, text: &str, font_id: FontId, color: Color32, wrap_width: f32, ) -> Arc<Galley> ⓘ

Lays out a text Galley with Apple HIG optical tracking (extra_letter_spacing) automatically applied from self.typography().tracking_table.

Source

pub fn control_metrics(&self) -> &MacControlMetrics

Returns control metrics tokens.

Source

pub fn button(&self) -> &ButtonMetrics

Returns button size and geometry tokens.

Source

pub fn text_field(&self) -> &TextFieldMetrics

Returns text field and input cell size/geometry tokens.

Source

pub fn segmented(&self) -> &SegmentedMetrics

Returns segmented control geometry tokens.

Source

pub fn focus_ring(&self) -> &FocusRingMetrics

Returns focus ring halo tokens.

Source

pub fn toolbar_metrics(&self) -> &ToolbarMetrics

Returns toolbar layout and hit-target tokens.

Source

pub fn popover_metrics(&self) -> &PopoverMetrics

Returns popover and floating panel geometry tokens.

Source

pub fn split_view(&self) -> &SplitViewMetrics

Returns split view divider and pane geometry tokens.

Source

pub fn layout_metrics(&self) -> &LayoutMetrics

Returns layout container metrics (scroll_view, stack_view).

Source

pub fn scroll_view(&self) -> &ScrollViewMetrics

Returns scroll view overlay scrollbar geometry tokens.

Source

pub fn stack_view(&self) -> &StackViewMetrics

Returns stack view spacing, padding, and header tokens.

Source

pub fn outline_view(&self) -> &OutlineViewMetrics

Returns outline view row, indentation, and chevron tokens.

Source

pub fn slider(&self) -> &SliderMetrics

Returns slider track, thumb, and tick tokens.

Source

pub fn thumbnail(&self) -> &ThumbnailCellMetrics

Returns thumbnail cell preview tokens.

Source

pub fn popup_button(&self) -> &PopUpButtonMetrics

Returns pop-up button bezel and menu tokens.

Source

pub fn search_field(&self) -> &SearchFieldMetrics

Returns search field pill, icon, and clear button tokens.

Source

pub fn stepper(&self) -> &StepperMetrics

Returns numeric stepper control tokens.

Source

pub fn color_well(&self) -> &ColorWellMetrics

Returns color well swatch and picker tokens.

Source

pub fn toggle(&self) -> &ToggleMetrics

Returns toggle switch (NSSwitch) tokens.

Source

pub fn navigation_metrics(&self) -> &NavigationMetrics

Returns navigation and feedback metrics tokens.

Source

pub fn menu_bar_metrics(&self) -> &MenuBarMetrics

Returns menu bar and dropdown menu tokens.

Source

pub fn footer_metrics(&self) -> &FooterMetrics

Returns canvas footer bar tokens.

Source

pub fn palette_metrics(&self) -> &PaletteMetrics

Returns Spotlight command palette tokens.

Source

pub fn context_menu_metrics(&self) -> &ContextMenuMetrics

Returns context menu popup tokens.

Source

pub fn toast_metrics(&self) -> &ToastMetrics

Returns floating toast notification tokens.

Source

pub fn progress_indicator(&self) -> &ProgressIndicatorMetrics

Returns progress indicator bar and spinning fin tokens.

Source

pub fn table_view(&self) -> &TableViewMetrics

Returns table view and sortable header tokens.

Source

pub fn token_field(&self) -> &TokenFieldMetrics

Returns token field pill capsule tokens.

Source

pub fn level_indicator(&self) -> &LevelIndicatorMetrics

Returns level indicator VU meter tokens.

Source

pub fn trim_scrubber(&self) -> &TrimScrubberMetrics

Returns AVKit trim scrubber timeline tokens.

Source

pub fn path_control(&self) -> &PathControlMetrics

Returns path control breadcrumb bar tokens.

Source

pub fn disclosure_group(&self) -> &DisclosureGroupMetrics

Returns disclosure group & button tokens.

Source

pub fn combo_box(&self) -> &ComboBoxMetrics

Returns combo box tokens.

Source

pub fn tab_view(&self) -> &TabViewMetrics

Returns tab view tokens.

Source

pub fn date_picker(&self) -> &DatePickerMetrics

Returns date picker tokens.

Source

pub fn collection_view(&self) -> &CollectionViewMetrics

Returns collection view tokens.

Source

pub fn player_view(&self) -> &PlayerViewMetrics

Returns player view tokens.

Source

pub fn box_view(&self) -> &BoxViewMetrics

Returns box view tokens.

Source

pub fn rule_editor(&self) -> &RuleEditorMetrics

Returns rule editor tokens.

Source

pub fn checkbox(&self) -> &CheckboxMetrics

Returns square AppKit checkbox (NSButtonTypeSwitch) tokens.

Source

pub fn label_metrics(&self) -> &LabelMetrics

Returns non-editable AppKit label (NSTextField.labelWithString:) tokens.

Source

pub fn help_button(&self) -> &HelpButtonMetrics

Returns circular AppKit help button (NSBezelStyleHelpButton) tokens.

Source

pub fn inline_action_button(&self) -> &InlineActionButtonMetrics

Returns circular inline action badge button (16x16pt) tokens.

Source

pub fn typography(&self) -> &MacTypographyTokens

Returns typography and SF Pro optical tracking tokens.

Source

pub fn motion(&self) -> &MacMotionTokens

Returns CoreAnimation spring physics preset tokens.

Source

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

Evaluates MacBackgroundStyle for the given background surface color.

Source

pub fn accent_background_style(&self) -> MacBackgroundStyle

Evaluates MacBackgroundStyle for Self::control_accent (or custom accent override).

Source

pub fn selected_control_background_style(&self) -> MacBackgroundStyle

Source

pub fn disabled_opacity(&self) -> f32

Returns disabled control opacity factor (0.45).

Source

pub fn apply_enabled(&self, color: Color32, enabled: bool) -> Color32

Scales color alpha by Self::disabled_opacity when enabled is false.

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.

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.

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

Resolves tertiaryLabelColor (NSColor) for subtle hints and disabled captions.

Source

pub fn box_background(&self) -> Color32

Resolves recessed container surface color (box_background) for NSBoxPrimary.

Source

pub fn box_border(&self) -> Color32

Resolves perimeter border color (box_border) for NSBoxPrimary.

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.

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.