Struct PopupPlacementSpec

Source
pub struct PopupPlacementSpec { /* private fields */ }
Expand description

Provider-neutral placement requested before a host viewport is known.

The active host combines this semantic geometry with its viewport and backend capabilities through resolve_popup_placement. Keeping viewport data out of this value prevents widgets from substituting their own bounds for the complete presentation area. All geometry is in logical pixels and is stored without validation; portal publication or placement resolution performs validation.

§Examples

use ailloli_ui_core::{Rect, Size};
use ailloli_ui_runtime::popup::PopupPlacementSpec;
let spec = PopupPlacementSpec::new(Rect::new(1.0, 2.0, 3.0, 4.0), Size::new(20.0, 10.0));
assert_eq!(spec.gap(), 0.0);
assert!(spec.allows_flip());

Implementations§

Source§

impl PopupPlacementSpec

Builder and accessor operations for semantic placement input.

Source

pub const fn new(anchor: Rect, desired_size: Size) -> Self

Creates bottom-centered placement with zero gap and flipping enabled.

Values are stored verbatim and validated only when published/resolved.

§Examples
use ailloli_ui_core::{Rect, Size};
use ailloli_ui_runtime::popup::{PopupAlignment, PopupPlacement, PopupPlacementSpec};
let spec = PopupPlacementSpec::new(Rect::new(0.0, 0.0, 10.0, 5.0), Size::new(30.0, 20.0));
assert_eq!((spec.placement(), spec.alignment(), spec.gap(), spec.allows_flip()), (PopupPlacement::Bottom, PopupAlignment::Center, 0.0, true));
Source

pub const fn anchor(self) -> Rect

Returns the stored global logical-pixel anchor rectangle.

§Examples
use ailloli_ui_core::{Rect, Size};
use ailloli_ui_runtime::popup::PopupPlacementSpec;
let anchor = Rect::new(1.0, 2.0, 3.0, 4.0);
assert_eq!(PopupPlacementSpec::new(anchor, Size::new(5.0, 6.0)).anchor(), anchor);
Source

pub const fn desired_size(self) -> Size

Returns the requested logical-pixel popup size.

§Examples
use ailloli_ui_core::{Rect, Size};
use ailloli_ui_runtime::popup::PopupPlacementSpec;
let size = Size::new(20.0, 10.0);
assert_eq!(PopupPlacementSpec::new(Rect::new(0.0, 0.0, 0.0, 0.0), size).desired_size(), size);
Source

pub const fn placement(self) -> PopupPlacement

Returns the preferred vertical side.

§Examples
use ailloli_ui_core::{Rect, Size};
use ailloli_ui_runtime::popup::{PopupPlacement, PopupPlacementSpec};
assert_eq!(PopupPlacementSpec::new(Rect::new(0.0, 0.0, 0.0, 0.0), Size::default()).placement(), PopupPlacement::Bottom);
Source

pub const fn alignment(self) -> PopupAlignment

Returns the requested cross-axis alignment.

§Examples
use ailloli_ui_core::{Rect, Size};
use ailloli_ui_runtime::popup::{PopupAlignment, PopupPlacementSpec};
assert_eq!(PopupPlacementSpec::new(Rect::new(0.0, 0.0, 0.0, 0.0), Size::default()).alignment(), PopupAlignment::Center);
Source

pub const fn gap(self) -> f32

Returns the requested anchor gap in logical pixels.

§Examples
use ailloli_ui_core::{Rect, Size};
use ailloli_ui_runtime::popup::PopupPlacementSpec;
assert_eq!(PopupPlacementSpec::new(Rect::new(0.0, 0.0, 0.0, 0.0), Size::default()).with_gap(4.0).gap(), 4.0);
Source

pub const fn allows_flip(self) -> bool

Returns whether the host may select the opposite vertical side.

§Examples
use ailloli_ui_core::{Rect, Size};
use ailloli_ui_runtime::popup::PopupPlacementSpec;
assert!(!PopupPlacementSpec::new(Rect::new(0.0, 0.0, 0.0, 0.0), Size::default()).with_flip(false).allows_flip());
Source

pub const fn with_placement(self, placement: PopupPlacement) -> Self

Replaces the preferred vertical side.

§Examples
use ailloli_ui_core::{Rect, Size};
use ailloli_ui_runtime::popup::{PopupPlacement, PopupPlacementSpec};
let spec = PopupPlacementSpec::new(Rect::new(0.0, 0.0, 0.0, 0.0), Size::default()).with_placement(PopupPlacement::Top);
assert_eq!(spec.placement(), PopupPlacement::Top);
Source

pub const fn with_alignment(self, alignment: PopupAlignment) -> Self

Replaces cross-axis alignment.

§Examples
use ailloli_ui_core::{Rect, Size};
use ailloli_ui_runtime::popup::{PopupAlignment, PopupPlacementSpec};
let spec = PopupPlacementSpec::new(Rect::new(0.0, 0.0, 0.0, 0.0), Size::default()).with_alignment(PopupAlignment::End);
assert_eq!(spec.alignment(), PopupAlignment::End);
Source

pub const fn with_gap(self, gap: f32) -> Self

Replaces the logical-pixel gap without validating it.

Negative and non-finite values are rejected when the spec is published.

§Examples
use ailloli_ui_core::{Rect, Size};
use ailloli_ui_runtime::popup::PopupPlacementSpec;
assert_eq!(PopupPlacementSpec::new(Rect::new(0.0, 0.0, 0.0, 0.0), Size::default()).with_gap(2.5).gap(), 2.5);
Source

pub const fn with_flip(self, allow_flip: bool) -> Self

Enables or disables automatic vertical-side flipping.

§Examples
use ailloli_ui_core::{Rect, Size};
use ailloli_ui_runtime::popup::PopupPlacementSpec;
assert!(!PopupPlacementSpec::new(Rect::new(0.0, 0.0, 0.0, 0.0), Size::default()).with_flip(false).allows_flip());

Trait Implementations§

Source§

impl Clone for PopupPlacementSpec

Source§

fn clone(&self) -> PopupPlacementSpec

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PopupPlacementSpec

Source§

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

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

impl PartialEq for PopupPlacementSpec

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for PopupPlacementSpec

Source§

impl StructuralPartialEq for PopupPlacementSpec

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> 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<A> IntoClickAction<A> for A
where A: Clone + 'static,

Source§

fn into_click_action(self) -> ClickAction<A>

Implements the into_click_action helper used by this module.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> Props for T
where T: Clone + 'static,