#[repr(C)]pub struct Bounds<T> {
pub origin: Point<T>,
pub size: Size<T>,
}Expand description
A rectangle: its top left corner (origin) and its size. A view’s
frame is its bounds relative to its parent.
Fields§
§origin: Point<T>The top left corner.
size: Size<T>The size.
Implementations§
Source§impl<T> Bounds<T>where
T: Clone,
impl<T> Bounds<T>where
T: Clone,
Sourcepub fn map_origin(self, f: impl Fn(T) -> T) -> Bounds<T>
pub fn map_origin(self, f: impl Fn(T) -> T) -> Bounds<T>
The origin’s coordinates converted by f, the size kept.
Source§impl<T> Bounds<T>
impl<T> Bounds<T>
Sourcepub fn from_corners(top_left: Point<T>, bottom_right: Point<T>) -> Bounds<T>
pub fn from_corners(top_left: Point<T>, bottom_right: Point<T>) -> Bounds<T>
The bounds between two corners.
Sourcepub fn bottom_right(&self) -> Point<T>
pub fn bottom_right(&self) -> Point<T>
The bottom right corner.
Sourcepub fn bottom_left(&self) -> Point<T>
pub fn bottom_left(&self) -> Point<T>
The bottom left corner.
Sourcepub fn extend(&self, amount: Edges<T>) -> Bounds<T>
pub fn extend(&self, amount: Edges<T>) -> Bounds<T>
The bounds grown by each of amount’s edges.
Sourcepub fn space_within(&self, outer: &Bounds<T>) -> Edges<T>
pub fn space_within(&self, outer: &Bounds<T>) -> Edges<T>
The space between these bounds and the outer bounds around them.
Source§impl<T> Bounds<T>
impl<T> Bounds<T>
Sourcepub fn centered_at(center: Point<T>, size: Size<T>) -> Bounds<T>
pub fn centered_at(center: Point<T>, size: Size<T>) -> Bounds<T>
Bounds of size centered at center.
Sourcepub fn half_perimeter(&self) -> T
pub fn half_perimeter(&self) -> T
The width plus the height.
Source§impl<T> Bounds<T>
impl<T> Bounds<T>
Sourcepub fn contains(&self, point: &Point<T>) -> bool
pub fn contains(&self, point: &Point<T>) -> bool
Whether point is inside: on the left or top edge is, on the right
or bottom one is not.
Sourcepub fn is_contained_within(&self, other: &Bounds<T>) -> bool
pub fn is_contained_within(&self, other: &Bounds<T>) -> bool
Whether the bounds lie within other.
Sourcepub fn intersects(&self, other: &Bounds<T>) -> bool
pub fn intersects(&self, other: &Bounds<T>) -> bool
Whether the two bounds overlap.
Source§impl<T> Bounds<T>where
T: PartialOrd + Default,
impl<T> Bounds<T>where
T: PartialOrd + Default,
Source§impl Bounds<Points>
impl Bounds<Points>
Sourcepub fn scale(&self, factor: f32) -> Bounds<ScaledPixels>
pub fn scale(&self, factor: f32) -> Bounds<ScaledPixels>
Scaled to device pixels at factor (unrounded).
Sourcepub fn to_device_pixels(self, scale_factor: f32) -> Bounds<DevicePixels>
pub fn to_device_pixels(self, scale_factor: f32) -> Bounds<DevicePixels>
In whole device pixels at scale_factor.
Trait Implementations§
impl<T> Copy for Bounds<T>where
T: Copy,
Source§impl<'de, T> Deserialize<'de> for Bounds<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Bounds<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Bounds<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Bounds<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<T> Eq for Bounds<T>where
T: Eq,
Source§impl<T, S> MulAssign<S> for Bounds<T>
impl<T, S> MulAssign<S> for Bounds<T>
Source§fn mul_assign(&mut self, rhs: S)
fn mul_assign(&mut self, rhs: S)
Performs the
*= operation. Read moreSource§impl<T> Serialize for Bounds<T>where
T: Serialize,
impl<T> Serialize for Bounds<T>where
T: Serialize,
Source§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,
Serialize this value into the given Serde serializer. Read more
impl<T> StructuralPartialEq for Bounds<T>where
T: PartialEq,
Auto Trait Implementations§
impl<T> Freeze for Bounds<T>
impl<T> RefUnwindSafe for Bounds<T>
impl<T> Send for Bounds<T>
impl<T> Sync for Bounds<T>
impl<T> Unpin for Bounds<T>
impl<T> UnsafeUnpin for Bounds<T>
impl<T> UnwindSafe for Bounds<T>
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
Mutably borrows from an owned value. Read more
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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
Compare self to
key and return true if they are equal.