pub struct RectAlign {
pub parent: Align2,
pub child: Align2,
}Expand description
A parent/child anchor pair describing how a popup attaches to its anchoring
widget — the placement half of the Popup API (egui’s RectAlign).
Fields§
§parent: Align2Anchor point on the parent (the widget the popup hangs off).
child: Align2Anchor point on the popup itself.
Implementations§
Source§impl RectAlign
impl RectAlign
Sourcepub const BOTTOM_START: Self
pub const BOTTOM_START: Self
Below the widget, left edges aligned.
Sourcepub const BOTTOM_END: Self
pub const BOTTOM_END: Self
Below the widget, right edges aligned.
Sourcepub const RIGHT_START: Self
pub const RIGHT_START: Self
To the right of the widget, top edges aligned.
Sourcepub const LEFT_START: Self
pub const LEFT_START: Self
To the left of the widget, top edges aligned.
Sourcepub const PRESETS: [(Self, &'static str); 12]
pub const PRESETS: [(Self, &'static str); 12]
The named presets with the display names and ordering of egui’s Popups demo preset combo box (egui_demo_lib/src/demo/popups.rs).
Sourcepub const MENU_ALIGNS: [Self; 12]
pub const MENU_ALIGNS: [Self; 12]
The 12 common menu positions in egui’s fallback-preference order
(emath’s RectAlign::MENU_ALIGNS): corner placements first, centered
ones last, for use with RectAlign::find_best_align.
Sourcepub fn preset_label(self) -> Option<&'static str>
pub fn preset_label(self) -> Option<&'static str>
The preset label matching this alignment exactly, or None for an
arbitrary (combo-box-composed) pair that isn’t a named preset.
Sourcepub fn flip_y(self) -> Self
pub fn flip_y(self) -> Self
Mirror the placement on the y-axis (e.g. BOTTOM_START → TOP_START).
Sourcepub fn symmetries(self) -> [Self; 3]
pub fn symmetries(self) -> [Self; 3]
The 3 alternative placements flipped in various ways, for use with
RectAlign::find_best_align (mirrors egui’s RectAlign::symmetries).
Sourcepub fn find_best_align(
values_to_try: impl Iterator<Item = Self>,
content_rect: Rect,
parent_rect: Rect,
gap: f64,
expected_size: Size,
) -> Option<Self>
pub fn find_best_align( values_to_try: impl Iterator<Item = Self>, content_rect: Rect, parent_rect: Rect, gap: f64, expected_size: Size, ) -> Option<Self>
Look for the first candidate placement whose popup rect fits entirely
inside content_rect — egui’s overflow-flip (find_best_align).
If no candidate fits, the FIRST candidate is returned (so the caller’s
preferred alignment wins and downstream clamping takes over). Returns
None only when the iterator is empty.
Sourcepub fn place_child(self, parent: Rect, size: Size, gap: f64) -> Rect
pub fn place_child(self, parent: Rect, size: Size, gap: f64) -> Rect
Place a popup of size relative to parent, applying gap pixels of
separation.
The gap is applied only along axes where the parent and child anchors
differ — i.e. the side the popup extends toward — so an edge-attached
popup (e.g. RectAlign::BOTTOM_START) gets vertical separation without
being nudged sideways.
Sourcepub fn place_child_clamped(
self,
parent: Rect,
size: Size,
gap: f64,
viewport: Size,
) -> Rect
pub fn place_child_clamped( self, parent: Rect, size: Size, gap: f64, viewport: Size, ) -> Rect
place_child then clamp the result fully inside
viewport, leaving a small margin — so a popup near an edge stays
on-screen, matching how the menu system clamps its panels.
Trait Implementations§
impl Copy for RectAlign
impl Eq for RectAlign
impl StructuralPartialEq for RectAlign
Auto Trait Implementations§
impl Freeze for RectAlign
impl RefUnwindSafe for RectAlign
impl Send for RectAlign
impl Sync for RectAlign
impl Unpin for RectAlign
impl UnsafeUnpin for RectAlign
impl UnwindSafe for RectAlign
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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>
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>
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