Struct PopupRequest

Source
pub struct PopupRequest<A> { /* private fields */ }
Expand description

Registration contract for one popup.

A request combines immutable identity/ownership, optional parent and geometry, backend/placement preferences, a remountable content factory, and interaction semantics. Defaults are closed-registration friendly: no parent, anchor, or desired size; bottom-center, zero gap, flip enabled; overlay backend and retained-overlay mounting. Builders store geometry verbatim; portal publication/resolution validates it.

§Examples

use ailloli_ui_core::ElementId; use ailloli_ui_runtime::{app::PresentationGeneration, component::View, popup::*};
let request = PopupRequest::<()>::new(PopupId::new(1), PopupOwner::new("main", PresentationGeneration::INITIAL, ElementTreeId::new(0), ElementId(1)), PopupContent::new(View::empty));
assert_eq!(request.parent(), None);
assert_eq!(request.mount_policy(), PopupMountPolicy::RetainedOverlay);

Implementations§

Source§

impl<A> PopupRequest<A>

Construction, immutable access, builders, and placement resolution.

Source

pub fn new(id: PopupId, owner: PopupOwner, content: PopupContent<A>) -> Self

Creates a closed-registration request with semantic defaults.

IDs/owner liveness are not checked and content is not built.

§Examples
use ailloli_ui_core::ElementId; use ailloli_ui_runtime::{app::PresentationGeneration, component::View, popup::*};
let request = PopupRequest::<()>::new(PopupId::new(2), PopupOwner::new("main", PresentationGeneration::INITIAL, ElementTreeId::new(0), ElementId(3)), PopupContent::new(View::empty));
assert_eq!(request.id(), PopupId::new(2));
assert_eq!((request.anchor(), request.desired_size()), (None, None));
Source

pub const fn id(&self) -> PopupId

Returns the stable popup registration ID.

§Examples
assert_eq!(request.id(), PopupId::new(7));
Source

pub const fn owner(&self) -> &PopupOwner

Borrows the complete popup owner identity.

§Examples
assert_eq!(request.owner().element_id(), ElementId(9));
Source

pub const fn parent(&self) -> Option<PopupId>

Returns the optional parent popup ID.

None denotes a root popup, not an unknown parent.

§Examples
assert_eq!(request.parent(), None);
Source

pub const fn anchor(&self) -> Option<Rect>

Returns optional global logical-pixel anchor geometry.

§Examples
assert_eq!(request.with_anchor(Rect::new(1.0, 2.0, 3.0, 4.0)).anchor(), Some(Rect::new(1.0, 2.0, 3.0, 4.0)));
Source

pub const fn desired_size(&self) -> Option<Size>

Returns optional requested logical-pixel popup size.

§Examples
assert_eq!(request.with_desired_size(Size::new(20.0, 10.0)).desired_size(), Some(Size::new(20.0, 10.0)));
Source

pub const fn placement(&self) -> PopupPlacement

Returns the preferred vertical side.

§Examples
assert_eq!(request.placement(), PopupPlacement::Bottom);
Source

pub const fn alignment(&self) -> PopupAlignment

Returns cross-axis alignment.

§Examples
assert_eq!(request.alignment(), PopupAlignment::Center);
Source

pub const fn gap(&self) -> f32

Returns requested anchor gap in logical pixels.

§Examples
assert_eq!(request.gap(), 0.0);
Source

pub const fn allows_flip(&self) -> bool

Reports whether viewport resolution may flip vertical sides.

§Examples
assert!(request.allows_flip());
Source

pub const fn backend(&self) -> PopupBackend

Returns the preferred presentation backend.

§Examples
assert_eq!(request.backend(), PopupBackend::Overlay);
Source

pub const fn content(&self) -> &PopupContent<A>

Borrows the remountable content factory without invoking it.

§Examples
assert_eq!(request.content().build().key_ref(), Some("content"));
Source

pub const fn semantics(&self) -> &PopupSemantics

Borrows interaction/accessibility semantics.

§Examples
assert_eq!(request.semantics().role(), PopupRole::Generic);
Source

pub const fn mount_policy(&self) -> PopupMountPolicy

Returns retained/procedural mounting policy.

§Examples
assert_eq!(request.mount_policy(), PopupMountPolicy::RetainedOverlay);
Source

pub const fn with_parent(self, parent: PopupId) -> Self

Assigns a parent popup ID.

Registration later requires that parent to exist in the same presentation; opening later requires it to be open.

§Examples
assert_eq!(request.with_parent(PopupId::new(1)).parent(), Some(PopupId::new(1)));
Source

pub const fn with_anchor(self, anchor: Rect) -> Self

Sets global logical-pixel anchor geometry without validation.

§Examples
let anchor = Rect::new(1.0, 2.0, 3.0, 4.0);
assert_eq!(request.with_anchor(anchor).anchor(), Some(anchor));
Source

pub const fn with_desired_size(self, desired_size: Size) -> Self

Sets requested logical-pixel size without validation.

§Examples
let size = Size::new(20.0, 10.0);
assert_eq!(request.with_desired_size(size).desired_size(), Some(size));
Source

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

Replaces preferred vertical side.

§Examples
assert_eq!(request.with_placement(PopupPlacement::Top).placement(), PopupPlacement::Top);
Source

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

Replaces cross-axis alignment.

§Examples
assert_eq!(request.with_alignment(PopupAlignment::End).alignment(), PopupAlignment::End);
Source

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

Replaces logical-pixel gap without validation.

§Examples
assert_eq!(request.with_gap(4.0).gap(), 4.0);
Source

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

Enables or disables vertical-side flipping.

§Examples
assert!(!request.with_flip(false).allows_flip());
Source

pub const fn with_backend(self, backend: PopupBackend) -> Self

Replaces preferred backend; capability fallback occurs during resolution.

§Examples
assert_eq!(request.with_backend(PopupBackend::Native).backend(), PopupBackend::Native);
Source

pub fn with_semantics(self, semantics: PopupSemantics) -> Self

Replaces the complete semantic contract.

§Examples
assert_eq!(request.with_semantics(PopupSemantics::tooltip()).semantics().role(), PopupRole::Tooltip);
Source

pub const fn with_mount_policy(self, mount_policy: PopupMountPolicy) -> Self

Replaces retained/procedural mounting policy.

§Examples
assert_eq!(request.with_mount_policy(PopupMountPolicy::ProceduralFallback).mount_policy(), PopupMountPolicy::ProceduralFallback);
Source

pub fn resolve_placement( &self, viewport: Rect, capabilities: PopupBackendCapabilities, ) -> Result<ResolvedPopupPlacement, PopupPlacementError>

Resolves this request against a host viewport and its advertised popup capabilities.

Registration remains valid without geometry because declaratively open popups can be mounted before their first layout. This method reports a typed missing-field error until both anchor and desired size are known. All geometry is logical pixels. Backend selection uses capabilities; the request itself is not mutated.

§Errors

Returns MissingAnchor, then MissingDesiredSize, or a validation/ representation error from resolve_popup_placement.

§Examples
let request = request.with_anchor(Rect::new(10.0, 10.0, 5.0, 5.0)).with_desired_size(Size::new(20.0, 10.0));
let resolved = request.resolve_placement(Rect::new(0.0, 0.0, 100.0, 100.0), PopupBackendCapabilities::overlay_only())?;
assert_eq!(resolved.bounds().w, 20.0);

Trait Implementations§

Source§

impl<A> Clone for PopupRequest<A>

Clones every value and shares the content factory’s Rc.

Source§

fn clone(&self) -> Self

Produces an equivalent independent request value.

1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<A> Debug for PopupRequest<A>

Formats registration metadata while redacting the content closure.

Source§

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

Writes all request fields through their debug representations.

Auto Trait Implementations§

§

impl<A> Freeze for PopupRequest<A>

§

impl<A> !RefUnwindSafe for PopupRequest<A>

§

impl<A> !Send for PopupRequest<A>

§

impl<A> !Sync for PopupRequest<A>

§

impl<A> Unpin for PopupRequest<A>

§

impl<A> !UnwindSafe for PopupRequest<A>

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,