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: Self = _
pub const LEFT_CENTER: Self = _
pub const LEFT_TOP: Self = _
pub const CENTER_BOTTOM: Self = _
pub const CENTER_CENTER: Self = _
pub const CENTER_TOP: Self = _
pub const RIGHT_BOTTOM: Self = _
pub const RIGHT_CENTER: Self = _
pub const RIGHT_TOP: Self = _
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<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. 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