Skip to main content

Bounds

Struct Bounds 

Source
#[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>

Source

pub const fn new(origin: Point<T>, size: Size<T>) -> Bounds<T>

Bounds at origin of size.

Source§

impl<T> Bounds<T>
where T: Clone,

Source

pub fn map<U>(&self, f: impl Fn(T) -> U) -> Bounds<U>

Every coordinate converted by f.

Source

pub fn map_origin(self, f: impl Fn(T) -> T) -> Bounds<T>

The origin’s coordinates converted by f, the size kept.

Source

pub fn map_size(self, f: impl Fn(T) -> T) -> Bounds<T>

The size’s dimensions converted by f, the origin kept.

Source§

impl<T> Bounds<T>
where T: Add<Output = T> + Sub<Output = T> + Clone,

Source

pub fn from_corners(top_left: Point<T>, bottom_right: Point<T>) -> Bounds<T>

The bounds between two corners.

Source

pub fn top(&self) -> T

The top edge.

Source

pub fn bottom(&self) -> T

The bottom edge.

Source

pub fn left(&self) -> T

The left edge.

Source

pub fn right(&self) -> T

The right edge.

Source

pub fn top_right(&self) -> Point<T>

The top right corner.

Source

pub fn bottom_right(&self) -> Point<T>

The bottom right corner.

Source

pub fn bottom_left(&self) -> Point<T>

The bottom left corner.

Source

pub fn dilate(&self, amount: T) -> Bounds<T>

The bounds grown by amount on every side.

Source

pub fn extend(&self, amount: Edges<T>) -> Bounds<T>

The bounds grown by each of amount’s edges.

Source

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>
where T: Sub<Output = T> + Clone + Neg<Output = T> + Add<Output = T>,

Source

pub fn inset(&self, amount: T) -> Bounds<T>

The bounds shrunk by amount on every side (dilate of -amount).

Source§

impl<T> Bounds<T>
where T: Add<Output = T> + Sub<Output = T> + Clone + Half,

Source

pub fn centered_at(center: Point<T>, size: Size<T>) -> Bounds<T>

Bounds of size centered at center.

Source

pub fn center(&self) -> Point<T>

The center.

Source

pub fn half_perimeter(&self) -> T

The width plus the height.

Source§

impl<T> Bounds<T>
where T: Add<Output = T> + Sub<Output = T> + Clone + PartialOrd,

Source

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.

Source

pub fn is_contained_within(&self, other: &Bounds<T>) -> bool

Whether the bounds lie within other.

Source

pub fn intersects(&self, other: &Bounds<T>) -> bool

Whether the two bounds overlap.

Source

pub fn intersect(&self, other: &Bounds<T>) -> Bounds<T>

The overlap of two bounds (of no size when they do not overlap).

Source

pub fn union(&self, other: &Bounds<T>) -> Bounds<T>

The smallest bounds holding both.

Source

pub fn localize(&self, point: &Point<T>) -> Option<Point<T>>

point relative to the bounds’ origin, if it is inside.

Source§

impl<T> Bounds<T>
where T: PartialOrd + Default,

Source

pub fn is_empty(&self) -> bool

Whether the bounds cover no area (a dimension zero or less).

Source§

impl Bounds<Points>

Source

pub fn scale(&self, factor: f32) -> Bounds<ScaledPixels>

Scaled to device pixels at factor (unrounded).

Source

pub fn to_device_pixels(self, scale_factor: f32) -> Bounds<DevicePixels>

In whole device pixels at scale_factor.

Source§

impl Bounds<DevicePixels>

Source

pub fn to_points(self, scale_factor: f32) -> Bounds<Points>

In points at scale_factor device pixels per point.

Trait Implementations§

Source§

impl<T> Add<Point<T>> for Bounds<T>
where T: Add<Output = T>,

The bounds moved by a point.

Source§

type Output = Bounds<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Point<T>) -> Bounds<T>

Performs the + operation. Read more
Source§

impl<T> Clone for Bounds<T>
where T: Clone,

Source§

fn clone(&self) -> Bounds<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Copy for Bounds<T>
where T: Copy,

Source§

impl<T> Debug for Bounds<T>
where T: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<T> Default for Bounds<T>
where T: Default,

Source§

fn default() -> Bounds<T>

Returns the “default value” for a type. Read more
Source§

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>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T, S> Div<S> for Bounds<T>
where T: Div<S, Output = T>, S: Clone,

Source§

type Output = Bounds<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: S) -> Bounds<T>

Performs the / operation. Read more
Source§

impl<T> Eq for Bounds<T>
where T: Eq,

Source§

impl From<&Layout> for Bounds<Points>

A laid out node’s border box relative to its parent.

Source§

fn from(l: &Layout) -> Bounds<Points>

Converts to this type from the input type.
Source§

impl<T> Hash for Bounds<T>
where T: Hash,

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T> IsZero for Bounds<T>
where T: IsZero,

Source§

fn is_zero(&self) -> bool

Whether the value is zero.
Source§

impl<T, S> Mul<S> for Bounds<T>
where T: Mul<S, Output = T>, S: Clone,

Source§

type Output = Bounds<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: S) -> Bounds<T>

Performs the * operation. Read more
Source§

impl<T, S> MulAssign<S> for Bounds<T>
where T: MulAssign<S>, S: Clone,

Source§

fn mul_assign(&mut self, rhs: S)

Performs the *= operation. Read more
Source§

impl<T> PartialEq for Bounds<T>
where T: PartialEq,

Source§

fn eq(&self, other: &Bounds<T>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

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,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T> StructuralPartialEq for Bounds<T>
where T: PartialEq,

Source§

impl<T> Sub<Point<T>> for Bounds<T>
where T: Sub<Output = T>,

The bounds moved back by a point.

Source§

type Output = Bounds<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Point<T>) -> Bounds<T>

Performs the - operation. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Bounds<T>
where Point<T>: Freeze, Size<T>: Freeze,

§

impl<T> RefUnwindSafe for Bounds<T>

§

impl<T> Send for Bounds<T>
where Point<T>: Send, Size<T>: Send,

§

impl<T> Sync for Bounds<T>
where Point<T>: Sync, Size<T>: Sync,

§

impl<T> Unpin for Bounds<T>
where Point<T>: Unpin, Size<T>: Unpin,

§

impl<T> UnsafeUnpin for Bounds<T>

§

impl<T> UnwindSafe for Bounds<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsOut<T> for T
where T: Copy,

Source§

fn as_out(&mut self) -> Out<'_, T>

Returns an out reference to self.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ParallelSend for T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, Rhs, Output> ScalarMul<Rhs, Output> for T
where T: Mul<Rhs, Output = Output> + MulAssign<Rhs>,

Source§

impl<T, Rhs, Output> ScalarMulOwned<Rhs, Output> for T
where T: for<'r> ScalarMul<&'r Rhs, Output>,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more