Struct floem::style::Style

source ·
pub struct Style { /* private fields */ }

Implementations§

source§

impl Style

source

pub fn new() -> Self

source

pub fn apply_class<C: StyleClass>(self, _class: C) -> Style

source

pub fn apply_selectors(self, selectors: &[StyleSelector]) -> Style

source

pub fn apply(self, over: Style) -> Style

Apply another Style to this style, returning a new Style with the overrides

StyleValue::Val will override the value with the given value StyleValue::Unset will unset the value, causing it to fall back to the default. StyleValue::Base will leave the value as-is, whether falling back to the default or using the value in the Style.

source

pub fn apply_overriding_styles( self, overrides: impl Iterator<Item = Style> ) -> Style

Apply multiple Styles to this style, returning a new Style with the overrides. Later styles take precedence over earlier styles.

source§

impl Style

source

pub fn display(self, v: impl Into<Display>) -> Self

source

pub fn position(self, v: impl Into<Position>) -> Self

source

pub fn width(self, v: impl Into<PxPctAuto>) -> Self

source

pub fn height(self, v: impl Into<PxPctAuto>) -> Self

source

pub fn min_width(self, v: impl Into<PxPctAuto>) -> Self

source

pub fn min_height(self, v: impl Into<PxPctAuto>) -> Self

source

pub fn max_width(self, v: impl Into<PxPctAuto>) -> Self

source

pub fn max_height(self, v: impl Into<PxPctAuto>) -> Self

source

pub fn flex_direction(self, v: impl Into<FlexDirection>) -> Self

source

pub fn flex_wrap(self, v: impl Into<FlexWrap>) -> Self

source

pub fn flex_grow(self, v: impl Into<f32>) -> Self

source

pub fn flex_shrink(self, v: impl Into<f32>) -> Self

source

pub fn flex_basis(self, v: impl Into<PxPctAuto>) -> Self

source

pub fn justify_content(self, v: impl Into<Option<JustifyContent>>) -> Self

source

pub fn justify_self(self, v: impl Into<Option<AlignItems>>) -> Self

source

pub fn align_items(self, v: impl Into<Option<AlignItems>>) -> Self

source

pub fn align_content(self, v: impl Into<Option<AlignContent>>) -> Self

source

pub fn grid_template_rows(self, v: impl Into<Vec<TrackSizingFunction>>) -> Self

source

pub fn grid_template_columns( self, v: impl Into<Vec<TrackSizingFunction>> ) -> Self

source

pub fn grid_row(self, v: impl Into<Line<GridPlacement>>) -> Self

source

pub fn grid_column(self, v: impl Into<Line<GridPlacement>>) -> Self

source

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

source

pub fn border_left(self, v: impl Into<Px>) -> Self

source

pub fn border_top(self, v: impl Into<Px>) -> Self

source

pub fn border_right(self, v: impl Into<Px>) -> Self

source

pub fn border_bottom(self, v: impl Into<Px>) -> Self

source

pub fn border_radius(self, v: impl Into<PxPct>) -> Self

source

pub fn outline_color(self, v: impl Into<Color>) -> Self

source

pub fn outline(self, v: impl Into<Px>) -> Self

source

pub fn border_color(self, v: impl Into<Color>) -> Self

source

pub fn padding_left(self, v: impl Into<PxPct>) -> Self

source

pub fn padding_top(self, v: impl Into<PxPct>) -> Self

source

pub fn padding_right(self, v: impl Into<PxPct>) -> Self

source

pub fn padding_bottom(self, v: impl Into<PxPct>) -> Self

source

pub fn margin_left(self, v: impl Into<PxPctAuto>) -> Self

source

pub fn margin_top(self, v: impl Into<PxPctAuto>) -> Self

source

pub fn margin_right(self, v: impl Into<PxPctAuto>) -> Self

source

pub fn margin_bottom(self, v: impl Into<PxPctAuto>) -> Self

source

pub fn inset_left(self, v: impl Into<PxPctAuto>) -> Self

source

pub fn inset_top(self, v: impl Into<PxPctAuto>) -> Self

source

pub fn inset_right(self, v: impl Into<PxPctAuto>) -> Self

source

pub fn inset_bottom(self, v: impl Into<PxPctAuto>) -> Self

source

pub fn text_overflow(self, v: impl Into<TextOverflow>) -> Self

source

pub fn aspect_ratio(self, v: impl Into<Option<f32>>) -> Self

source§

impl Style

source

pub fn get<P: StyleProp>(&self, _prop: P) -> P::Type

source

pub fn get_style_value<P: StyleProp>(&self, _prop: P) -> StyleValue<P::Type>

source

pub fn set<P: StyleProp>(self, prop: P, value: impl Into<P::Type>) -> Self

source

pub fn set_style_value<P: StyleProp>( self, _prop: P, value: StyleValue<P::Type> ) -> Self

source

pub fn transition<P: StyleProp>(self, _prop: P, transition: Transition) -> Self

source

pub fn hover(self, style: impl FnOnce(Style) -> Style) -> Self

The visual style to apply when the mouse hovers over the element

source

pub fn focus(self, style: impl FnOnce(Style) -> Style) -> Self

source

pub fn focus_visible(self, style: impl FnOnce(Style) -> Style) -> Self

Similar to the :focus-visible css selector, this style only activates when tab navigation is used.

source

pub fn selected(self, style: impl FnOnce(Style) -> Style) -> Self

source

pub fn disabled(self, style: impl FnOnce(Style) -> Style) -> Self

source

pub fn active(self, style: impl FnOnce(Style) -> Style) -> Self

source

pub fn responsive( self, size: ScreenSize, style: impl FnOnce(Style) -> Style ) -> Self

source

pub fn class<C: StyleClass>( self, _class: C, style: impl FnOnce(Style) -> Style ) -> Self

source

pub fn width_full(self) -> Self

source

pub fn width_pct(self, width: f64) -> Self

source

pub fn height_full(self) -> Self

source

pub fn height_pct(self, height: f64) -> Self

source

pub fn gap(self, width: impl Into<PxPct>, height: impl Into<PxPct>) -> Self

source

pub fn size( self, width: impl Into<PxPctAuto>, height: impl Into<PxPctAuto> ) -> Self

source

pub fn size_full(self) -> Self

source

pub fn size_pct(self, width: f64, height: f64) -> Self

source

pub fn min_width_full(self) -> Self

source

pub fn min_width_pct(self, min_width: f64) -> Self

source

pub fn min_height_full(self) -> Self

source

pub fn min_height_pct(self, min_height: f64) -> Self

source

pub fn min_size_full(self) -> Self

source

pub fn min_size( self, min_width: impl Into<PxPctAuto>, min_height: impl Into<PxPctAuto> ) -> Self

source

pub fn min_size_pct(self, min_width: f64, min_height: f64) -> Self

source

pub fn max_width_full(self) -> Self

source

pub fn max_width_pct(self, max_width: f64) -> Self

source

pub fn max_height_full(self) -> Self

source

pub fn max_height_pct(self, max_height: f64) -> Self

source

pub fn max_size( self, max_width: impl Into<PxPctAuto>, max_height: impl Into<PxPctAuto> ) -> Self

source

pub fn max_size_full(self) -> Self

source

pub fn max_size_pct(self, max_width: f64, max_height: f64) -> Self

source

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

source

pub fn border_horiz(self, border: impl Into<Px>) -> Self

Sets border_left and border_right to border

source

pub fn border_vert(self, border: impl Into<Px>) -> Self

Sets border_top and border_bottom to border

source

pub fn padding_left_pct(self, padding: f64) -> Self

source

pub fn padding_right_pct(self, padding: f64) -> Self

source

pub fn padding_top_pct(self, padding: f64) -> Self

source

pub fn padding_bottom_pct(self, padding: f64) -> Self

source

pub fn padding(self, padding: impl Into<PxPct>) -> Self

Set padding on all directions

source

pub fn padding_pct(self, padding: f64) -> Self

source

pub fn padding_horiz(self, padding: impl Into<PxPct>) -> Self

Sets padding_left and padding_right to padding

source

pub fn padding_horiz_pct(self, padding: f64) -> Self

source

pub fn padding_vert(self, padding: impl Into<PxPct>) -> Self

Sets padding_top and padding_bottom to padding

source

pub fn padding_vert_pct(self, padding: f64) -> Self

source

pub fn margin_left_pct(self, margin: f64) -> Self

source

pub fn margin_right_pct(self, margin: f64) -> Self

source

pub fn margin_top_pct(self, margin: f64) -> Self

source

pub fn margin_bottom_pct(self, margin: f64) -> Self

source

pub fn margin(self, margin: impl Into<PxPctAuto>) -> Self

source

pub fn margin_pct(self, margin: f64) -> Self

source

pub fn margin_horiz(self, margin: impl Into<PxPctAuto>) -> Self

Sets margin_left and margin_right to margin

source

pub fn margin_horiz_pct(self, margin: f64) -> Self

source

pub fn margin_vert(self, margin: impl Into<PxPctAuto>) -> Self

Sets margin_top and margin_bottom to margin

source

pub fn margin_vert_pct(self, margin: f64) -> Self

source

pub fn inset_left_pct(self, inset: f64) -> Self

source

pub fn inset_right_pct(self, inset: f64) -> Self

source

pub fn inset_top_pct(self, inset: f64) -> Self

source

pub fn inset_bottom_pct(self, inset: f64) -> Self

source

pub fn inset(self, inset: impl Into<PxPctAuto>) -> Self

source

pub fn inset_pct(self, inset: f64) -> Self

source

pub fn cursor(self, cursor: impl Into<StyleValue<CursorStyle>>) -> Self

source

pub fn color(self, color: impl Into<StyleValue<Color>>) -> Self

source

pub fn background(self, color: impl Into<StyleValue<Color>>) -> Self

source

pub fn box_shadow_blur(self, blur_radius: impl Into<PxPct>) -> Self

source

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

source

pub fn box_shadow_spread(self, spread: impl Into<PxPct>) -> Self

source

pub fn box_shadow_h_offset(self, h_offset: impl Into<PxPct>) -> Self

source

pub fn box_shadow_v_offset(self, v_offset: impl Into<PxPct>) -> Self

source

pub fn font_size(self, size: impl Into<StyleValue<f32>>) -> Self

source

pub fn font_family(self, family: impl Into<StyleValue<String>>) -> Self

source

pub fn font_weight(self, weight: impl Into<StyleValue<Weight>>) -> Self

source

pub fn font_bold(self) -> Self

source

pub fn font_style(self, style: impl Into<StyleValue<Style>>) -> Self

source

pub fn cursor_color(self, color: impl Into<StyleValue<Color>>) -> Self

source

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

source

pub fn text_ellipsis(self) -> Self

source

pub fn text_clip(self) -> Self

source

pub fn absolute(self) -> Self

source

pub fn items_start(self) -> Self

source

pub fn items_center(self) -> Self

Defines the alignment along the cross axis as Centered

source

pub fn items_end(self) -> Self

source

pub fn justify_center(self) -> Self

Defines the alignment along the main axis as Centered

source

pub fn justify_end(self) -> Self

source

pub fn justify_start(self) -> Self

source

pub fn justify_between(self) -> Self

source

pub fn hide(self) -> Self

source

pub fn flex(self) -> Self

source

pub fn flex_row(self) -> Self

source

pub fn flex_col(self) -> Self

source

pub fn z_index(self, z_index: i32) -> Self

source

pub fn apply_opt<T>( self, opt: Option<T>, f: impl FnOnce(Self, T) -> Self ) -> Self

Allow the application of a function if the option exists.
This is useful for chaining together a bunch of optional style changes.

let style = Style::default()
   .apply_opt(Some(5.0), Style::padding) // ran
   .apply_opt(None, Style::margin) // not ran
   .apply_opt(Some(5.0), |s, v| s.border_right(v * 2.0))
   .border_left(5.0); // ran, obviously
source

pub fn apply_if(self, cond: bool, f: impl FnOnce(Self) -> Self) -> Self

Allow the application of a function if the condition holds.
This is useful for chaining together a bunch of optional style changes.

let style = Style::default()
    .apply_if(true, |s| s.padding(5.0)) // ran
    .apply_if(false, |s| s.margin(5.0)) // not ran
source§

impl Style

Trait Implementations§

source§

impl Clone for Style

source§

fn clone(&self) -> Style

Returns a copy 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 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() -> Style

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

Auto Trait Implementations§

§

impl !RefUnwindSafe for Style

§

impl !Send for Style

§

impl !Sync for Style

§

impl Unpin 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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

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

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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.

§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

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

§

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

§

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

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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