Skip to main content

Theme

Struct Theme 

Source
pub struct Theme {
    pub id: ThemeId,
    pub appearance: ThemeAppearance,
    pub colors: ColorTokens,
    pub layout: LayoutTokens,
    pub typography: TypographyTokens,
    pub shape: ShapeTokens,
    pub motion: MotionTokens,
    pub style_slots: ComponentStyleSlots,
    pub extensions: ThemeExtensions,
}

Fields§

§id: ThemeId

Stable identity of this theme — see ThemeId. Serde-defaulted so older serialized themes (which predate the field) still deserialize.

§appearance: ThemeAppearance§colors: ColorTokens§layout: LayoutTokens§typography: TypographyTokens§shape: ShapeTokens§motion: MotionTokens§style_slots: ComponentStyleSlots

Typed Rc<dyn FooStyle> slot bag for theme-wide style installations. None per slot means “use the widget’s local Recipe*Style default”; apps install per-theme overrides via theme.style_slots.button = Some(Rc::new(MyButton)). Per-call .style(...) on a widget always wins over the slot.

§extensions: ThemeExtensions

Implementations§

Source§

impl Theme

Source

pub fn new( appearance: ThemeAppearance, colors: ColorTokens, layout: LayoutTokens, typography: TypographyTokens, shape: ShapeTokens, motion: MotionTokens, ) -> Self

Build a Theme from raw token data. Most apps go through a preset constructor (e.g. teksilo_core::presets::intui::light) rather than calling this directly — presets aggregate the matching Recipe*Style defaults under the same call.

Source

pub fn with_id(self, id: impl Into<Cow<'static, str>>) -> Self

Set this theme’s ThemeId and return self for chaining. Used by preset constructors and apps building custom themes.

Source

pub fn is_dark(&self) -> bool

Whether this theme paints on a dark background. Convenience for theme.appearance.is_dark().

Source

pub fn for_inactive_window(&self) -> Theme

A copy of this theme projected for an inactive window — the accent family and focus indicators desaturated toward graphite (see ColorTokens::for_inactive_window). The paint walker swaps this in when the host window loses focus, so every accent-coloured control greys out with no per-widget code. Only the colours change; typography / layout / shape / motion are untouched, so this never affects layout.

Source

pub fn for_high_contrast(&self) -> Theme

Project into a high-contrast variant (WCAG 1.4.6 Enhanced / EN 301 549 §11.7), applied at paint time when the OS “increase contrast” preference is set. See ColorTokens::for_high_contrast.

Source

pub fn extension<T: Any + Send + Sync>(&self) -> Option<&T>

Look up a typed theme extension. See ThemeExtensions.

Source

pub fn with_extension<T: Any + Send + Sync>(self, value: T) -> Self

Attach a typed extension and return self for chaining. See ThemeExtensions.

Trait Implementations§

Source§

impl Clone for Theme

Source§

fn clone(&self) -> Theme

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 Debug for Theme

Source§

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

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

impl<'de> Deserialize<'de> for Theme

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Theme

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Serialize for Theme

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Theme

Auto Trait Implementations§

§

impl !RefUnwindSafe for Theme

§

impl !Send for Theme

§

impl !Sync for Theme

§

impl !UnwindSafe for Theme

§

impl Freeze for Theme

§

impl Unpin for Theme

§

impl UnsafeUnpin for Theme

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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, <T as TryFrom<U>>::Error>

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.