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: 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 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 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 apply_to_egui(&self, ctx: &Context)
pub fn apply_to_egui(&self, ctx: &Context)
Synchronizes egui::Context theme and visuals with the macOS appearance.
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 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 system_green(&self) -> Color32
pub fn system_green(&self) -> Color32
Resolves Apple system green semantic color (systemGreenColor).
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 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 (Fluent crimson red #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 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.
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