pub struct ThemeService { /* private fields */ }Expand description
The theme, as a service: read it, ask for another (installed between
frames), and choose between its light and dark variants when it has
a counterpart (the SETTING_THEME_PREFERENCE setting).
Implementations§
Source§impl ThemeService
impl ThemeService
pub fn spec(&self) -> ThemeSpec
Sourcepub fn set(&self, spec: ThemeSpec)
pub fn set(&self, spec: ThemeSpec)
Asks for a theme; installed before the next frame, which it asks for (an idle window does not wait for input to show it).
Sourcepub fn update(&self, f: impl FnOnce(&mut ThemeSpec))
pub fn update(&self, f: impl FnOnce(&mut ThemeSpec))
Changes the theme in place; installed before the next frame, which it asks for when the spec changed.
pub fn themes(&self) -> &Themes
Sourcepub fn kits(&self) -> &[KitInfo]
pub fn kits(&self) -> &[KitInfo]
The kits added (AppBuilder::kit, then the user’s kits), each a
theme of ThemeService::themes under its name, a kit holding
both variants listed once per variant: what a theme picker lists.
Sourcepub fn preference(&self) -> ThemePreference
pub fn preference(&self) -> ThemePreference
The light or dark mode asked for (the SETTING_THEME_PREFERENCE
setting): the system’s by default. It chooses between the theme
and its counterpart; a theme alone keeps its own mode.
Sourcepub fn set_preference(&self, preference: ThemePreference)
pub fn set_preference(&self, preference: ThemePreference)
Asks for a light or dark mode, or the system’s (written to the setting); applied before the next frame.
Sourcepub fn accent_color(&self) -> Option<Color>
pub fn accent_color(&self) -> Option<Color>
The accent’s seed colour, when the accent is generated from one
(ThemeSpec::accent_color): the SETTING_ACCENT_COLOR
setting, or the spec’s own.
Sourcepub fn set_accent_color(&self, seed: Option<Color>)
pub fn set_accent_color(&self, seed: Option<Color>)
Generates the accent from a colour, for the theme and its
counterpart (each its own ramp, light or dark), or goes back to
the theme’s own accent (None). Written to the
SETTING_ACCENT_COLOR setting and the spec; installed before
the next frame.
Sourcepub fn counterpart(&self) -> Option<String>
pub fn counterpart(&self) -> Option<String>
The theme’s counterpart, its other variant, if it has one.
Sourcepub fn shown(&self, ctx: &Context) -> String
pub fn shown(&self, ctx: &Context) -> String
The theme shown with the preference: the spec’s base, or its
counterpart when the preference (or the system’s mode, with
System) asks for the other mode.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ThemeService
impl RefUnwindSafe for ThemeService
impl Send for ThemeService
impl Sync for ThemeService
impl Unpin for ThemeService
impl UnsafeUnpin for ThemeService
impl UnwindSafe for ThemeService
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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