Skip to main content

ThemeDefinition

Struct ThemeDefinition 

Source
pub struct ThemeDefinition { /* private fields */ }
Expand description

一份主题定义:基表 + scale + 覆盖。

只描述“改了什么“,不预先算结果 —— ThemeDefinition::resolve 才是实际取值, 所以一份定义可以同时服务明暗两档。

Implementations§

Source§

impl ThemeDefinition

Source

pub fn named(self, name: impl Into<String>) -> Self

主题名(Astryx defineTheme({ name }))。

Source

pub fn name(&self) -> &str

Source

pub fn radius_multiplier(self, multiplier: f32) -> Self

半径倍率(Astryx radius.multiplier,0–2)。--radius-none / --radius-full 不受影响。

Source

pub fn radius_base(self, base: f32) -> Self

半径基准(Astryx radius.base,px)。

Source

pub fn text_scale(self, base: f32, ratio: f32) -> Self

字号锚点 + 台阶比(Astryx typography.scale)。

Source

pub fn motion_scale( self, fast_ms: f32, medium_ms: f32, slow_ms: f32, ratio: f32, ) -> Self

动效节奏(Astryx motion;单位 ms,min/max 按 ratio 生成)。

Source

pub fn scales(&self) -> Scales

Source

pub fn token(self, name: &str, value: &str) -> Result<Self, TokenError>

覆盖单个 token(Astryx 变量名 + 字面量)。

Source

pub fn set_token(&mut self, name: &str, value: &str) -> Result<(), TokenError>

ThemeDefinition::token 的 &mut self 版本 —— 循环里构造主题时不用来回搬 self。

Source

pub fn set_color(&mut self, token: ColorToken, light: Color, dark: Color)

ThemeDefinition::color 的 &mut self 版本。

Source

pub fn color(self, token: ColorToken, light: Color, dark: Color) -> Self

覆盖 color token 的便捷写法:明暗两档分别给 Color。

Source

pub fn tokens(self, overrides: TokenOverrides) -> Self

Source

pub fn overrides(&self) -> &TokenOverrides

Source

pub fn resolve(&self, dark: bool) -> Tokens

解析成某个明暗档下的实际 token 取值。

Trait Implementations§

Source§

impl Clone for ThemeDefinition

Source§

fn clone(&self) -> Self

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 ThemeDefinition

Source§

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

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

impl PartialEq for ThemeDefinition

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ThemeDefinition

Auto Trait Implementations§

§

impl Forget for ThemeDefinition

§

impl Freeze for ThemeDefinition
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const LeafNode<String, String> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, String)>>: Freeze,

§

impl Move for ThemeDefinition

§

impl RefUnwindSafe for ThemeDefinition

§

impl Send for ThemeDefinition
where RawVecInner: Send, NodeRef<Owned, String, String, LeafOrInternal>: Send, BoxRaw<(String, String)>: Send,

§

impl Sync for ThemeDefinition
where RawVecInner: Sync, NodeRef<Owned, String, String, LeafOrInternal>: Sync, BoxRaw<(String, String)>: Sync,

§

impl Unpin for ThemeDefinition
where *const u8 is !null: Unpin, *const LeafNode<String, String> is !null: Unpin, Box<(String, String)>: Unpin,

§

impl UnsafeUnpin for ThemeDefinition
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const LeafNode<String, String> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(String, String)>>: UnsafeUnpin,

§

impl UnwindSafe for ThemeDefinition
where RawVecInner: UnwindSafe, BTreeMap<String, String>: UnwindSafe,

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> 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, !>

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.