floem::style

Struct Style

Source
pub struct Style { /* private fields */ }

Implementations§

Source§

impl Style

Source

pub fn new() -> Self

Source

pub fn apply_classes_from_context( self, classes: &[StyleClassRef], context: &Style, ) -> Style

Source

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

Source

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

Source

pub fn builtin(&self) -> BuiltinStyle<'_>

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_auto_rows( self, v: impl Into<Vec<MinMax<MinTrackSizingFunction, MaxTrackSizingFunction>>>, ) -> Self

Source

pub fn grid_auto_columns( self, v: impl Into<Vec<MinMax<MinTrackSizingFunction, MaxTrackSizingFunction>>>, ) -> 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_radius(self, v: impl Into<PxPct>) -> Self

Source

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

Source

pub fn border_color(self, v: impl Into<Brush>) -> 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 pointer_events(self, v: impl Into<Option<PointerEvents>>) -> Self

Source

pub fn selectable(self, v: impl Into<bool>) -> 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

pub fn scale_x(self, v: impl Into<Pct>) -> Self

Source

pub fn scale_y(self, v: impl Into<Pct>) -> Self

Source

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

Source

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

Source

pub fn rotate(self, v: impl Into<Px>) -> 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 row_gap(self, width: impl Into<PxPct>) -> Self

Source

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

Source

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

Source

pub fn gap(self, gap: 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<StrokeWrap>) -> Self

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Sets border_left and border_right to border

Source

pub fn border_vert(self, border: impl Into<Stroke>) -> 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<Brush>) -> 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<Px>) -> 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<Brush>>) -> Self

Source

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

Source

pub fn pointer_events_auto(self) -> Self

Source

pub fn pointer_events_none(self) -> 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 grid(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 scale(self, scale: impl Into<Pct>) -> 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.

use floem::style::Style;
let maybe_none: Option<i32> = None;
let style = Style::default()
    .apply_opt(Some(5.0), Style::padding) // ran
    .apply_opt(maybe_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 optional style changes.

use floem::style::Style;
let style = Style::default()
    .apply_if(true, |s| s.padding(5.0)) // ran
    .apply_if(false, |s| s.margin(5.0)); // not ran
Source

pub fn apply_custom<CS: Into<Style>>(self, custom_style: CS) -> Self

Source

pub fn transition_width(self, transition: Transition) -> Self

Source

pub fn transition_height(self, transition: Transition) -> Self

Source

pub fn transition_size(self, transition: Transition) -> Self

Source

pub fn transition_color(self, transition: Transition) -> Self

Source

pub fn transition_background(self, transition: Transition) -> Self

Source§

impl Style

Source

pub fn to_taffy_style(&self) -> TaffyStyle

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

impl From<DropdownCustomStyle> for Style

Source§

fn from(val: DropdownCustomStyle) -> Self

Converts to this type from the input type.
Source§

impl From<LabelCustomStyle> for Style

Source§

fn from(value: LabelCustomStyle) -> Self

Converts to this type from the input type.
Source§

impl From<ScrollCustomStyle> for Style

Source§

fn from(value: ScrollCustomStyle) -> Self

Converts to this type from the input type.
Source§

impl From<SliderCustomStyle> for Style

Source§

fn from(val: SliderCustomStyle) -> Self

Converts to this type from the input type.
Source§

impl From<Style> for KeyFrameStyle

Source§

fn from(value: Style) -> Self

Converts to this type from the input type.
Source§

impl From<ToggleButtonCustomStyle> for Style

Source§

fn from(value: ToggleButtonCustomStyle) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Style

§

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

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

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.

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

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

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T