Skip to main content

Style

Struct Style 

Source
pub struct Style {
Show 21 fields pub size: Option<Size>, pub min_size: Option<Size>, pub max_size: Option<Size>, pub padding: Insets, pub gap: f32, pub flex_grow: f32, pub flex_shrink: f32, pub align: Align, pub justify: Justify, pub background: Option<Color>, pub clip: bool, pub fill: bool, pub row_height: f32, pub line_height: Option<f32>, pub font_size: f32, pub color: Option<Color>, pub weight: f32, pub radius: Radius, pub border_width: f32, pub border_color: Option<Color>, pub shadow: Option<Shadow>,
}

Fields§

§size: Option<Size>§min_size: Option<Size>§max_size: Option<Size>§padding: Insets§gap: f32§flex_grow: f32§flex_shrink: f32§align: Align§justify: Justify§background: Option<Color>§clip: bool§fill: bool

Takes the whole content box on the parent’s main axis, which is what a scrollback panel or a virtual list wants.

§row_height: f32§line_height: Option<f32>

Overrides the line box height. None derives it from font_size and the real font metrics, which is what a view spec wants.

§font_size: f32

Font size in pixels, used by text renderers for shaping and metrics.

§color: Option<Color>§weight: f32§radius: Radius

How round this box’s corners are. Zero everywhere means a hard rectangle, which is what every view that never mentions radius gets.

§border_width: f32

Border thickness in pixels, drawn inside the box so it cannot grow it.

§border_color: Option<Color>§shadow: Option<Shadow>

Drawn behind the box, outside its edges.

Implementations§

Source§

impl Style

Source

pub fn size(self, size: Size) -> Self

Source

pub fn width(self, value: f32) -> Self

Source

pub fn height(self, value: f32) -> Self

Source

pub fn min_size(self, size: Size) -> Self

Source

pub fn max_size(self, size: Size) -> Self

Source

pub fn padding(self, value: Insets) -> Self

Source

pub fn gap(self, value: f32) -> Self

Source

pub fn flex_grow(self, value: f32) -> Self

Source

pub fn align(self, value: Align) -> Self

Source

pub fn justify(self, value: Justify) -> Self

Source

pub fn background(self, value: Color) -> Self

Source

pub fn clip(self, value: bool) -> Self

Source

pub fn fill(self, value: bool) -> Self

Source

pub fn row_height(self, value: f32) -> Self

Source

pub fn line_height(self, value: f32) -> Self

Pins the line box height instead of deriving it from the font.

Source

pub fn font_size(self, value: f32) -> Self

Source

pub fn resolved_line_height(&self, font_line_height: f32) -> f32

Resolved line box height for a style, given the font’s own line height.

Source

pub fn color(self, value: Color) -> Self

Source

pub fn weight(self, value: f32) -> Self

Source

pub fn radius(self, value: f32) -> Self

Rounds the corners by the same amount on every corner, which is what a card, a button or an input wants.

Source

pub fn radius_sized(self, radius: Radius) -> Self

Rounds each corner size separately, for a panel that is subtly rounded and a popover that is not.

Source

pub fn border(self, width: f32, color: Color) -> Self

Sets the border width and colour together, because a border with no colour is not a border.

Source

pub fn shadow(self, shadow: Shadow) -> Self

Source

pub fn corner_radius(&self, width: f32, height: f32) -> f32

The radius this box actually draws with, never more than half its shorter side: a radius wider than the box turns the corners inside out.

Source

pub fn border_px(&self) -> f32

The border width this box actually draws with.

Source

pub fn shadow_reach(&self) -> f32

How far this box’s shadow reaches past its edges, so a draw that wants to contain the shadow knows how much room to ask for.

Source

pub fn main_size(&self, axis: Axis) -> Option<f32>

Resolved size along the given axis, if the style pins a non-zero one.

Source

pub fn cross_size(&self, axis: Axis) -> Option<f32>

Resolved size across the given axis, if the style pins a non-zero one.

Trait Implementations§

Source§

impl Clone for Style

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 Style

Source§

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

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

impl Default for Style

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for Style
where Style: Default,

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 Style

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 Serialize for Style

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 Style

Auto Trait Implementations§

§

impl Freeze for Style

§

impl RefUnwindSafe for Style

§

impl Send for Style

§

impl Sync for Style

§

impl Unpin for Style

§

impl UnsafeUnpin for Style

§

impl UnwindSafe for Style

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

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.