Skip to main content

Style

Struct Style 

Source
#[non_exhaustive]
pub struct Style {
Show 18 fields pub font: Option<Font>, pub size: Option<Bindable<f64>>, pub weight: Option<Bindable<FontWeight>>, pub design: Option<FontDesign>, pub font_family: Option<String>, pub monospaced_digit: Option<bool>, pub color: Option<Bindable<Color>>, pub line_limit: Option<u8>, pub minimum_scale_factor: Option<f64>, pub alignment: Option<HorizontalAlignment>, pub padding: Option<Padding>, pub frame: Option<Frame>, pub background: Option<Bindable<Color>>, pub corner_radius: Option<Bindable<f64>>, pub opacity: Option<Bindable<f64>>, pub tint: Option<Bindable<Color>>, pub button_style: Option<ButtonStyle>, pub content_transition: Option<ContentTransition>,
}
Expand description

Modifiers a node takes through its style token. At least one member; font and size exclude each other, and so do font_family and design. The Bindable members may name a value instead of a literal; the others are fixed at start.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§font: Option<Font>§size: Option<Bindable<f64>>

Font size in points.

§weight: Option<Bindable<FontWeight>>§design: Option<FontDesign>§font_family: Option<String>

The PostScript or family name of a font that the widget extension bundles (listed under UIAppFonts in its Info.plist). With font it takes that text style’s size, with size that size; not together with design. A name the extension lacks draws the system font.

§monospaced_digit: Option<bool>§color: Option<Bindable<Color>>

Foreground color.

§line_limit: Option<u8>§minimum_scale_factor: Option<f64>§alignment: Option<HorizontalAlignment>

Alignment of text that spans several lines.

§padding: Option<Padding>§frame: Option<Frame>§background: Option<Bindable<Color>>§corner_radius: Option<Bindable<f64>>§opacity: Option<Bindable<f64>>§tint: Option<Bindable<Color>>

Tint of buttons, toggles, progress views and gauges.

§button_style: Option<ButtonStyle>§content_transition: Option<ContentTransition>

How text and symbols change when their value does.

Implementations§

Source§

impl Style

Builders for each member. A member that takes Bindable also takes Bound.

Source

pub fn new() -> Style

Source

pub fn font(self, font: Font) -> Style

A system text style; not together with size.

Source

pub fn size(self, points: impl Into<Bindable<f64>>) -> Style

The font size, 6 to 96 points.

Source

pub fn weight(self, weight: impl Into<Bindable<FontWeight>>) -> Style

Source

pub fn design(self, design: FontDesign) -> Style

Not together with font_family.

Source

pub fn font_family(self, name: impl Into<String>) -> Style

A font that the widget extension bundles, by its PostScript or family name.

Source

pub fn monospaced_digit(self) -> Style

Digits of equal width.

Source

pub fn color(self, color: impl Into<Bindable<Color>>) -> Style

The foreground color.

Source

pub fn line_limit(self, lines: u8) -> Style

At most this many lines, 1 to 10.

Source

pub fn minimum_scale_factor(self, factor: f64) -> Style

How far text may shrink to fit, 0.1 to 1.

Source

pub fn alignment(self, alignment: HorizontalAlignment) -> Style

The alignment of text that spans several lines.

Source

pub fn padding(self, padding: impl Into<Padding>) -> Style

One number for every edge, or [top, leading, bottom, trailing], each 0 to 64 points.

Source

pub fn frame(self, frame: Frame) -> Style

Source

pub fn background(self, color: impl Into<Bindable<Color>>) -> Style

Source

pub fn corner_radius(self, points: impl Into<Bindable<f64>>) -> Style

0 to 64 points.

Source

pub fn opacity(self, opacity: impl Into<Bindable<f64>>) -> Style

0 to 1.

Source

pub fn tint(self, color: impl Into<Bindable<Color>>) -> Style

The tint of buttons, progress bars and gauges.

Source

pub fn content_transition(self, transition: ContentTransition) -> Style

How text and symbols with this style change when an update gives them another value.

Source

pub fn button_style(self, style: ButtonStyle) -> Style

Trait Implementations§

Source§

impl Clone for Style

Source§

fn clone(&self) -> Style

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 Style

Source§

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

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

impl Default for Style

Source§

fn default() -> Style

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Style

Source§

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

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

impl PartialEq for Style

Source§

fn eq(&self, other: &Style) -> 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 Style

Source§

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

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

impl StructuralPartialEq for Style

Auto Trait Implementations§

§

impl Forget for Style

§

impl Freeze for Style
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze,

§

impl Move for Style

§

impl RefUnwindSafe for Style

§

impl Send for Style
where RawVecInner: Send,

§

impl Sync for Style
where RawVecInner: Sync,

§

impl Unpin for Style
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for Style

§

impl UnwindSafe for Style
where RawVecInner: 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> 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more