Skip to main content

ItemStyle

Struct ItemStyle 

Source
pub struct ItemStyle {
Show 27 fields pub w: Option<Length>, pub h: Option<Length>, pub min_w: Option<Length>, pub min_h: Option<Length>, pub max_w: Option<Length>, pub max_h: Option<Length>, pub grow: Option<f32>, pub shrink: Option<f32>, pub basis: Option<Length>, pub align_self: Option<AlignSelf>, pub m: Option<Length>, pub mx: Option<Length>, pub my: Option<Length>, pub mt: Option<Length>, pub mr: Option<Length>, pub mb: Option<Length>, pub ml: Option<Length>, pub p: Option<Length>, pub px: Option<Length>, pub py: Option<Length>, pub pt: Option<Length>, pub pr: Option<Length>, pub pb: Option<Length>, pub pl: Option<Length>, pub col_span: Option<u16>, pub row_span: Option<u16>, pub paint: PaintStyle,
}
Expand description

The layout attributes every element accepts, as a flex/grid item.

Every setter takes impl Into<Length>, so .w(120.0), .w("50%") and .w(Length::Auto) all work; rsx! passes literals straight through.

It carries the item’s PaintStyle too, reached through setters of the same names (.bg(..), .border(..)), so one prop is the whole vocabulary.

Fields§

§w: Option<Length>

width.

§h: Option<Length>

height.

§min_w: Option<Length>

min-width.

§min_h: Option<Length>

min-height.

§max_w: Option<Length>

max-width.

§max_h: Option<Length>

max-height.

§grow: Option<f32>

flex-grow.

§shrink: Option<f32>

flex-shrink.

§basis: Option<Length>

flex-basis.

§align_self: Option<AlignSelf>

align-self.

§m: Option<Length>

margin (all sides).

§mx: Option<Length>

margin-inline.

§my: Option<Length>

margin-block.

§mt: Option<Length>

margin-top.

§mr: Option<Length>

margin-right.

§mb: Option<Length>

margin-bottom.

§ml: Option<Length>

margin-left.

§p: Option<Length>

padding (all sides).

§px: Option<Length>

padding-inline.

§py: Option<Length>

padding-block.

§pt: Option<Length>

padding-top.

§pr: Option<Length>

padding-right.

§pb: Option<Length>

padding-bottom.

§pl: Option<Length>

padding-left.

§col_span: Option<u16>

grid-column: span N.

§row_span: Option<u16>

grid-row: span N.

§paint: PaintStyle

How the box looks: background, border, radius, shadow, opacity.

Implementations§

Source§

impl ItemStyle

Source

pub fn w(self, v: impl Into<Length>) -> Self

Set width.

Source

pub fn h(self, v: impl Into<Length>) -> Self

Set height.

Source

pub fn min_w(self, v: impl Into<Length>) -> Self

Set min-width.

Source

pub fn min_h(self, v: impl Into<Length>) -> Self

Set min-height.

Source

pub fn max_w(self, v: impl Into<Length>) -> Self

Set max-width.

Source

pub fn max_h(self, v: impl Into<Length>) -> Self

Set max-height.

Source

pub fn basis(self, v: impl Into<Length>) -> Self

Set flex-basis.

Source

pub fn m(self, v: impl Into<Length>) -> Self

Set the margin on all four sides.

Source

pub fn mx(self, v: impl Into<Length>) -> Self

Set the left and right margin.

Source

pub fn my(self, v: impl Into<Length>) -> Self

Set the top and bottom margin.

Source

pub fn mt(self, v: impl Into<Length>) -> Self

Set the top margin.

Source

pub fn mr(self, v: impl Into<Length>) -> Self

Set the right margin.

Source

pub fn mb(self, v: impl Into<Length>) -> Self

Set the bottom margin.

Source

pub fn ml(self, v: impl Into<Length>) -> Self

Set the left margin.

Source

pub fn p(self, v: impl Into<Length>) -> Self

Set the padding on all four sides.

Source

pub fn px(self, v: impl Into<Length>) -> Self

Set the left and right padding.

Source

pub fn py(self, v: impl Into<Length>) -> Self

Set the top and bottom padding.

Source

pub fn pt(self, v: impl Into<Length>) -> Self

Set the top padding.

Source

pub fn pr(self, v: impl Into<Length>) -> Self

Set the right padding.

Source

pub fn pb(self, v: impl Into<Length>) -> Self

Set the bottom padding.

Source

pub fn pl(self, v: impl Into<Length>) -> Self

Set the left padding.

Source

pub fn grow(self, v: f32) -> Self

Set flex-grow.

Source

pub fn shrink(self, v: f32) -> Self

Set flex-shrink.

Source

pub fn align_self(self, v: impl Into<AlignSelf>) -> Self

Set align-self.

Source

pub fn col_span(self, v: u16) -> Self

Set how many grid columns this item spans.

Source

pub fn row_span(self, v: u16) -> Self

Set how many grid rows this item spans.

Source

pub fn bg(self, v: impl Into<Color32>) -> Self

Set the background colour. See PaintStyle::bg.

Source

pub fn border(self, v: impl Into<Stroke>) -> Self

Set the border stroke. See PaintStyle::border.

Source

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

Set the corner radius. See PaintStyle::radius.

Source

pub fn shadow(self, v: bool) -> Self

Cast the theme’s window shadow. See PaintStyle::shadow.

Source

pub fn custom_shadow(self, v: Shadow) -> Self

Cast a shadow of your own. See PaintStyle::custom_shadow.

Source

pub fn opacity(self, v: f32) -> Self

Multiply the opacity of this node. See PaintStyle::opacity.

Source

pub fn padding_px(&self) -> Option<[f32; 4]>

The padding this item asks for, in points, if it asked for any.

[top, right, bottom, left], resolved most-specific-wins exactly as ItemStyle::to_taffy resolves it. None when no padding prop is set — there is nothing to take over — and when any side is a percentage or auto, because those need the containing block, which only the layout has.

This is for an element that hands its padding to the widget rather than to the layout: <Button> does, so that the hover frame and the click area cover the whole box, and <Frame> does outside a tree, where there is no layout to hold it.

Source

pub fn without_padding(self) -> Self

This style with every padding prop cleared.

The other half of ItemStyle::padding_px: an element that took the padding over passes this to cx.leaf, so the layout does not reserve the same points a second time.

Source

pub fn to_taffy(&self) -> Style

The taffy style of this item, with container properties left default.

Trait Implementations§

Source§

impl Clone for ItemStyle

Source§

fn clone(&self) -> ItemStyle

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ItemStyle

Source§

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

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

impl Default for ItemStyle

Source§

fn default() -> ItemStyle

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

impl PartialEq for ItemStyle

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for ItemStyle

Source§

impl StructuralPartialEq for ItemStyle

Auto Trait Implementations§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,