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 tracking_for_font_size(&self, size_pt: f32) -> f32
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.
Sourcepub fn semibold_font_id(&self, ui: &Ui, size_pt: f32) -> (FontId, bool)
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.
Sourcepub fn tracked_text_format(&self, font_id: FontId, color: Color32) -> TextFormat
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.
Sourcepub fn layout_tracked_galley(
&self,
ui: &Ui,
text: &str,
font_id: FontId,
color: Color32,
wrap_width: f32,
) -> Arc<Galley> ⓘ
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.
Sourcepub fn control_metrics(&self) -> &MacControlMetrics
pub fn control_metrics(&self) -> &MacControlMetrics
Returns control metrics tokens.
Returns button size and geometry tokens.
Sourcepub fn text_field(&self) -> &TextFieldMetrics
pub fn text_field(&self) -> &TextFieldMetrics
Returns text field and input cell size/geometry tokens.
Sourcepub fn segmented(&self) -> &SegmentedMetrics
pub fn segmented(&self) -> &SegmentedMetrics
Returns segmented control geometry tokens.
Sourcepub fn focus_ring(&self) -> &FocusRingMetrics
pub fn focus_ring(&self) -> &FocusRingMetrics
Returns focus ring halo tokens.
Sourcepub fn toolbar_metrics(&self) -> &ToolbarMetrics
pub fn toolbar_metrics(&self) -> &ToolbarMetrics
Returns toolbar layout and hit-target tokens.
Sourcepub fn popover_metrics(&self) -> &PopoverMetrics
pub fn popover_metrics(&self) -> &PopoverMetrics
Returns popover and floating panel geometry tokens.
Sourcepub fn split_view(&self) -> &SplitViewMetrics
pub fn split_view(&self) -> &SplitViewMetrics
Returns split view divider and pane geometry tokens.
Sourcepub fn layout_metrics(&self) -> &LayoutMetrics
pub fn layout_metrics(&self) -> &LayoutMetrics
Returns layout container metrics (scroll_view, stack_view).
Sourcepub fn scroll_view(&self) -> &ScrollViewMetrics
pub fn scroll_view(&self) -> &ScrollViewMetrics
Returns scroll view overlay scrollbar geometry tokens.
Sourcepub fn stack_view(&self) -> &StackViewMetrics
pub fn stack_view(&self) -> &StackViewMetrics
Returns stack view spacing, padding, and header tokens.
Sourcepub fn outline_view(&self) -> &OutlineViewMetrics
pub fn outline_view(&self) -> &OutlineViewMetrics
Returns outline view row, indentation, and chevron tokens.
Sourcepub fn slider(&self) -> &SliderMetrics
pub fn slider(&self) -> &SliderMetrics
Returns slider track, thumb, and tick tokens.
Sourcepub fn thumbnail(&self) -> &ThumbnailCellMetrics
pub fn thumbnail(&self) -> &ThumbnailCellMetrics
Returns thumbnail cell preview tokens.
Returns pop-up button bezel and menu tokens.
Sourcepub fn search_field(&self) -> &SearchFieldMetrics
pub fn search_field(&self) -> &SearchFieldMetrics
Returns search field pill, icon, and clear button tokens.
Sourcepub fn stepper(&self) -> &StepperMetrics
pub fn stepper(&self) -> &StepperMetrics
Returns numeric stepper control tokens.
Sourcepub fn color_well(&self) -> &ColorWellMetrics
pub fn color_well(&self) -> &ColorWellMetrics
Returns color well swatch and picker tokens.
Sourcepub fn toggle(&self) -> &ToggleMetrics
pub fn toggle(&self) -> &ToggleMetrics
Returns toggle switch (NSSwitch) tokens.
Returns navigation and feedback metrics tokens.
Returns menu bar and dropdown menu tokens.
Returns canvas footer bar tokens.
Sourcepub fn palette_metrics(&self) -> &PaletteMetrics
pub fn palette_metrics(&self) -> &PaletteMetrics
Returns Spotlight command palette tokens.
Returns context menu popup tokens.
Sourcepub fn toast_metrics(&self) -> &ToastMetrics
pub fn toast_metrics(&self) -> &ToastMetrics
Returns floating toast notification tokens.
Sourcepub fn progress_indicator(&self) -> &ProgressIndicatorMetrics
pub fn progress_indicator(&self) -> &ProgressIndicatorMetrics
Returns progress indicator bar and spinning fin tokens.
Sourcepub fn table_view(&self) -> &TableViewMetrics
pub fn table_view(&self) -> &TableViewMetrics
Returns table view and sortable header tokens.
Sourcepub fn token_field(&self) -> &TokenFieldMetrics
pub fn token_field(&self) -> &TokenFieldMetrics
Returns token field pill capsule tokens.
Sourcepub fn level_indicator(&self) -> &LevelIndicatorMetrics
pub fn level_indicator(&self) -> &LevelIndicatorMetrics
Returns level indicator VU meter tokens.
Sourcepub fn trim_scrubber(&self) -> &TrimScrubberMetrics
pub fn trim_scrubber(&self) -> &TrimScrubberMetrics
Returns AVKit trim scrubber timeline tokens.
Sourcepub fn path_control(&self) -> &PathControlMetrics
pub fn path_control(&self) -> &PathControlMetrics
Returns path control breadcrumb bar tokens.
Sourcepub fn disclosure_group(&self) -> &DisclosureGroupMetrics
pub fn disclosure_group(&self) -> &DisclosureGroupMetrics
Returns disclosure group & button tokens.
Sourcepub fn combo_box(&self) -> &ComboBoxMetrics
pub fn combo_box(&self) -> &ComboBoxMetrics
Returns combo box tokens.
Sourcepub fn tab_view(&self) -> &TabViewMetrics
pub fn tab_view(&self) -> &TabViewMetrics
Returns tab view tokens.
Sourcepub fn date_picker(&self) -> &DatePickerMetrics
pub fn date_picker(&self) -> &DatePickerMetrics
Returns date picker tokens.
Sourcepub fn collection_view(&self) -> &CollectionViewMetrics
pub fn collection_view(&self) -> &CollectionViewMetrics
Returns collection view tokens.
Sourcepub fn player_view(&self) -> &PlayerViewMetrics
pub fn player_view(&self) -> &PlayerViewMetrics
Returns player view tokens.
Sourcepub fn box_view(&self) -> &BoxViewMetrics
pub fn box_view(&self) -> &BoxViewMetrics
Returns box view tokens.
Sourcepub fn rule_editor(&self) -> &RuleEditorMetrics
pub fn rule_editor(&self) -> &RuleEditorMetrics
Returns rule editor tokens.
Sourcepub fn checkbox(&self) -> &CheckboxMetrics
pub fn checkbox(&self) -> &CheckboxMetrics
Returns square AppKit checkbox (NSButtonTypeSwitch) tokens.
Sourcepub fn label_metrics(&self) -> &LabelMetrics
pub fn label_metrics(&self) -> &LabelMetrics
Returns non-editable AppKit label (NSTextField.labelWithString:) tokens.
Returns circular AppKit help button (NSBezelStyleHelpButton) tokens.
Returns circular inline action badge button (16x16pt) tokens.
Sourcepub fn typography(&self) -> &MacTypographyTokens
pub fn typography(&self) -> &MacTypographyTokens
Returns typography and SF Pro optical tracking tokens.
Sourcepub fn motion(&self) -> &MacMotionTokens
pub fn motion(&self) -> &MacMotionTokens
Returns CoreAnimation spring physics preset tokens.
Sourcepub fn background_style(&self, surface_bg: Color32) -> MacBackgroundStyle
pub fn background_style(&self, surface_bg: Color32) -> MacBackgroundStyle
Evaluates MacBackgroundStyle for the given background surface color.
Sourcepub fn accent_background_style(&self) -> MacBackgroundStyle
pub fn accent_background_style(&self) -> MacBackgroundStyle
Evaluates MacBackgroundStyle for Self::control_accent (or custom accent override).
Sourcepub fn selected_control_background_style(&self) -> MacBackgroundStyle
pub fn selected_control_background_style(&self) -> MacBackgroundStyle
Evaluates MacBackgroundStyle for Self::selected_control.
Sourcepub fn disabled_opacity(&self) -> f32
pub fn disabled_opacity(&self) -> f32
Returns disabled control opacity factor (0.45).
Sourcepub fn apply_enabled(&self, color: Color32, enabled: bool) -> Color32
pub fn apply_enabled(&self, color: Color32, enabled: bool) -> Color32
Scales color alpha by Self::disabled_opacity when enabled is false.
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 resolve_or_default<'a>(theme: Option<&'a Self>) -> Cow<'a, Self>
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.
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.
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 tertiary_label(&self) -> Color32
pub fn tertiary_label(&self) -> Color32
Resolves tertiaryLabelColor (NSColor) for subtle hints and disabled captions.
Sourcepub fn box_background(&self) -> Color32
pub fn box_background(&self) -> Color32
Resolves recessed container surface color (box_background) for NSBoxPrimary.
Sourcepub fn box_border(&self) -> Color32
pub fn box_border(&self) -> Color32
Resolves perimeter border color (box_border) for NSBoxPrimary.
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.
Trait Implementations§
Auto Trait Implementations§
impl Forget for MacTheme
impl Freeze for MacTheme
impl Move 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