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: MacAppearanceActive macOS appearance mode (MacAppearance::Aqua or MacAppearance::DarkAqua).
window_controls_style: WindowControlsStyleWindow caption controls presentation style.
Implementations§
Source§impl MacTheme
impl MacTheme
Sourcepub fn control_metrics(&self) -> &MacControlMetrics
pub fn control_metrics(&self) -> &MacControlMetrics
Resolves top-level control metrics collection.
Sourcepub fn focus_ring(&self) -> &FocusRingMetrics
pub fn focus_ring(&self) -> &FocusRingMetrics
Resolves focus ring geometry metrics.
Sourcepub fn text_field(&self) -> &TextFieldMetrics
pub fn text_field(&self) -> &TextFieldMetrics
Resolves text field geometry metrics.
Resolves push button geometry metrics.
Sourcepub fn segmented(&self) -> &SegmentedMetrics
pub fn segmented(&self) -> &SegmentedMetrics
Resolves segmented control geometry metrics.
Sourcepub fn popover_metrics(&self) -> &PopoverMetrics
pub fn popover_metrics(&self) -> &PopoverMetrics
Resolves popover and HUD panel geometry metrics.
Sourcepub fn toolbar_metrics(&self) -> &ToolbarMetrics
pub fn toolbar_metrics(&self) -> &ToolbarMetrics
Resolves window toolbar geometry metrics.
Sourcepub fn slider(&self) -> &SliderMetrics
pub fn slider(&self) -> &SliderMetrics
Resolves slider control geometry metrics.
Sourcepub fn thumbnail(&self) -> &ThumbnailCellMetrics
pub fn thumbnail(&self) -> &ThumbnailCellMetrics
Resolves thumbnail cell geometry metrics.
Sourcepub fn split_view(&self) -> &SplitViewMetrics
pub fn split_view(&self) -> &SplitViewMetrics
Resolves split view divider and handle geometry metrics.
Sourcepub fn layout_metrics(&self) -> &LayoutMetrics
pub fn layout_metrics(&self) -> &LayoutMetrics
Resolves layout container geometry metrics.
Sourcepub fn scroll_view(&self) -> &ScrollViewMetrics
pub fn scroll_view(&self) -> &ScrollViewMetrics
Resolves scroll view and overlay scrollbar geometry metrics.
Sourcepub fn stack_view(&self) -> &StackViewMetrics
pub fn stack_view(&self) -> &StackViewMetrics
Resolves stack view linear layout geometry metrics.
Sourcepub fn outline_view(&self) -> &OutlineViewMetrics
pub fn outline_view(&self) -> &OutlineViewMetrics
Resolves outline view hierarchical table geometry metrics.
Resolves pop-up button geometry metrics.
Sourcepub fn search_field(&self) -> &SearchFieldMetrics
pub fn search_field(&self) -> &SearchFieldMetrics
Resolves search field geometry metrics.
Sourcepub fn stepper(&self) -> &StepperMetrics
pub fn stepper(&self) -> &StepperMetrics
Resolves numeric stepper control geometry metrics.
Sourcepub fn color_well(&self) -> &ColorWellMetrics
pub fn color_well(&self) -> &ColorWellMetrics
Resolves color well swatch control geometry metrics.
Sourcepub fn toggle(&self) -> &ToggleMetrics
pub fn toggle(&self) -> &ToggleMetrics
Resolves toggle switch control geometry metrics.
Sourcepub fn progress_indicator(&self) -> &ProgressIndicatorMetrics
pub fn progress_indicator(&self) -> &ProgressIndicatorMetrics
Resolves progress indicator control geometry metrics.
Sourcepub fn table_view(&self) -> &TableViewMetrics
pub fn table_view(&self) -> &TableViewMetrics
Resolves table view and header geometry metrics.
Sourcepub fn token_field(&self) -> &TokenFieldMetrics
pub fn token_field(&self) -> &TokenFieldMetrics
Resolves token field pill input geometry metrics.
Sourcepub fn level_indicator(&self) -> &LevelIndicatorMetrics
pub fn level_indicator(&self) -> &LevelIndicatorMetrics
Resolves level indicator meter geometry metrics.
Sourcepub fn trim_scrubber(&self) -> &TrimScrubberMetrics
pub fn trim_scrubber(&self) -> &TrimScrubberMetrics
Resolves trim scrubber timeline geometry metrics.
Sourcepub fn path_control(&self) -> &PathControlMetrics
pub fn path_control(&self) -> &PathControlMetrics
Resolves path control breadcrumb geometry metrics.
Resolves navigation and feedback metrics collection.
Resolves menu bar and dropdown geometry metrics.
Resolves canvas footer geometry metrics.
Sourcepub fn palette_metrics(&self) -> &PaletteMetrics
pub fn palette_metrics(&self) -> &PaletteMetrics
Resolves command palette modal geometry metrics.
Resolves context menu geometry metrics.
Sourcepub fn toast_metrics(&self) -> &ToastMetrics
pub fn toast_metrics(&self) -> &ToastMetrics
Resolves toast notification geometry metrics.
Sourcepub fn motion(&self) -> &MacMotionTokens
pub fn motion(&self) -> &MacMotionTokens
Resolves CoreAnimation motion preset tokens.
Sourcepub fn typography(&self) -> &MacTypographyTokens
pub fn typography(&self) -> &MacTypographyTokens
Resolves typography and SF Pro tracking tokens.
Sourcepub fn disabled_opacity(&self) -> f32
pub fn disabled_opacity(&self) -> f32
Resolves opacity multiplier for disabled controls (0.45).
Sourcepub fn background_style(&self, bg: Color32) -> MacBackgroundStyle
pub fn background_style(&self, bg: Color32) -> MacBackgroundStyle
Resolves the MacBackgroundStyle (Light or Dark) for any background color.
Sourcepub fn window_background_style(&self) -> MacBackgroundStyle
pub fn window_background_style(&self) -> MacBackgroundStyle
Resolves the MacBackgroundStyle for the window background.
Sourcepub fn control_background_style(&self) -> MacBackgroundStyle
pub fn control_background_style(&self) -> MacBackgroundStyle
Resolves the MacBackgroundStyle for the control background.
Sourcepub fn selected_control_background_style(&self) -> MacBackgroundStyle
pub fn selected_control_background_style(&self) -> MacBackgroundStyle
Resolves the MacBackgroundStyle for the selected control background.
Sourcepub fn paint_focus_ring(
&self,
painter: &Painter,
rect: Rect,
corner_radius: f32,
)
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
impl MacTheme
Sourcepub fn new(appearance: MacAppearance) -> Self
pub fn new(appearance: MacAppearance) -> Self
Creates a new MacTheme for the given appearance using the embedded default token catalog.
Sourcepub fn from_ctx(ctx: &Context) -> Self
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.
Sourcepub fn resolve<'a>(theme: Option<&'a Self>, ctx: &Context) -> Cow<'a, Self>
pub fn resolve<'a>(theme: Option<&'a Self>, ctx: &Context) -> Cow<'a, Self>
Resolves an optional borrowed MacTheme, falling back to MacTheme::from_ctx.
Sourcepub fn with_window_controls_style(self, style: WindowControlsStyle) -> Self
pub fn with_window_controls_style(self, style: WindowControlsStyle) -> Self
Sets the window controls presentation style (Strategy 2).
Sourcepub fn window_controls_style(&self) -> WindowControlsStyle
pub fn window_controls_style(&self) -> WindowControlsStyle
Returns the active window controls presentation style.
Sourcepub fn with_accent(self, accent: Color32) -> Self
pub fn with_accent(self, accent: Color32) -> Self
Sets a dynamic system accent color override (matching macOS System Settings Appearance Accent).
Sourcepub fn with_tokens(appearance: MacAppearance, tokens: MacDesignTokens) -> Self
pub fn with_tokens(appearance: MacAppearance, tokens: MacDesignTokens) -> Self
Creates a MacTheme with custom loaded tokens.
Sourcepub fn with_arc_tokens(
appearance: MacAppearance,
tokens: Arc<MacDesignTokens>,
) -> Self
pub fn with_arc_tokens( appearance: MacAppearance, tokens: Arc<MacDesignTokens>, ) -> Self
Creates a MacTheme with custom loaded tokens wrapped in an Arc.
Sourcepub fn tokens(&self) -> &MacDesignTokens
pub fn tokens(&self) -> &MacDesignTokens
Returns the underlying design token catalog.
Sourcepub fn colors(&self) -> &MacAppearanceColors
pub fn colors(&self) -> &MacAppearanceColors
Active appearance color palette.
Sourcepub fn window_background(&self) -> Color32
pub fn window_background(&self) -> Color32
Resolves windowBackgroundColor (NSColor) for the active appearance.
Sourcepub fn control_background(&self) -> Color32
pub fn control_background(&self) -> Color32
Resolves controlBackgroundColor (NSColor) for the active appearance.
Sourcepub fn control_accent(&self) -> Color32
pub fn control_accent(&self) -> Color32
Resolves controlAccentColor (NSColor) or custom accent override.
Sourcepub fn selected_control(&self) -> Color32
pub fn selected_control(&self) -> Color32
Resolves selectedControlColor (NSColor) or custom accent override.
Sourcepub fn selected_control_inactive(&self) -> Color32
pub fn selected_control_inactive(&self) -> Color32
Resolves selectedControlColor (NSColor) when the window or control is inactive/unfocused.
Sourcepub fn separator(&self) -> Color32
pub fn separator(&self) -> Color32
Resolves separatorColor (NSColor) for hairlines and borders.
Sourcepub fn placeholder_text(&self) -> Color32
pub fn placeholder_text(&self) -> Color32
Resolves placeholderTextColor (NSColor) for empty text fields and search inputs.
Sourcepub fn keyboard_focus_indicator(&self) -> Color32
pub fn keyboard_focus_indicator(&self) -> Color32
Resolves keyboardFocusIndicatorColor (NSColor) for focus rings.
Sourcepub fn secondary_label(&self) -> Color32
pub fn secondary_label(&self) -> Color32
Resolves secondaryLabelColor (NSColor) for captions, subtitles, and section headers.
Sourcepub fn system_green(&self) -> Color32
pub fn system_green(&self) -> Color32
Resolves Apple system green semantic color (systemGreenColor).
Sourcepub fn system_yellow(&self) -> Color32
pub fn system_yellow(&self) -> Color32
Resolves Apple system yellow/amber semantic color (systemYellowColor).
Sourcepub fn system_orange(&self) -> Color32
pub fn system_orange(&self) -> Color32
Resolves Apple system orange semantic color (systemOrangeColor).
Sourcepub fn system_red(&self) -> Color32
pub fn system_red(&self) -> Color32
Resolves Apple system red semantic color (systemRedColor).
Sourcepub fn alternating_row_even(&self) -> Color32
pub fn alternating_row_even(&self) -> Color32
Resolves even table row background color (alternatingContentBackgroundColors[0]).
Sourcepub fn alternating_row_odd(&self) -> Color32
pub fn alternating_row_odd(&self) -> Color32
Resolves odd table row background color (alternatingContentBackgroundColors[1]).
Sourcepub fn alternating_content_background(&self, row_index: usize) -> Color32
pub fn alternating_content_background(&self, row_index: usize) -> Color32
Resolves alternating content background color for the given row index (row_index % 2).
Sourcepub fn scrubber_selection_border(&self) -> Color32
pub fn scrubber_selection_border(&self) -> Color32
Resolves QuickTime / AVKit trim selection border and handle color.
Sourcepub fn scrubber_outside_dim(&self) -> Color32
pub fn scrubber_outside_dim(&self) -> Color32
Resolves dimming overlay color for timeline regions outside active trim bounds.
Sourcepub fn scrubber_waveform(&self) -> Color32
pub fn scrubber_waveform(&self) -> Color32
Resolves waveform amplitude bar color inside trim scrubber track.
Sourcepub fn scrubber_playhead(&self) -> Color32
pub fn scrubber_playhead(&self) -> Color32
Resolves playhead cursor line and timecode badge accent color.
Sourcepub fn on_accent_text(&self) -> Color32
pub fn on_accent_text(&self) -> Color32
Resolves high-contrast white text color used on accent fills.
Sourcepub fn knob_fill(&self) -> Color32
pub fn knob_fill(&self) -> Color32
Resolves white thumb knob fill color for switches and sliders.
Sourcepub fn drop_shadow(&self) -> Color32
pub fn drop_shadow(&self) -> Color32
Resolves subtle ambient drop shadow color for controls and floating surfaces.
Sourcepub fn backdrop_dim(&self) -> Color32
pub fn backdrop_dim(&self) -> Color32
Resolves modal backdrop dimming overlay color.
Sourcepub fn hud_background(&self) -> Color32
pub fn hud_background(&self) -> Color32
Resolves translucent dark HUD palette background color (SPEC-006 §2.2).
Sourcepub fn hud_border(&self) -> Color32
pub fn hud_border(&self) -> Color32
Resolves dark HUD palette hairline border color.
Sourcepub fn hud_secondary_text(&self) -> Color32
pub fn hud_secondary_text(&self) -> Color32
Resolves dark HUD palette secondary label color.
Sourcepub fn traffic_light_close(&self) -> (Color32, Color32)
pub fn traffic_light_close(&self) -> (Color32, Color32)
Resolves macOS window close traffic light fill and border colors (fill, border).
Sourcepub fn traffic_light_minimize(&self) -> (Color32, Color32)
pub fn traffic_light_minimize(&self) -> (Color32, Color32)
Resolves macOS window minimize traffic light fill and border colors (fill, border).
Sourcepub fn traffic_light_zoom(&self) -> (Color32, Color32)
pub fn traffic_light_zoom(&self) -> (Color32, Color32)
Resolves macOS window zoom/fullscreen traffic light fill and border colors (fill, border).
Sourcepub fn traffic_light_glyph(&self) -> Color32
pub fn traffic_light_glyph(&self) -> Color32
Interior glyph color for hovered macOS traffic light buttons.
Sourcepub fn windows_caption_close_hover_bg(&self) -> Color32
pub fn windows_caption_close_hover_bg(&self) -> Color32
Background color for Windows 11 close caption button on hover (#E81123).
Sourcepub fn windows_caption_close_pressed_bg(&self) -> Color32
pub fn windows_caption_close_pressed_bg(&self) -> Color32
Background color for Windows 11 close caption button when pressed (#C42B1C).
Sourcepub fn windows_caption_hover_bg(&self) -> Color32
pub fn windows_caption_hover_bg(&self) -> Color32
Background color for Windows 11 minimize/maximize caption buttons on hover.
Sourcepub fn windows_caption_pressed_bg(&self) -> Color32
pub fn windows_caption_pressed_bg(&self) -> Color32
Background color for Windows 11 minimize/maximize caption buttons when pressed.
Sourcepub fn scrollbar_thumb_color(&self, active: bool, alpha_factor: f32) -> Color32
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].
Sourcepub fn apply_to_egui(&self, ctx: &Context)
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§
Auto Trait Implementations§
impl Forget for MacTheme
impl Freeze for MacTheme
impl RefUnwindSafe for MacTheme
impl Send for MacTheme
impl Sync for MacTheme
impl Unpin for MacTheme
impl UnsafeUnpin for MacTheme
impl UnwindSafe for MacTheme
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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