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 PartialEq for Align2
impl PartialEq for Align2
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