Skip to main content

RectAlign

Struct RectAlign 

Source
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: Align2

Anchor point on the parent (the widget the popup hangs off).

§child: Align2

Anchor point on the popup itself.

Implementations§

Source§

impl RectAlign

Source

pub const BOTTOM_START: Self

Below the widget, left edges aligned.

Source

pub const BOTTOM: Self

Below the widget, horizontally centered.

Source

pub const BOTTOM_END: Self

Below the widget, right edges aligned.

Source

pub const TOP_START: Self

Above the widget, left edges aligned.

Source

pub const TOP: Self

Above the widget, horizontally centered.

Source

pub const TOP_END: Self

Above the widget, right edges aligned.

Source

pub const RIGHT_START: Self

To the right of the widget, top edges aligned.

Source

pub const RIGHT: Self

To the right of the widget, vertically centered.

Source

pub const RIGHT_END: Self

To the right of the widget, bottom edges aligned.

Source

pub const LEFT_START: Self

To the left of the widget, top edges aligned.

Source

pub const LEFT: Self

To the left of the widget, vertically centered.

Source

pub const LEFT_END: Self

To the left of the widget, bottom edges aligned.

Source

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).

Source

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.

Source

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.

Source

pub fn flip_x(self) -> Self

Mirror the placement on the x-axis (e.g. RIGHTLEFT).

Source

pub fn flip_y(self) -> Self

Mirror the placement on the y-axis (e.g. BOTTOM_STARTTOP_START).

Source

pub fn flip(self) -> Self

Mirror the placement on both axes.

Source

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).

Source

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.

Source

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.

Source

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§

Source§

impl Clone for RectAlign

Source§

fn clone(&self) -> RectAlign

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for RectAlign

Source§

impl Debug for RectAlign

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for RectAlign

Source§

impl PartialEq for RectAlign

Source§

fn eq(&self, other: &RectAlign) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RectAlign

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

Converts 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)

Converts &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)

Converts &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
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<A> Is for A
where A: Any,

Source§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> TypeData for T
where T: 'static + Send + Sync + Clone,

Source§

fn clone_type_data(&self) -> Box<dyn TypeData>

Creates a type-erased clone of this value.