pub enum Anchor {
TopLeft,
TopCenter,
TopRight,
CenterLeft,
Center,
CenterRight,
BottomLeft,
BottomCenter,
BottomRight,
}Expand description
Placement within a parent; oversized requests shrink to its available extent.
Unlike stretched Anchors, this keeps a fixed HUD size whenever it fits.
Variants§
Implementations§
Source§impl Anchor
impl Anchor
Sourcepub fn place(self, parent: Rect, size: [f32; 2]) -> Result<Rect, UiError>
pub fn place(self, parent: Rect, size: [f32; 2]) -> Result<Rect, UiError>
Place a requested size entirely inside parent, including empty parents.
use ferravex_play::ui::{Anchor, Viewport};
let viewport = Viewport::responsive([800., 600.], [0., 24., 0., 16.])?;
let safe = viewport.bounds().inset([12.; 4])?;
let score = Anchor::TopRight.place(safe, [180., 44.])?;
assert_eq!(score.min, [608., 12.]); // Logical coordinates within the safe area.Trait Implementations§
impl Copy for Anchor
impl Eq for Anchor
impl StructuralPartialEq for Anchor
Auto Trait Implementations§
impl Freeze for Anchor
impl RefUnwindSafe for Anchor
impl Send for Anchor
impl Sync for Anchor
impl Unpin for Anchor
impl UnwindSafe for Anchor
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