Skip to main content

SystemColor

Enum SystemColor 

Source
#[repr(u8)]
pub enum SystemColor {
Show 16 variants Accent = 0, Text = 1, SecondaryText = 2, Background = 3, Surface = 4, TertiaryText = 5, Placeholder = 6, Link = 7, Separator = 8, ControlFill = 9, GroupedBackground = 10, ElevatedSurface = 11, Selection = 12, Destructive = 13, Success = 14, Warning = 15,
}
Expand description

A platform color role: what a color means, which each toolkit answers with its own palette (docs/color.md “System colors”). Pass a role wherever a color is taken (.background(SystemColor::Surface), label(..).color(SystemColor::Link)) and the view follows the appearance, the accent and the contrast setting.

Every role maps to a real platform color on every toolkit, or to the documented light/dark pair in SystemColor::fallback where a platform has none.

Variants§

§

Accent = 0

The app’s accent: selection, the prominent button, a focus ring.

§

Text = 1

Primary text.

§

SecondaryText = 2

De-emphasized text: a caption, a detail line.

§

Background = 3

The window’s content background.

§

Surface = 4

A region set off from the background: a panel, a card, a sidebar.

§

TertiaryText = 5

Text a step quieter than secondary: a disabled-looking hint, a footnote.

§

Placeholder = 6

A text field’s placeholder.

A link in running text.

§

Separator = 8

A hairline between items: a rule, a list separator, a grid line.

§

ControlFill = 9

The fill of a control’s track or well: a slider’s track, a segmented control’s background, a search field.

§

GroupedBackground = 10

The background behind grouped sections (an inset grouped list, a settings page).

§

ElevatedSurface = 11

A surface raised above the content: a popover, a menu, a sheet in dark appearance.

§

Selection = 12

The highlight behind selected text or selected content the app draws itself. Text keeps its own color on it.

§

Destructive = 13

A destructive action or an error.

§

Success = 14

Success, a value that rose.

§

Warning = 15

A warning, something to notice.

Implementations§

Source§

impl SystemColor

Source

pub const COUNT: usize = 16

How many roles there are: the length of SystemColor::ALL and of a Palette.

Source

pub const ALL: [Self; 16]

All roles, in discriminant order (the wire order: a role crosses JNI, C++ and JS as its position here).

Source

pub const fn wire(self) -> u8

The role as its wire number: its position in SystemColor::ALL.

Source

pub const fn from_wire(n: u8) -> Option<SystemColor>

The role with wire number n, if there is one.

Source

pub const fn with_alpha(self, alpha: f64) -> Ink

This role at opacity alpha, replacing the role’s own alpha: a wash of the accent behind a selected chip (SystemColor::Accent.with_alpha(0.14)).

Source

pub const fn fallback(self, dark: bool) -> Color

Day’s own light/dark pair for the role: what a toolkit answers where its platform has no such color, and what Palette::fallback holds. Fixed sRGB colors, close to the Apple system palette, not an approximation of a user-chosen accent.

Trait Implementations§

Source§

impl Clone for SystemColor

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 Copy for SystemColor

Source§

impl Debug for SystemColor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for SystemColor

Source§

impl From<SystemColor> for Ink

Source§

fn from(role: SystemColor) -> Self

Converts to this type from the input type.
Source§

impl From<SystemColor> for Paint

Source§

fn from(role: SystemColor) -> Self

Converts to this type from the input type.
Source§

impl Hash for SystemColor

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for SystemColor

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SystemColor

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<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> 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.