pub struct Rect<T> {
pub left: T,
pub right: T,
pub top: T,
pub bottom: T,
}
Expand description
An axis-aligned UI rectangle
Fields§
§left: T
This can represent either the x-coordinate of the starting edge, or the amount of padding on the starting side.
The starting edge is the left edge when working with LTR text, and the right edge when working with RTL text.
right: T
This can represent either the x-coordinate of the ending edge, or the amount of padding on the ending side.
The ending edge is the right edge when working with LTR text, and the left edge when working with RTL text.
top: T
This can represent either the y-coordinate of the top edge, or the amount of padding on the top side.
bottom: T
This can represent either the y-coordinate of the bottom edge, or the amount of padding on the bottom side.
Implementations§
Source§impl<T: Add> Rect<T>
impl<T: Add> Rect<T>
Sourcepub fn grid_axis_sum(self, axis: AbsoluteAxis) -> <T as Add>::Output
pub fn grid_axis_sum(self, axis: AbsoluteAxis) -> <T as Add>::Output
Get either the width or height depending on the AbsoluteAxis passed in
Source§impl<T> Rect<T>
impl<T> Rect<T>
Sourcepub fn map<R, F>(self, f: F) -> Rect<R>where
F: Fn(T) -> R,
pub fn map<R, F>(self, f: F) -> Rect<R>where
F: Fn(T) -> R,
Applies the function f
to the left, right, top, and bottom properties
This is used to transform a Rect<T>
into a Rect<R>
.
Sourcepub fn horizontal_components(self) -> Line<T>
pub fn horizontal_components(self) -> Line<T>
Returns a Line<T>
representing the left and right properties of the Rect
Sourcepub fn vertical_components(self) -> Line<T>
pub fn vertical_components(self) -> Line<T>
Returns a Line<T>
containing the top and bottom properties of the Rect
Source§impl<T, U> Rect<T>
impl<T, U> Rect<T>
Sourcepub(crate) fn horizontal_axis_sum(&self) -> U
pub(crate) fn horizontal_axis_sum(&self) -> U
The sum of Rect.start
and Rect.end
This is typically used when computing total padding.
NOTE: this is not the width of the rectangle.
Sourcepub(crate) fn vertical_axis_sum(&self) -> U
pub(crate) fn vertical_axis_sum(&self) -> U
The sum of Rect.top
and Rect.bottom
This is typically used when computing total padding.
NOTE: this is not the height of the rectangle.
Source§impl Rect<Dimension>
impl Rect<Dimension>
Sourcepub const fn from_length(start: f32, end: f32, top: f32, bottom: f32) -> Self
pub const fn from_length(start: f32, end: f32, top: f32, bottom: f32) -> Self
Create a new Rect with Dimension::Length
Sourcepub const fn from_percent(start: f32, end: f32, top: f32, bottom: f32) -> Self
pub const fn from_percent(start: f32, end: f32, top: f32, bottom: f32) -> Self
Create a new Rect with Dimension::Percent
Source§impl<T: TaffyMinContent> Rect<T>
impl<T: TaffyMinContent> Rect<T>
Sourcepub const fn min_content() -> Self
pub const fn min_content() -> Self
Returns a Rect where the left, right, top, and bottom values are all the min_content value of the contained type (e.g. Dimension::Auto or LengthPercentageAuto::Auto)
Source§impl<T: TaffyMaxContent> Rect<T>
impl<T: TaffyMaxContent> Rect<T>
Sourcepub const fn max_content() -> Self
pub const fn max_content() -> Self
Returns a Rect where the left, right, top, and bottom values are all the max_content value of the contained type (e.g. Dimension::Auto or LengthPercentageAuto::Auto)
Source§impl<T: TaffyFitContent> Rect<T>
impl<T: TaffyFitContent> Rect<T>
Sourcepub fn fit_content(argument: LengthPercentage) -> Self
pub fn fit_content(argument: LengthPercentage) -> Self
Returns a Rect where the left, right, top and bottom values are all constant fit_content value of the contained type (e.g. 2.1, Some(2.1), or Dimension::Length(2.1))
Source§impl<T: FromLength> Rect<T>
impl<T: FromLength> Rect<T>
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Rect<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Rect<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<T: FromLength> FromLength for Rect<T>
impl<T: FromLength> FromLength for Rect<T>
Source§impl<T: FromPercent> FromPercent for Rect<T>
impl<T: FromPercent> FromPercent for Rect<T>
Source§impl<Out: TaffyZero, T: ResolveOrZero<Option<f32>, Out>> ResolveOrZero<Option<f32>, Rect<Out>> for Rect<T>
impl<Out: TaffyZero, T: ResolveOrZero<Option<f32>, Out>> ResolveOrZero<Option<f32>, Rect<Out>> for Rect<T>
Source§impl<In: Copy, Out: TaffyZero, T: ResolveOrZero<In, Out>> ResolveOrZero<Size<In>, Rect<Out>> for Rect<T>
impl<In: Copy, Out: TaffyZero, T: ResolveOrZero<In, Out>> ResolveOrZero<Size<In>, Rect<Out>> for Rect<T>
Source§fn resolve_or_zero(self, context: Size<In>) -> Rect<Out>
fn resolve_or_zero(self, context: Size<In>) -> Rect<Out>
Converts any parent
-relative values for Rect into an absolute Rect