pub struct ThemeExtensions { /* private fields */ }Expand description
The design-token vocabulary: the Theme bundle plus its
component token tables, flat-re-exported from frust-theme so app code
never names that crate directly. A root component reads the active theme via
use_context::<Theme>(); a widget reads it during paint/layout via
PaintCtx::theme_as/LayoutCtx::theme_as (or Theme::from_paint_ctx).
Includes the glass material tokens — this crate ships the opaque recipe, and a design system authors its own translucent one over the same types:
use frust::GlassScale;
let glass = GlassScale::opaque_material();
assert_eq!(glass.chrome.blur_radius_intent, 0.0);
assert!(glass.control.is_opaque());Also the composable-theming surface:
ThemeBuilder (defineTheme/copyWith analog), the no-lock-in typed
extension slot (ThemeExtensions) plus its first consumer
StatusPalette/StatusColors (success/warning/info), and the motion
vocabulary (MotionDurations/EasingSet) — all flat-re-exported so an
app (or a design-system plugin) authors a theme against frust::* alone.
A persistent, typed extension map: any 'static + Send + Sync type can be
attached once (a later insert of the same type replaces
it) and recovered by type via get.
Send + Sync bounds match crate::theme::Theme’s own crossing of
frust-shell-common’s process-global Mutex<OverrideSlot> (see that
module’s thread contract) — an extension type that isn’t Send + Sync
simply can’t be inserted, a compile-time guarantee rather than a runtime
one.
Implementations§
Source§impl ThemeExtensions
impl ThemeExtensions
Sourcepub fn new() -> ThemeExtensions
pub fn new() -> ThemeExtensions
An empty extension map.
Sourcepub fn insert<T>(&mut self, ext: T)
pub fn insert<T>(&mut self, ext: T)
Attach ext, keyed by its concrete type T. A later insert::<T>
call replaces whatever T was previously attached (last write wins,
mirroring HashMap::insert).
Sourcepub fn get<T>(&self) -> Option<&T>
pub fn get<T>(&self) -> Option<&T>
Recover the attached T, or None if nothing of that type was ever
inserted — never a panic on a type that isn’t there.
Trait Implementations§
Source§impl Clone for ThemeExtensions
impl Clone for ThemeExtensions
Source§fn clone(&self) -> ThemeExtensions
fn clone(&self) -> ThemeExtensions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ThemeExtensions
impl Debug for ThemeExtensions
Source§impl Default for ThemeExtensions
impl Default for ThemeExtensions
Source§fn default() -> ThemeExtensions
fn default() -> ThemeExtensions
Auto Trait Implementations§
impl !RefUnwindSafe for ThemeExtensions
impl !UnwindSafe for ThemeExtensions
impl Freeze for ThemeExtensions
impl Send for ThemeExtensions
impl Sync for ThemeExtensions
impl Unpin for ThemeExtensions
impl UnsafeUnpin for ThemeExtensions
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> Brush for 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.