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§
§impl<T> Rect<T>where
T: Add,
impl<T> Rect<T>where
T: Add,
pub 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
§impl<T> Rect<T>
impl<T> Rect<T>
pub 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>
.
pub 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
pub 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
§impl Rect<Dimension>
impl Rect<Dimension>
pub const fn from_length(
start: f32,
end: f32,
top: f32,
bottom: f32,
) -> Rect<Dimension>
pub const fn from_length( start: f32, end: f32, top: f32, bottom: f32, ) -> Rect<Dimension>
Create a new Rect with Dimension::Length
pub const fn from_percent(
start: f32,
end: f32,
top: f32,
bottom: f32,
) -> Rect<Dimension>
pub const fn from_percent( start: f32, end: f32, top: f32, bottom: f32, ) -> Rect<Dimension>
Create a new Rect with Dimension::Percent
§impl<T> Rect<T>where
T: TaffyMinContent,
impl<T> Rect<T>where
T: TaffyMinContent,
pub const fn min_content() -> Rect<T>
pub const fn min_content() -> Rect<T>
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)
§impl<T> Rect<T>where
T: TaffyMaxContent,
impl<T> Rect<T>where
T: TaffyMaxContent,
pub const fn max_content() -> Rect<T>
pub const fn max_content() -> Rect<T>
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)
§impl<T> Rect<T>where
T: TaffyFitContent,
impl<T> Rect<T>where
T: TaffyFitContent,
pub fn fit_content(argument: LengthPercentage) -> Rect<T>
pub fn fit_content(argument: LengthPercentage) -> Rect<T>
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))
§impl<T> Rect<T>where
T: FromLength,
impl<T> Rect<T>where
T: FromLength,
Trait Implementations§
§impl<'de, T> Deserialize<'de> for Rect<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Rect<T>where
T: Deserialize<'de>,
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Rect<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Rect<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl<T> FromLength for Rect<T>where
T: FromLength,
impl<T> FromLength for Rect<T>where
T: FromLength,
§impl<T> FromPercent for Rect<T>where
T: FromPercent,
impl<T> FromPercent for Rect<T>where
T: FromPercent,
§impl<Out, T> ResolveOrZero<Option<f32>, Rect<Out>> for Rect<T>
impl<Out, T> ResolveOrZero<Option<f32>, Rect<Out>> for Rect<T>
§fn resolve_or_zero(self, context: Option<f32>) -> Rect<Out>
fn resolve_or_zero(self, context: Option<f32>) -> Rect<Out>
Converts any parent
-relative values for Rect into an absolute Rect
§impl<In, Out, T> ResolveOrZero<Size<In>, Rect<Out>> for Rect<T>
impl<In, Out, T> ResolveOrZero<Size<In>, Rect<Out>> for Rect<T>
§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
§impl<T> Serialize for Rect<T>where
T: Serialize,
impl<T> Serialize for Rect<T>where
T: Serialize,
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
§impl<T> TaffyFitContent for Rect<T>where
T: TaffyFitContent,
impl<T> TaffyFitContent for Rect<T>where
T: TaffyFitContent,
§fn fit_content(argument: LengthPercentage) -> Rect<T>
fn fit_content(argument: LengthPercentage) -> Rect<T>
§impl<T> TaffyMaxContent for Rect<T>where
T: TaffyMaxContent,
impl<T> TaffyMaxContent for Rect<T>where
T: TaffyMaxContent,
§const MAX_CONTENT: Rect<T> = _
const MAX_CONTENT: Rect<T> = _
§impl<T> TaffyMinContent for Rect<T>where
T: TaffyMinContent,
impl<T> TaffyMinContent for Rect<T>where
T: TaffyMinContent,
§const MIN_CONTENT: Rect<T> = _
const MIN_CONTENT: Rect<T> = _
impl<T> Copy for Rect<T>where
T: Copy,
impl<T> Eq for Rect<T>where
T: Eq,
impl<T> StructuralPartialEq for Rect<T>
Auto Trait Implementations§
impl<T> Freeze for Rect<T>where
T: Freeze,
impl<T> RefUnwindSafe for Rect<T>where
T: RefUnwindSafe,
impl<T> Send for Rect<T>where
T: Send,
impl<T> Sync for Rect<T>where
T: Sync,
impl<T> Unpin for Rect<T>where
T: Unpin,
impl<T> UnwindSafe for Rect<T>where
T: UnwindSafe,
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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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