pub struct ThemeDefinition { /* private fields */ }Expand description
一份主题定义:基表 + scale + 覆盖。
只描述“改了什么“,不预先算结果 —— ThemeDefinition::resolve 才是实际取值,
所以一份定义可以同时服务明暗两档。
Implementations§
Source§impl ThemeDefinition
impl ThemeDefinition
pub fn name(&self) -> &str
Sourcepub fn radius_multiplier(self, multiplier: f32) -> Self
pub fn radius_multiplier(self, multiplier: f32) -> Self
半径倍率(Astryx radius.multiplier,0–2)。--radius-none / --radius-full 不受影响。
Sourcepub fn radius_base(self, base: f32) -> Self
pub fn radius_base(self, base: f32) -> Self
半径基准(Astryx radius.base,px)。
Sourcepub fn text_scale(self, base: f32, ratio: f32) -> Self
pub fn text_scale(self, base: f32, ratio: f32) -> Self
字号锚点 + 台阶比(Astryx typography.scale)。
Sourcepub fn motion_scale(
self,
fast_ms: f32,
medium_ms: f32,
slow_ms: f32,
ratio: f32,
) -> Self
pub fn motion_scale( self, fast_ms: f32, medium_ms: f32, slow_ms: f32, ratio: f32, ) -> Self
动效节奏(Astryx motion;单位 ms,min/max 按 ratio 生成)。
pub fn scales(&self) -> Scales
Sourcepub fn token(self, name: &str, value: &str) -> Result<Self, TokenError>
pub fn token(self, name: &str, value: &str) -> Result<Self, TokenError>
覆盖单个 token(Astryx 变量名 + 字面量)。
Sourcepub fn set_token(&mut self, name: &str, value: &str) -> Result<(), TokenError>
pub fn set_token(&mut self, name: &str, value: &str) -> Result<(), TokenError>
ThemeDefinition::token 的 &mut self 版本 —— 循环里构造主题时不用来回搬 self。
Sourcepub fn set_color(&mut self, token: ColorToken, light: Color, dark: Color)
pub fn set_color(&mut self, token: ColorToken, light: Color, dark: Color)
ThemeDefinition::color 的 &mut self 版本。
Sourcepub fn color(self, token: ColorToken, light: Color, dark: Color) -> Self
pub fn color(self, token: ColorToken, light: Color, dark: Color) -> Self
覆盖 color token 的便捷写法:明暗两档分别给 Color。
pub fn tokens(self, overrides: TokenOverrides) -> Self
pub fn overrides(&self) -> &TokenOverrides
Trait Implementations§
Source§impl Clone for ThemeDefinition
impl Clone for ThemeDefinition
Source§impl Debug for ThemeDefinition
impl Debug for ThemeDefinition
Source§impl PartialEq for ThemeDefinition
impl PartialEq for ThemeDefinition
impl StructuralPartialEq for ThemeDefinition
Auto Trait Implementations§
impl Forget for ThemeDefinition
impl Freeze for ThemeDefinition
impl Move for ThemeDefinition
impl RefUnwindSafe for ThemeDefinition
impl Send for ThemeDefinition
impl Sync for ThemeDefinition
impl Unpin for ThemeDefinition
impl UnsafeUnpin for ThemeDefinitionwhere
*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
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
Mutably borrows from an owned value. Read more