pub struct Style {Show 49 fields
pub display: Display,
pub visibility: Visibility,
pub direction: LayoutDirection,
pub unicode_bidi: UnicodeBidi,
pub overflow: Point<Overflow>,
pub overflow_fade: Edges<AbsoluteLength>,
pub scrollbar_width: AbsoluteLength,
pub allow_concurrent_scroll: bool,
pub restrict_scroll_to_axis: bool,
pub position: Position,
pub inset: Edges<Length>,
pub size: Size<Length>,
pub min_size: Size<Length>,
pub max_size: Size<Length>,
pub aspect_ratio: Option<f32>,
pub margin: Edges<Length>,
pub padding: Edges<DefiniteLength>,
pub border_widths: Edges<AbsoluteLength>,
pub align_items: Option<AlignItems>,
pub align_self: Option<AlignSelf>,
pub vertical_align: VerticalAlign,
pub align_content: Option<AlignContent>,
pub justify_content: Option<JustifyContent>,
pub gap: Size<DefiniteLength>,
pub flex_direction: FlexDirection,
pub flex_wrap: FlexWrap,
pub flex_basis: Length,
pub flex_grow: f32,
pub flex_shrink: f32,
pub background: Option<Fill>,
pub border_color: Option<Background>,
pub border_style: BorderStyle,
pub border_dashed_length: f32,
pub border_dashed_gap: f32,
pub corner_radii: Corners<AbsoluteLength>,
pub corner_smoothing: Option<f32>,
pub box_shadow: Vec<BoxShadow>,
pub ring: RingStyle,
pub inset_ring: RingStyle,
pub filter: Vec<Filter>,
pub backdrop_filter: Vec<Filter>,
pub text: TextStyleRefinement,
pub mouse_cursor: Option<CursorStyle>,
pub opacity: Option<f32>,
pub grid_cols: Option<GridTemplate>,
pub grid_rows: Option<GridTemplate>,
pub grid_location: Option<GridLocation>,
pub debug: bool,
pub debug_below: bool,
/* private fields */
}Expand description
The resolved styling of an element, which GPUI uses to lay out and paint it.
You rarely build a Style yourself. The methods of Styled write into a
StyleRefinement, and GPUI applies that refinement over Style::default() when it
draws the element. A default Style uses Display::Block and is visible.
§Examples
use gpui::{Display, Refineable, Style, StyleRefinement};
let mut style = Style::default();
assert_eq!(style.display, Display::Block);
let mut refinement = StyleRefinement::default();
refinement.display = Some(Display::Flex);
style.refine(&refinement);
assert_eq!(style.display, Display::Flex);Fields§
§display: DisplayWhat layout strategy should be used?
visibility: VisibilityShould the element be painted on screen?
direction: LayoutDirectionThe inline direction of this element and its descendants.
unicode_bidi: UnicodeBidiHow this element participates in Unicode bidirectional text formatting.
overflow: Point<Overflow>How children overflowing their container should affect layout
overflow_fade: Edges<AbsoluteLength>Edge fade distances for overflow masking.
scrollbar_width: AbsoluteLengthHow much space (in logical pixels or rems) should be reserved for the scrollbars of Overflow::Scroll nodes.
allow_concurrent_scroll: boolWhether both x and y axis should be scrollable at the same time.
restrict_scroll_to_axis: boolWhether scrolling should be restricted to the input gesture’s axis.
Pixel-based scroll gestures are locked to their initially dominant axis. The lock may be released when the gesture changes direction strongly. Touch phases delimit gestures when available, with a timeout fallback for platforms that only emit moved events.
This also prevents input from being remapped to another axis. For example, horizontal input will not scroll a container that only has vertical overflow enabled. Mouse wheel platforms typically report ordinary wheel input on the Y axis and Shift-modified input on the X axis.
§Motivation
On the web, a vertical mouse wheel scrolls the Y axis even over a horizontally scrollable element.
The only way to scroll horizontally is to hold down Shift while scrolling, which then changes the scroll axis
to the X axis.
GPUI can otherwise choose either axis for mouse-wheel input. In a vertical list with horizontally scrollable children, that can send the list’s scroll gesture to a child.
Set this property to keep each gesture on its initial axis.
position: PositionWhat should the position value of this struct use as a base offset?
inset: Edges<Length>How should the position of this element be tweaked relative to the layout defined?
size: Size<Length>Sets the initial size of the item
min_size: Size<Length>Controls the minimum size of the item
max_size: Size<Length>Controls the maximum size of the item
aspect_ratio: Option<f32>Sets the preferred aspect ratio for the item. The ratio is calculated as width divided by height.
margin: Edges<Length>How large should the margin be on each side?
padding: Edges<DefiniteLength>How large should the padding be on each side?
border_widths: Edges<AbsoluteLength>How large should the border be on each side?
align_items: Option<AlignItems>How this node’s children aligned in the cross/block axis?
align_self: Option<AlignSelf>How this node should be aligned in the cross/block axis. Falls back to the parents AlignItems if not set
vertical_align: VerticalAlignHow this element aligns vertically when it participates in an inline formatting context.
align_content: Option<AlignContent>How should content contained within this item be aligned in the cross/block axis
justify_content: Option<JustifyContent>How should contained within this item be aligned in the main/inline axis
gap: Size<DefiniteLength>How large should the gaps between items in a flex container be?
flex_direction: FlexDirectionWhich direction does the main axis flow in?
flex_wrap: FlexWrapShould elements wrap, or stay in a single line?
flex_basis: LengthSets the initial main axis size of the item
flex_grow: f32The relative rate at which this item grows when it is expanding to fill space, 0.0 is the default value, and this value must be positive.
flex_shrink: f32The relative rate at which this item shrinks when it is contracting to fit into space, 1.0 is the default value, and this value must be positive.
background: Option<Fill>The fill color of this element
border_color: Option<Background>The background painted into the border of this element
border_style: BorderStyleThe border style of this element
border_dashed_length: f32The length of each border dash, as a multiple of the border width.
border_dashed_gap: f32The gap between border dashes, as a multiple of the border width.
corner_radii: Corners<AbsoluteLength>The radius of the corners of this element
corner_smoothing: Option<f32>Controls the transition from each rounded corner to the straight edges.
0.0 produces circular corners. 1.0 applies maximum smoothing.
box_shadow: Vec<BoxShadow>Box shadow of the element
ring: RingStyleA solid ring painted outside the element.
inset_ring: RingStyleA solid ring painted inside the element.
filter: Vec<Filter>Filters applied to this element’s own content and children (CSS filter).
backdrop_filter: Vec<Filter>Filters applied to the content rendered behind this element (CSS backdrop-filter).
text: TextStyleRefinementThe text style of this element
mouse_cursor: Option<CursorStyle>The mouse cursor style shown when the mouse pointer is over an element.
opacity: Option<f32>Opacity applied to this element and its children after compositing them as a group.
grid_cols: Option<GridTemplate>The grid columns of this element
Roughly equivalent to the Tailwind grid-cols-<number>
grid_rows: Option<GridTemplate>The row span of this element
Equivalent to the Tailwind grid-rows-<number>
grid_location: Option<GridLocation>The grid location of this element
debug: boolWhether to draw a red debugging outline around this element
debug_below: boolWhether to draw a red debugging outline around this element and all of its conforming children
Implementations§
Source§impl Style
impl Style
Sourcepub fn has_opaque_background(&self) -> bool
pub fn has_opaque_background(&self) -> bool
Returns true if the style has a background that is not fully transparent. Visibility is not checked.
Sourcepub fn text_style(&self) -> Option<&TextStyleRefinement>
pub fn text_style(&self) -> Option<&TextStyleRefinement>
Get the text style in this element style.
Sourcepub fn overflow_mask(
&self,
bounds: Bounds<Pixels>,
rem_size: Pixels,
) -> Option<ContentMask<Pixels>>
pub fn overflow_mask( &self, bounds: Bounds<Pixels>, rem_size: Pixels, ) -> Option<ContentMask<Pixels>>
Get the content mask for this element style, based on the given bounds.
If the element does not hide its overflow, this will return None.
Sourcepub fn scroll_mask(
&self,
bounds: Bounds<Pixels>,
rem_size: Pixels,
) -> ContentMask<Pixels>
pub fn scroll_mask( &self, bounds: Bounds<Pixels>, rem_size: Pixels, ) -> ContentMask<Pixels>
Get the content mask for a container that always clips and scrolls
vertically, like List and
UniformList: the vertical axis always clips,
the horizontal axis clips according to overflow.x, and
overflow_fade distances apply on each clipped axis.
Trait Implementations§
Source§impl From<StyleRefinement> for Stylewhere
Option<Display>: Clone,
Option<Visibility>: Clone,
Option<LayoutDirection>: Clone,
Option<UnicodeBidi>: Clone,
Option<bool>: Clone,
PointRefinement<Overflow>: Clone,
EdgesRefinement<AbsoluteLength>: Clone,
Option<AbsoluteLength>: Clone,
Option<Position>: Clone,
EdgesRefinement<Length>: Clone,
SizeRefinement<Length>: Clone,
Option<f32>: Clone,
EdgesRefinement<DefiniteLength>: Clone,
Option<AlignItems>: Clone,
Option<AlignSelf>: Clone,
Option<VerticalAlign>: Clone,
Option<AlignContent>: Clone,
Option<JustifyContent>: Clone,
SizeRefinement<DefiniteLength>: Clone,
Option<FlexDirection>: Clone,
Option<FlexWrap>: Clone,
Option<Length>: Clone,
Option<Fill>: Clone,
Option<Background>: Clone,
Option<BorderStyle>: Clone,
CornersRefinement<AbsoluteLength>: Clone,
Option<Vec<BoxShadow>>: Clone,
RingStyleRefinement: Clone,
Option<Vec<Filter>>: Clone,
TextStyleRefinement: Clone,
Option<CursorStyle>: Clone,
Option<GridTemplate>: Clone,
Option<GridLocation>: Clone,
impl From<StyleRefinement> for Stylewhere
Option<Display>: Clone,
Option<Visibility>: Clone,
Option<LayoutDirection>: Clone,
Option<UnicodeBidi>: Clone,
Option<bool>: Clone,
PointRefinement<Overflow>: Clone,
EdgesRefinement<AbsoluteLength>: Clone,
Option<AbsoluteLength>: Clone,
Option<Position>: Clone,
EdgesRefinement<Length>: Clone,
SizeRefinement<Length>: Clone,
Option<f32>: Clone,
EdgesRefinement<DefiniteLength>: Clone,
Option<AlignItems>: Clone,
Option<AlignSelf>: Clone,
Option<VerticalAlign>: Clone,
Option<AlignContent>: Clone,
Option<JustifyContent>: Clone,
SizeRefinement<DefiniteLength>: Clone,
Option<FlexDirection>: Clone,
Option<FlexWrap>: Clone,
Option<Length>: Clone,
Option<Fill>: Clone,
Option<Background>: Clone,
Option<BorderStyle>: Clone,
CornersRefinement<AbsoluteLength>: Clone,
Option<Vec<BoxShadow>>: Clone,
RingStyleRefinement: Clone,
Option<Vec<Filter>>: Clone,
TextStyleRefinement: Clone,
Option<CursorStyle>: Clone,
Option<GridTemplate>: Clone,
Option<GridLocation>: Clone,
Source§fn from(value: StyleRefinement) -> Self
fn from(value: StyleRefinement) -> Self
Source§impl Refineable for Stylewhere
Option<Display>: Clone,
Option<Visibility>: Clone,
Option<LayoutDirection>: Clone,
Option<UnicodeBidi>: Clone,
Option<bool>: Clone,
PointRefinement<Overflow>: Clone,
EdgesRefinement<AbsoluteLength>: Clone,
Option<AbsoluteLength>: Clone,
Option<Position>: Clone,
EdgesRefinement<Length>: Clone,
SizeRefinement<Length>: Clone,
Option<f32>: Clone,
EdgesRefinement<DefiniteLength>: Clone,
Option<AlignItems>: Clone,
Option<AlignSelf>: Clone,
Option<VerticalAlign>: Clone,
Option<AlignContent>: Clone,
Option<JustifyContent>: Clone,
SizeRefinement<DefiniteLength>: Clone,
Option<FlexDirection>: Clone,
Option<FlexWrap>: Clone,
Option<Length>: Clone,
Option<Fill>: Clone,
Option<Background>: Clone,
Option<BorderStyle>: Clone,
CornersRefinement<AbsoluteLength>: Clone,
Option<Vec<BoxShadow>>: Clone,
RingStyleRefinement: Clone,
Option<Vec<Filter>>: Clone,
TextStyleRefinement: Clone,
Option<CursorStyle>: Clone,
Option<GridTemplate>: Clone,
Option<GridLocation>: Clone,
impl Refineable for Stylewhere
Option<Display>: Clone,
Option<Visibility>: Clone,
Option<LayoutDirection>: Clone,
Option<UnicodeBidi>: Clone,
Option<bool>: Clone,
PointRefinement<Overflow>: Clone,
EdgesRefinement<AbsoluteLength>: Clone,
Option<AbsoluteLength>: Clone,
Option<Position>: Clone,
EdgesRefinement<Length>: Clone,
SizeRefinement<Length>: Clone,
Option<f32>: Clone,
EdgesRefinement<DefiniteLength>: Clone,
Option<AlignItems>: Clone,
Option<AlignSelf>: Clone,
Option<VerticalAlign>: Clone,
Option<AlignContent>: Clone,
Option<JustifyContent>: Clone,
SizeRefinement<DefiniteLength>: Clone,
Option<FlexDirection>: Clone,
Option<FlexWrap>: Clone,
Option<Length>: Clone,
Option<Fill>: Clone,
Option<Background>: Clone,
Option<BorderStyle>: Clone,
CornersRefinement<AbsoluteLength>: Clone,
Option<Vec<BoxShadow>>: Clone,
RingStyleRefinement: Clone,
Option<Vec<Filter>>: Clone,
TextStyleRefinement: Clone,
Option<CursorStyle>: Clone,
Option<GridTemplate>: Clone,
Option<GridLocation>: Clone,
type Refinement = StyleRefinement
Source§fn refine(&mut self, refinement: &Self::Refinement)
fn refine(&mut self, refinement: &Self::Refinement)
Source§fn refined(self, refinement: Self::Refinement) -> Self
fn refined(self, refinement: Self::Refinement) -> Self
self and calling
refine on it.Source§fn is_superset_of(&self, refinement: &Self::Refinement) -> bool
fn is_superset_of(&self, refinement: &Self::Refinement) -> bool
true if this instance would contain all values from the refinement. Read moreSource§fn subtract(&self, refinement: &Self::Refinement) -> Self::Refinement
fn subtract(&self, refinement: &Self::Refinement) -> Self::Refinement
Auto Trait Implementations§
impl Freeze for Style
impl RefUnwindSafe for Style
impl Send for Style
impl Sync for Style
impl Unpin for Style
impl UnsafeUnpin for Style
impl UnwindSafe for Style
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
replaced by palette::chromatic_adaptation::AdaptIntoUnclamped
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
replaced by palette::chromatic_adaptation::AdaptIntoUnclamped
Source§impl<T, C> AdaptIntoUnclamped<T> for Cwhere
T: AdaptFromUnclamped<C>,
impl<T, C> AdaptIntoUnclamped<T> for Cwhere
T: AdaptFromUnclamped<C>,
Source§type Scalar = <T as AdaptFromUnclamped<C>>::Scalar
type Scalar = <T as AdaptFromUnclamped<C>>::Scalar
Source§fn adapt_into_unclamped_with<M>(self) -> Twhere
M: LmsToXyz<<C as AdaptIntoUnclamped<T>>::Scalar> + XyzToLms<<C as AdaptIntoUnclamped<T>>::Scalar>,
fn adapt_into_unclamped_with<M>(self) -> Twhere
M: LmsToXyz<<C as AdaptIntoUnclamped<T>>::Scalar> + XyzToLms<<C as AdaptIntoUnclamped<T>>::Scalar>,
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Source§impl<T, C> ComponentsInto<C> for T
impl<T, C> ComponentsInto<C> for T
Source§fn components_into(self) -> C
fn components_into(self) -> C
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
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 moreSource§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
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().Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more