pub struct CupertinoDynamicColor {
pub color: Color,
pub dark_color: Color,
pub high_contrast_color: Color,
pub dark_high_contrast_color: Color,
pub elevated_color: Color,
pub dark_elevated_color: Color,
pub high_contrast_elevated_color: Color,
pub dark_high_contrast_elevated_color: Color,
pub debug_label: Option<&'static str>,
}Expand description
A colour that adapts: up to eight values for one name, one for each combination of a light or dark interface, normal or high contrast, and the base or the elevated level.
resolve picks the one that applies where it is used;
resolve_with picks it for conditions given outright. Used as a
plain Color without being resolved (Color::from), it is its light, normal-contrast,
base value, as the reference’s is.
Most colours vary along fewer than three of the axes, and two constructors say so:
with_brightness and
with_brightness_and_contrast. The palette is
CupertinoColors.
use frus_widgets::{Brightness, Color, CupertinoDynamicColor, CupertinoUserInterfaceLevelData};
let ink = CupertinoDynamicColor::with_brightness(Color::rgb8(20, 20, 20), Color::rgb8(240, 240, 240));
let dark = ink.resolve_with(Brightness::Dark, CupertinoUserInterfaceLevelData::Base, false);
assert_eq!(dark, Color::rgb8(240, 240, 240));Fields§
§color: ColorLight, normal contrast, base level.
dark_color: ColorDark, normal contrast, base level.
high_contrast_color: ColorLight, high contrast, base level.
dark_high_contrast_color: ColorDark, high contrast, base level.
elevated_color: ColorLight, normal contrast, elevated.
dark_elevated_color: ColorDark, normal contrast, elevated.
high_contrast_elevated_color: ColorLight, high contrast, elevated.
dark_high_contrast_elevated_color: ColorDark, high contrast, elevated.
debug_label: Option<&'static str>A name to tell it by when it is printed; it takes no part in equality.
Implementations§
Source§impl CupertinoDynamicColor
impl CupertinoDynamicColor
Sourcepub const fn new(
color: Color,
dark_color: Color,
high_contrast_color: Color,
dark_high_contrast_color: Color,
elevated_color: Color,
dark_elevated_color: Color,
high_contrast_elevated_color: Color,
dark_high_contrast_elevated_color: Color,
) -> CupertinoDynamicColor
pub const fn new( color: Color, dark_color: Color, high_contrast_color: Color, dark_high_contrast_color: Color, elevated_color: Color, dark_elevated_color: Color, high_contrast_elevated_color: Color, dark_high_contrast_elevated_color: Color, ) -> CupertinoDynamicColor
A colour that varies along all three axes: all eight values, given outright.
Sourcepub const fn with_brightness_and_contrast(
color: Color,
dark_color: Color,
high_contrast_color: Color,
dark_high_contrast_color: Color,
) -> CupertinoDynamicColor
pub const fn with_brightness_and_contrast( color: Color, dark_color: Color, high_contrast_color: Color, dark_high_contrast_color: Color, ) -> CupertinoDynamicColor
A colour that varies with the brightness and the contrast, and is the same at either level.
Sourcepub const fn with_brightness(
color: Color,
dark_color: Color,
) -> CupertinoDynamicColor
pub const fn with_brightness( color: Color, dark_color: Color, ) -> CupertinoDynamicColor
A colour that varies with the brightness alone.
Sourcepub const fn labelled(self, label: &'static str) -> CupertinoDynamicColor
pub const fn labelled(self, label: &'static str) -> CupertinoDynamicColor
The same colour, printed as label.
Sourcepub fn resolve_with(
&self,
brightness: Brightness,
level: CupertinoUserInterfaceLevelData,
high_contrast: bool,
) -> Color
pub fn resolve_with( &self, brightness: Brightness, level: CupertinoUserInterfaceLevelData, high_contrast: bool, ) -> Color
The value for these conditions: a brightness, a level, and whether the
reader has asked for high_contrast.
Sourcepub fn resolve(&self, theme: &Theme) -> Color
pub fn resolve(&self, theme: &Theme) -> Color
The value where it is used: in the brightness of the Apple-style theme under
theme (CupertinoTheme::brightness_of), at
the level theme says its subtree is at, and in high contrast if the reader has asked
for it (Accessibility::high_contrast, read
from the ambient MediaQuery).
That brightness is the theme’s, not the system’s, unless the theme says otherwise: an application that keeps a light theme on a dark system gets the light values, as the reference’s adaptive colours under its main theme do.
Trait Implementations§
Source§impl Clone for CupertinoDynamicColor
impl Clone for CupertinoDynamicColor
Source§fn clone(&self) -> CupertinoDynamicColor
fn clone(&self) -> CupertinoDynamicColor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for CupertinoDynamicColor
Source§impl Debug for CupertinoDynamicColor
impl Debug for CupertinoDynamicColor
Source§impl From<Color> for CupertinoDynamicColor
A plain colour as an adaptive one: the same in every condition, so that a theme takes
either where it takes a colour.
impl From<Color> for CupertinoDynamicColor
A plain colour as an adaptive one: the same in every condition, so that a theme takes either where it takes a colour.
Source§fn from(c: Color) -> CupertinoDynamicColor
fn from(c: Color) -> CupertinoDynamicColor
Source§impl From<CupertinoDynamicColor> for Color
An adaptive colour used without being resolved: its light, normal-contrast, base value.
impl From<CupertinoDynamicColor> for Color
An adaptive colour used without being resolved: its light, normal-contrast, base value.
Source§fn from(c: CupertinoDynamicColor) -> Color
fn from(c: CupertinoDynamicColor) -> Color
Auto Trait Implementations§
impl Freeze for CupertinoDynamicColor
impl RefUnwindSafe for CupertinoDynamicColor
impl Send for CupertinoDynamicColor
impl Sync for CupertinoDynamicColor
impl Unpin for CupertinoDynamicColor
impl UnsafeUnpin for CupertinoDynamicColor
impl UnwindSafe for CupertinoDynamicColor
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.