pub struct Style { /* private fields */ }
Implementations§
Source§impl Style
impl Style
pub fn new() -> Self
pub fn apply_classes_from_context( self, classes: &[StyleClassRef], context: &Style, ) -> Style
pub fn apply_class<C: StyleClass>(self, _class: C) -> Style
pub fn apply_selectors(self, selectors: &[StyleSelector]) -> Style
pub fn builtin(&self) -> BuiltinStyle<'_>
Sourcepub fn apply(self, over: Style) -> Style
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
.
Sourcepub fn apply_overriding_styles(
self,
overrides: impl Iterator<Item = Style>,
) -> Style
pub fn apply_overriding_styles( self, overrides: impl Iterator<Item = Style>, ) -> Style
Apply multiple Style
s to this style, returning a new Style
with the overrides.
Later styles take precedence over earlier styles.
Source§impl Style
impl Style
pub fn display(self, v: impl Into<Display>) -> Self
pub fn position(self, v: impl Into<Position>) -> Self
pub fn width(self, v: impl Into<PxPctAuto>) -> Self
pub fn height(self, v: impl Into<PxPctAuto>) -> Self
pub fn min_width(self, v: impl Into<PxPctAuto>) -> Self
pub fn min_height(self, v: impl Into<PxPctAuto>) -> Self
pub fn max_width(self, v: impl Into<PxPctAuto>) -> Self
pub fn max_height(self, v: impl Into<PxPctAuto>) -> Self
pub fn flex_direction(self, v: impl Into<FlexDirection>) -> Self
pub fn flex_wrap(self, v: impl Into<FlexWrap>) -> Self
pub fn flex_grow(self, v: impl Into<f32>) -> Self
pub fn flex_shrink(self, v: impl Into<f32>) -> Self
pub fn flex_basis(self, v: impl Into<PxPctAuto>) -> Self
pub fn justify_content(self, v: impl Into<Option<JustifyContent>>) -> Self
pub fn justify_self(self, v: impl Into<Option<AlignItems>>) -> Self
pub fn align_items(self, v: impl Into<Option<AlignItems>>) -> Self
pub fn align_content(self, v: impl Into<Option<AlignContent>>) -> Self
pub fn grid_template_rows(self, v: impl Into<Vec<TrackSizingFunction>>) -> Self
pub fn grid_template_columns( self, v: impl Into<Vec<TrackSizingFunction>>, ) -> Self
pub fn grid_auto_rows( self, v: impl Into<Vec<MinMax<MinTrackSizingFunction, MaxTrackSizingFunction>>>, ) -> Self
pub fn grid_auto_columns( self, v: impl Into<Vec<MinMax<MinTrackSizingFunction, MaxTrackSizingFunction>>>, ) -> Self
pub fn grid_row(self, v: impl Into<Line<GridPlacement>>) -> Self
pub fn grid_column(self, v: impl Into<Line<GridPlacement>>) -> Self
pub fn align_self(self, v: impl Into<Option<AlignItems>>) -> Self
pub fn border_radius(self, v: impl Into<PxPct>) -> Self
pub fn outline_color(self, v: impl Into<Brush>) -> Self
pub fn border_color(self, v: impl Into<Brush>) -> Self
pub fn padding_left(self, v: impl Into<PxPct>) -> Self
pub fn padding_top(self, v: impl Into<PxPct>) -> Self
pub fn padding_right(self, v: impl Into<PxPct>) -> Self
pub fn padding_bottom(self, v: impl Into<PxPct>) -> Self
pub fn margin_left(self, v: impl Into<PxPctAuto>) -> Self
pub fn margin_top(self, v: impl Into<PxPctAuto>) -> Self
pub fn margin_right(self, v: impl Into<PxPctAuto>) -> Self
pub fn margin_bottom(self, v: impl Into<PxPctAuto>) -> Self
pub fn inset_left(self, v: impl Into<PxPctAuto>) -> Self
pub fn inset_top(self, v: impl Into<PxPctAuto>) -> Self
pub fn inset_right(self, v: impl Into<PxPctAuto>) -> Self
pub fn inset_bottom(self, v: impl Into<PxPctAuto>) -> Self
pub fn pointer_events(self, v: impl Into<Option<PointerEvents>>) -> Self
pub fn selectable(self, v: impl Into<bool>) -> Self
pub fn text_overflow(self, v: impl Into<TextOverflow>) -> Self
pub fn aspect_ratio(self, v: impl Into<Option<f32>>) -> Self
pub fn scale_x(self, v: impl Into<Pct>) -> Self
pub fn scale_y(self, v: impl Into<Pct>) -> Self
pub fn translate_x(self, v: impl Into<PxPct>) -> Self
pub fn translate_y(self, v: impl Into<PxPct>) -> Self
pub fn rotate(self, v: impl Into<Px>) -> Self
Source§impl Style
impl Style
pub fn get<P: StyleProp>(&self, _prop: P) -> P::Type
pub fn get_style_value<P: StyleProp>(&self, _prop: P) -> StyleValue<P::Type>
pub fn set<P: StyleProp>(self, prop: P, value: impl Into<P::Type>) -> Self
pub fn set_style_value<P: StyleProp>( self, _prop: P, value: StyleValue<P::Type>, ) -> Self
pub fn transition<P: StyleProp>(self, _prop: P, transition: Transition) -> Self
Sourcepub fn hover(self, style: impl FnOnce(Style) -> Style) -> Self
pub fn hover(self, style: impl FnOnce(Style) -> Style) -> Self
The visual style to apply when the mouse hovers over the element
pub fn focus(self, style: impl FnOnce(Style) -> Style) -> Self
Sourcepub fn focus_visible(self, style: impl FnOnce(Style) -> Style) -> Self
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.
pub fn selected(self, style: impl FnOnce(Style) -> Style) -> Self
pub fn disabled(self, style: impl FnOnce(Style) -> Style) -> Self
pub fn active(self, style: impl FnOnce(Style) -> Style) -> Self
pub fn responsive( self, size: ScreenSize, style: impl FnOnce(Style) -> Style, ) -> Self
pub fn class<C: StyleClass>( self, _class: C, style: impl FnOnce(Style) -> Style, ) -> Self
pub fn width_full(self) -> Self
pub fn width_pct(self, width: f64) -> Self
pub fn height_full(self) -> Self
pub fn height_pct(self, height: f64) -> Self
pub fn row_gap(self, width: impl Into<PxPct>) -> Self
pub fn column_gap(self, height: impl Into<PxPct>) -> Self
pub fn row_col_gap( self, width: impl Into<PxPct>, height: impl Into<PxPct>, ) -> Self
pub fn gap(self, gap: impl Into<PxPct>) -> Self
pub fn size( self, width: impl Into<PxPctAuto>, height: impl Into<PxPctAuto>, ) -> Self
pub fn size_full(self) -> Self
pub fn size_pct(self, width: f64, height: f64) -> Self
pub fn min_width_full(self) -> Self
pub fn min_width_pct(self, min_width: f64) -> Self
pub fn min_height_full(self) -> Self
pub fn min_height_pct(self, min_height: f64) -> Self
pub fn min_size_full(self) -> Self
pub fn min_size( self, min_width: impl Into<PxPctAuto>, min_height: impl Into<PxPctAuto>, ) -> Self
pub fn min_size_pct(self, min_width: f64, min_height: f64) -> Self
pub fn max_width_full(self) -> Self
pub fn max_width_pct(self, max_width: f64) -> Self
pub fn max_height_full(self) -> Self
pub fn max_height_pct(self, max_height: f64) -> Self
pub fn max_size( self, max_width: impl Into<PxPctAuto>, max_height: impl Into<PxPctAuto>, ) -> Self
pub fn max_size_full(self) -> Self
pub fn max_size_pct(self, max_width: f64, max_height: f64) -> Self
pub fn border(self, border: impl Into<StrokeWrap>) -> Self
pub fn border_left(self, border: impl Into<StrokeWrap>) -> Self
pub fn border_right(self, border: impl Into<StrokeWrap>) -> Self
pub fn border_top(self, border: impl Into<StrokeWrap>) -> Self
pub fn border_bottom(self, border: impl Into<StrokeWrap>) -> Self
pub fn outline(self, outline: impl Into<StrokeWrap>) -> Self
Sourcepub fn border_horiz(self, border: impl Into<Stroke>) -> Self
pub fn border_horiz(self, border: impl Into<Stroke>) -> Self
Sets border_left
and border_right
to border
Sourcepub fn border_vert(self, border: impl Into<Stroke>) -> Self
pub fn border_vert(self, border: impl Into<Stroke>) -> Self
Sets border_top
and border_bottom
to border
pub fn padding_left_pct(self, padding: f64) -> Self
pub fn padding_right_pct(self, padding: f64) -> Self
pub fn padding_top_pct(self, padding: f64) -> Self
pub fn padding_bottom_pct(self, padding: f64) -> Self
pub fn padding_pct(self, padding: f64) -> Self
Sourcepub fn padding_horiz(self, padding: impl Into<PxPct>) -> Self
pub fn padding_horiz(self, padding: impl Into<PxPct>) -> Self
Sets padding_left
and padding_right
to padding
pub fn padding_horiz_pct(self, padding: f64) -> Self
Sourcepub fn padding_vert(self, padding: impl Into<PxPct>) -> Self
pub fn padding_vert(self, padding: impl Into<PxPct>) -> Self
Sets padding_top
and padding_bottom
to padding
pub fn padding_vert_pct(self, padding: f64) -> Self
pub fn margin_left_pct(self, margin: f64) -> Self
pub fn margin_right_pct(self, margin: f64) -> Self
pub fn margin_top_pct(self, margin: f64) -> Self
pub fn margin_bottom_pct(self, margin: f64) -> Self
pub fn margin(self, margin: impl Into<PxPctAuto>) -> Self
pub fn margin_pct(self, margin: f64) -> Self
Sourcepub fn margin_horiz(self, margin: impl Into<PxPctAuto>) -> Self
pub fn margin_horiz(self, margin: impl Into<PxPctAuto>) -> Self
Sets margin_left
and margin_right
to margin
pub fn margin_horiz_pct(self, margin: f64) -> Self
Sourcepub fn margin_vert(self, margin: impl Into<PxPctAuto>) -> Self
pub fn margin_vert(self, margin: impl Into<PxPctAuto>) -> Self
Sets margin_top
and margin_bottom
to margin
pub fn margin_vert_pct(self, margin: f64) -> Self
pub fn inset_left_pct(self, inset: f64) -> Self
pub fn inset_right_pct(self, inset: f64) -> Self
pub fn inset_top_pct(self, inset: f64) -> Self
pub fn inset_bottom_pct(self, inset: f64) -> Self
pub fn inset(self, inset: impl Into<PxPctAuto>) -> Self
pub fn inset_pct(self, inset: f64) -> Self
pub fn cursor(self, cursor: impl Into<StyleValue<CursorStyle>>) -> Self
pub fn color(self, color: impl Into<StyleValue<Color>>) -> Self
pub fn background(self, color: impl Into<Brush>) -> Self
pub fn box_shadow_blur(self, blur_radius: impl Into<PxPct>) -> Self
pub fn box_shadow_color(self, color: Color) -> Self
pub fn box_shadow_spread(self, spread: impl Into<PxPct>) -> Self
pub fn box_shadow_h_offset(self, h_offset: impl Into<PxPct>) -> Self
pub fn box_shadow_v_offset(self, v_offset: impl Into<PxPct>) -> Self
pub fn font_size(self, size: impl Into<Px>) -> Self
pub fn font_family(self, family: impl Into<StyleValue<String>>) -> Self
pub fn font_weight(self, weight: impl Into<StyleValue<Weight>>) -> Self
pub fn font_bold(self) -> Self
pub fn font_style(self, style: impl Into<StyleValue<Style>>) -> Self
pub fn cursor_color(self, color: impl Into<StyleValue<Brush>>) -> Self
pub fn line_height(self, normal: f32) -> Self
pub fn pointer_events_auto(self) -> Self
pub fn pointer_events_none(self) -> Self
pub fn text_ellipsis(self) -> Self
pub fn text_clip(self) -> Self
pub fn absolute(self) -> Self
pub fn items_start(self) -> Self
Sourcepub fn items_center(self) -> Self
pub fn items_center(self) -> Self
Defines the alignment along the cross axis as Centered
pub fn items_end(self) -> Self
Sourcepub fn justify_center(self) -> Self
pub fn justify_center(self) -> Self
Defines the alignment along the main axis as Centered
pub fn justify_end(self) -> Self
pub fn justify_start(self) -> Self
pub fn justify_between(self) -> Self
pub fn hide(self) -> Self
pub fn flex(self) -> Self
pub fn grid(self) -> Self
pub fn flex_row(self) -> Self
pub fn flex_col(self) -> Self
pub fn z_index(self, z_index: i32) -> Self
pub fn scale(self, scale: impl Into<Pct>) -> Self
Sourcepub fn apply_opt<T>(
self,
opt: Option<T>,
f: impl FnOnce(Self, T) -> Self,
) -> Self
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
Sourcepub fn apply_if(self, cond: bool, f: impl FnOnce(Self) -> Self) -> Self
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
pub fn apply_custom<CS: Into<Style>>(self, custom_style: CS) -> Self
pub fn transition_width(self, transition: Transition) -> Self
pub fn transition_height(self, transition: Transition) -> Self
pub fn transition_size(self, transition: Transition) -> Self
pub fn transition_color(self, transition: Transition) -> Self
pub fn transition_background(self, transition: Transition) -> Self
Source§impl Style
impl Style
pub fn to_taffy_style(&self) -> TaffyStyle
Trait Implementations§
Source§impl From<DropdownCustomStyle> for Style
impl From<DropdownCustomStyle> for Style
Source§fn from(val: DropdownCustomStyle) -> Self
fn from(val: DropdownCustomStyle) -> Self
Source§impl From<LabelCustomStyle> for Style
impl From<LabelCustomStyle> for Style
Source§fn from(value: LabelCustomStyle) -> Self
fn from(value: LabelCustomStyle) -> Self
Source§impl From<ScrollCustomStyle> for Style
impl From<ScrollCustomStyle> for Style
Source§fn from(value: ScrollCustomStyle) -> Self
fn from(value: ScrollCustomStyle) -> Self
Source§impl From<SliderCustomStyle> for Style
impl From<SliderCustomStyle> for Style
Source§fn from(val: SliderCustomStyle) -> Self
fn from(val: SliderCustomStyle) -> Self
Source§impl From<Style> for KeyFrameStyle
impl From<Style> for KeyFrameStyle
Source§impl From<ToggleButtonCustomStyle> for Style
impl From<ToggleButtonCustomStyle> for Style
Source§fn from(value: ToggleButtonCustomStyle) -> Self
fn from(value: ToggleButtonCustomStyle) -> Self
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.