pub struct DesignTokensAdapter {
pub border_radius: f32,
pub body_font_size: f32,
pub headline_font_size: f32,
pub base_spacing: f32,
}Expand description
Applies DesignTokens and TypographyScale to produce iced-compatible
style values for use in per-widget style helpers.
iced 0.14 has no global style-override hook — styles are set per-widget
(e.g. button::style, text_input::style). DesignTokensAdapter exposes
the token values as iced primitives so callers can apply them at the widget
call site without repeating the token-field mapping.
§Example
use oxiui_iced::DesignTokensAdapter;
use oxiui_theme::{DesignTokens, TypographyScale};
let adapter = DesignTokensAdapter::from_tokens(
&DesignTokens::default(),
&TypographyScale::default(),
);
assert!(adapter.body_font_size > 0.0);
let _padding = adapter.standard_padding();
let _body_sz = adapter.body_text_size();Fields§
§border_radius: f32Medium border radius in logical pixels (mapped from RadiusStep::Md).
body_font_size: f32Body font size in logical pixels (from TypographyScale::body.size).
headline_font_size: f32Headline font size in logical pixels (from TypographyScale::headline.size).
base_spacing: f32Base spacing in logical pixels (mapped from SpacingStep::Sm, 8 px by default).
Implementations§
Source§impl DesignTokensAdapter
impl DesignTokensAdapter
Sourcepub fn from_tokens(tokens: &DesignTokens, typography: &TypographyScale) -> Self
pub fn from_tokens(tokens: &DesignTokens, typography: &TypographyScale) -> Self
Build an adapter from references to a DesignTokens and a
TypographyScale.
Field mapping:
border_radius←tokens.radius(RadiusStep::Md)(4.0 px by default)body_font_size←typography.body.size(14.0 px by default)headline_font_size←typography.headline.size(24.0 px by default)base_spacing←tokens.spacing(SpacingStep::Sm)(8.0 px by default)
Sourcepub fn body_text_size(&self) -> Pixels
pub fn body_text_size(&self) -> Pixels
Returns an iced text size for body text.
Sourcepub fn headline_text_size(&self) -> Pixels
pub fn headline_text_size(&self) -> Pixels
Returns an iced text size for headlines.
Sourcepub fn standard_padding(&self) -> Padding
pub fn standard_padding(&self) -> Padding
Returns an iced iced::Padding with uniform padding equal to
base_spacing on all sides.
Trait Implementations§
Source§impl Clone for DesignTokensAdapter
impl Clone for DesignTokensAdapter
Source§fn clone(&self) -> DesignTokensAdapter
fn clone(&self) -> DesignTokensAdapter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for DesignTokensAdapter
Source§impl Debug for DesignTokensAdapter
impl Debug for DesignTokensAdapter
Source§impl PartialEq for DesignTokensAdapter
impl PartialEq for DesignTokensAdapter
Source§fn eq(&self, other: &DesignTokensAdapter) -> bool
fn eq(&self, other: &DesignTokensAdapter) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for DesignTokensAdapter
Auto Trait Implementations§
impl Freeze for DesignTokensAdapter
impl RefUnwindSafe for DesignTokensAdapter
impl Send for DesignTokensAdapter
impl Sync for DesignTokensAdapter
impl Unpin for DesignTokensAdapter
impl UnsafeUnpin for DesignTokensAdapter
impl UnwindSafe for DesignTokensAdapter
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<State, Message> IntoBoot<State, Message> for State
impl<State, Message> IntoBoot<State, Message> for State
Source§fn into_boot(self) -> (State, Task<Message>)
fn into_boot(self) -> (State, Task<Message>)
Application.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 more