pub struct Style { /* private fields */ }
Implementations§
source§impl Style
impl Style
pub fn new() -> Self
pub fn apply_class<C: StyleClass>(self, _class: C) -> Style
pub fn apply_selectors(self, selectors: &[StyleSelector]) -> Style
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_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_left(self, v: impl Into<Px>) -> Self
pub fn border_top(self, v: impl Into<Px>) -> Self
pub fn border_right(self, v: impl Into<Px>) -> Self
pub fn border_bottom(self, v: impl Into<Px>) -> Self
pub fn border_radius(self, v: impl Into<PxPct>) -> Self
pub fn outline_color(self, v: impl Into<Color>) -> Self
pub fn outline(self, v: impl Into<Px>) -> Self
pub fn border_color(self, v: impl Into<Color>) -> 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 text_overflow(self, v: impl Into<TextOverflow>) -> Self
pub fn aspect_ratio(self, v: impl Into<Option<f32>>) -> 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 gap(self, width: impl Into<PxPct>, height: 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<Px>) -> Self
sourcepub fn border_horiz(self, border: impl Into<Px>) -> Self
pub fn border_horiz(self, border: impl Into<Px>) -> Self
Sets border_left
and border_right
to border
sourcepub fn border_vert(self, border: impl Into<Px>) -> Self
pub fn border_vert(self, border: impl Into<Px>) -> 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<StyleValue<Color>>) -> 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<StyleValue<f32>>) -> 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<Color>>) -> Self
pub fn line_height(self, normal: f32) -> 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 flex_row(self) -> Self
pub fn flex_col(self) -> Self
pub fn z_index(self, z_index: i32) -> 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.
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
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 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
impl Style
pub fn to_taffy_style(&self) -> TaffyStyle
Trait Implementations§
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> 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
§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>
§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()
.