pub enum MacBackgroundStyle {
Light,
Dark,
}Expand description
macOS AppKit background style (NSBackgroundStyle).
Indicates whether an element’s background is light or dark, allowing child text, icons, and accessories to select high-contrast tints that satisfy WCAG 2.1 AA.
Variants§
Light
Background is light (relative luminance L > 0.179). Use dark foreground text.
Dark
Background is dark (relative luminance L <= 0.179). Use light/white foreground text.
Implementations§
Source§impl MacBackgroundStyle
impl MacBackgroundStyle
Sourcepub fn from_color(bg: Color32) -> Self
pub fn from_color(bg: Color32) -> Self
Resolves MacBackgroundStyle from a background color’s WCAG 2.1 relative luminance.
For neutral / low-saturation backgrounds, applies the normative WCAG 2.1 AA threshold L = 0.179:
L <= 0.179=>Darkstyle (white text guarantees >= 4.5:1 contrast)L > 0.179=>Lightstyle (dark text guarantees >= 4.5:1 contrast)
For saturated chromatic fills (such as Apple System Blue #007AFF / #0A84FF),
macOS AppKit filled controls use high-contrast white text (Dark style),
satisfying WCAG 2.1 §1.4.11 / §1.4.3 UI Component / Control AA (>= 3.0:1) with L <= 0.26.
Sourcepub fn primary_text_color(&self, theme: &MacTheme) -> Color32
pub fn primary_text_color(&self, theme: &MacTheme) -> Color32
Primary text color guaranteeing >= 4.5:1 WCAG contrast against this background.
Dark=> 100% white (#FFFFFF)Light=> dark primary label color from Aqua tokens (#262626)
Sourcepub fn secondary_text_color(&self, theme: &MacTheme) -> Color32
pub fn secondary_text_color(&self, theme: &MacTheme) -> Color32
Secondary text color (subtitles, captions, metadata).
Dark=> 85% white (rgba(255, 255, 255, 0.85))Light=> dark secondary label color from Aqua tokens (#6E6E73)
Sourcepub fn tertiary_text_color(&self, theme: &MacTheme) -> Color32
pub fn tertiary_text_color(&self, theme: &MacTheme) -> Color32
Tertiary text color (placeholders, disabled hints).
Dark=> 70% white (rgba(255, 255, 255, 0.70))Light=> dark placeholder text color from Aqua tokens
Sourcepub fn primary_text(&self) -> Color32
pub fn primary_text(&self) -> Color32
Standalone primary text color without requiring a MacTheme reference.
Sourcepub fn secondary_text(&self) -> Color32
pub fn secondary_text(&self) -> Color32
Standalone secondary text color without requiring a MacTheme reference.
Sourcepub fn tertiary_text(&self) -> Color32
pub fn tertiary_text(&self) -> Color32
Standalone tertiary text color without requiring a MacTheme reference.
Trait Implementations§
Source§impl Clone for MacBackgroundStyle
impl Clone for MacBackgroundStyle
impl Copy for MacBackgroundStyle
Source§impl Debug for MacBackgroundStyle
impl Debug for MacBackgroundStyle
Source§impl Default for MacBackgroundStyle
impl Default for MacBackgroundStyle
impl Eq for MacBackgroundStyle
Source§impl PartialEq for MacBackgroundStyle
impl PartialEq for MacBackgroundStyle
impl StructuralPartialEq for MacBackgroundStyle
Auto Trait Implementations§
impl Forget for MacBackgroundStyle
impl Freeze for MacBackgroundStyle
impl RefUnwindSafe for MacBackgroundStyle
impl Send for MacBackgroundStyle
impl Sync for MacBackgroundStyle
impl Unpin for MacBackgroundStyle
impl UnsafeUnpin for MacBackgroundStyle
impl UnwindSafe for MacBackgroundStyle
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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