pub struct ThemeManager { /* private fields */ }Implementations§
Source§impl ThemeManager
impl ThemeManager
Sourcepub fn from_variants(
variants: impl IntoIterator<Item = ThemeVariant>,
selection: ThemeSelection,
) -> Result<Self, ThemeError>
pub fn from_variants( variants: impl IntoIterator<Item = ThemeVariant>, selection: ThemeSelection, ) -> Result<Self, ThemeError>
Build families from independent variants and select one fixed variant. Families that only provide one color mode use their first variant as the fallback for the unavailable system appearance.
§Errors
Returns ThemeError for duplicates, invalid variants, or an unknown
initial selection.
Sourcepub fn new(
families: impl IntoIterator<Item = ThemeFamily>,
app: ThemePreference,
) -> Result<Self, ThemeError>
pub fn new( families: impl IntoIterator<Item = ThemeFamily>, app: ThemePreference, ) -> Result<Self, ThemeError>
Create a manager with a validated app preference.
§Errors
Returns ThemeError if the preference cannot resolve in the supplied
family set.
Sourcepub fn register_family(&mut self, family: ThemeFamily) -> Result<(), ThemeError>
pub fn register_family(&mut self, family: ThemeFamily) -> Result<(), ThemeError>
Sourcepub fn replace_variant(
&mut self,
variant: ThemeVariant,
) -> Result<(), ThemeError>
pub fn replace_variant( &mut self, variant: ThemeVariant, ) -> Result<(), ThemeError>
Replace one already-registered variant and advance the theme generation.
This is the host-facing path for live theme editors. Identity cannot be changed in place; callers create a new manager when families are added or removed.
§Errors
Returns validation or unknown-selection errors.
Sourcepub fn set_app(&mut self, preference: ThemePreference) -> Result<(), ThemeError>
pub fn set_app(&mut self, preference: ThemePreference) -> Result<(), ThemeError>
Change the application fallback preference.
§Errors
Returns ThemeError when the selection cannot resolve.
Sourcepub fn set_window(
&mut self,
window: impl Into<String>,
preference: ThemePreference,
) -> Result<(), ThemeError>
pub fn set_window( &mut self, window: impl Into<String>, preference: ThemePreference, ) -> Result<(), ThemeError>
pub fn remove_window(&mut self, window: &str) -> bool
pub fn remove_scope(&mut self, scope: &ComponentInstancePath) -> bool
Sourcepub fn set_scope(
&mut self,
scope: ComponentInstancePath,
preference: ThemePreference,
) -> Result<(), ThemeError>
pub fn set_scope( &mut self, scope: ComponentInstancePath, preference: ThemePreference, ) -> Result<(), ThemeError>
Set a local theme preference for a component subtree.
§Errors
Returns ThemeError when the preference cannot resolve.
pub const fn generation(&self) -> u64
pub fn app_preference(&self) -> &ThemePreference
Sourcepub fn resolve(
&self,
window: Option<&str>,
component: Option<&ComponentInstancePath>,
system: SystemAppearance,
) -> Result<ResolvedTheme<'_>, ThemeError>
pub fn resolve( &self, window: Option<&str>, component: Option<&ComponentInstancePath>, system: SystemAppearance, ) -> Result<ResolvedTheme<'_>, ThemeError>
Resolve the nearest active theme without changing scripts or UI state.
§Errors
Returns ThemeError if an internally stored preference no longer
resolves after malformed deserialization.
Trait Implementations§
Source§impl Clone for ThemeManager
impl Clone for ThemeManager
Auto Trait Implementations§
impl Freeze for ThemeManager
impl RefUnwindSafe for ThemeManager
impl Send for ThemeManager
impl Sync for ThemeManager
impl Unpin for ThemeManager
impl UnsafeUnpin for ThemeManager
impl UnwindSafe for ThemeManager
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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Variant for T
impl<T> Variant for T
Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Variant trait object to &mut dyn Any.Source§fn as_boxed_any(self: Box<T>) -> Box<dyn Any>
fn as_boxed_any(self: Box<T>) -> Box<dyn Any>
Variant trait object to Box<dyn Any>.