pub struct Align2(pub [Align; 2]);
Expand description
Two-dimension alignment, e.g. Align2::LEFT_TOP
.
Tuple Fields§
§0: [Align; 2]
Implementations§
Source§impl Align2
impl Align2
pub const LEFT_BOTTOM: Align2
pub const LEFT_CENTER: Align2
pub const LEFT_TOP: Align2
pub const CENTER_BOTTOM: Align2
pub const CENTER_CENTER: Align2
pub const CENTER_TOP: Align2
pub const RIGHT_BOTTOM: Align2
pub const RIGHT_CENTER: Align2
pub const RIGHT_TOP: Align2
Source§impl Align2
impl Align2
Sourcepub fn anchor_rect(self, rect: Rect) -> Rect
pub fn anchor_rect(self, rect: Rect) -> Rect
Used e.g. to anchor a piece of text to a part of the rectangle. Give a position within the rect, specified by the aligns
Sourcepub fn anchor_size(self, pos: Pos2, size: Vec2) -> Rect
pub fn anchor_size(self, pos: Pos2, size: Vec2) -> Rect
Use this anchor to position something around pos
,
e.g. Self::RIGHT_TOP
means the right-top of the rect
will end up at pos
.
Sourcepub fn align_size_within_rect(self, size: Vec2, frame: Rect) -> Rect
pub fn align_size_within_rect(self, size: Vec2, frame: Rect) -> Rect
e.g. center a size within a given frame
Sourcepub fn pos_in_rect(self, frame: &Rect) -> Pos2
pub fn pos_in_rect(self, frame: &Rect) -> Pos2
Returns the point on the rect’s frame or in the center of a rect according to the alignments of this object.
(*)-----------+------(*)------+-----------(*)--> X
| | | |
| Min, Min | Center, Min | Max, Min |
| | | |
+------------+---------------+------------+
| | | |
(*)Min, Center|Center(*)Center|Max, Center(*)
| | | |
+------------+---------------+------------+
| | | |
| Min, Max | Center, Max | Max, Max |
| | | |
(*)-----------+------(*)------+-----------(*)
|
Y
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Align2
impl<'de> Deserialize<'de> for Align2
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Align2, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Align2, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for Align2
impl Serialize for Align2
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 Copy for Align2
impl Eq for Align2
impl StructuralPartialEq for Align2
Auto Trait Implementations§
impl Freeze for Align2
impl RefUnwindSafe for Align2
impl Send for Align2
impl Sync for Align2
impl Unpin for Align2
impl UnwindSafe for Align2
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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