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.
impl<A> PopupRequest<A>
Construction, immutable access, builders, and placement resolution.
Sourcepub fn new(id: PopupId, owner: PopupOwner, content: PopupContent<A>) -> Self
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));Sourcepub const fn owner(&self) -> &PopupOwner
pub const fn owner(&self) -> &PopupOwner
Borrows the complete popup owner identity.
§Examples
assert_eq!(request.owner().element_id(), ElementId(9));Sourcepub const fn parent(&self) -> Option<PopupId>
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);Sourcepub const fn anchor(&self) -> Option<Rect>
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)));Sourcepub const fn desired_size(&self) -> Option<Size>
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)));Sourcepub const fn placement(&self) -> PopupPlacement
pub const fn placement(&self) -> PopupPlacement
Returns the preferred vertical side.
§Examples
assert_eq!(request.placement(), PopupPlacement::Bottom);Sourcepub const fn alignment(&self) -> PopupAlignment
pub const fn alignment(&self) -> PopupAlignment
Sourcepub const fn allows_flip(&self) -> bool
pub const fn allows_flip(&self) -> bool
Reports whether viewport resolution may flip vertical sides.
§Examples
assert!(request.allows_flip());Sourcepub const fn backend(&self) -> PopupBackend
pub const fn backend(&self) -> PopupBackend
Returns the preferred presentation backend.
§Examples
assert_eq!(request.backend(), PopupBackend::Overlay);Sourcepub const fn content(&self) -> &PopupContent<A>
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"));Sourcepub const fn semantics(&self) -> &PopupSemantics
pub const fn semantics(&self) -> &PopupSemantics
Borrows interaction/accessibility semantics.
§Examples
assert_eq!(request.semantics().role(), PopupRole::Generic);Sourcepub const fn mount_policy(&self) -> PopupMountPolicy
pub const fn mount_policy(&self) -> PopupMountPolicy
Returns retained/procedural mounting policy.
§Examples
assert_eq!(request.mount_policy(), PopupMountPolicy::RetainedOverlay);Sourcepub const fn with_parent(self, parent: PopupId) -> Self
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)));Sourcepub const fn with_anchor(self, anchor: Rect) -> Self
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));Sourcepub const fn with_desired_size(self, desired_size: Size) -> Self
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));Sourcepub const fn with_placement(self, placement: PopupPlacement) -> Self
pub const fn with_placement(self, placement: PopupPlacement) -> Self
Replaces preferred vertical side.
§Examples
assert_eq!(request.with_placement(PopupPlacement::Top).placement(), PopupPlacement::Top);Sourcepub const fn with_alignment(self, alignment: PopupAlignment) -> Self
pub const fn with_alignment(self, alignment: PopupAlignment) -> Self
Replaces cross-axis alignment.
§Examples
assert_eq!(request.with_alignment(PopupAlignment::End).alignment(), PopupAlignment::End);Sourcepub const fn with_gap(self, gap: f32) -> Self
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);Sourcepub const fn with_flip(self, allow_flip: bool) -> Self
pub const fn with_flip(self, allow_flip: bool) -> Self
Enables or disables vertical-side flipping.
§Examples
assert!(!request.with_flip(false).allows_flip());Sourcepub const fn with_backend(self, backend: PopupBackend) -> Self
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);Sourcepub fn with_semantics(self, semantics: PopupSemantics) -> Self
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);Sourcepub const fn with_mount_policy(self, mount_policy: PopupMountPolicy) -> Self
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);Sourcepub fn resolve_placement(
&self,
viewport: Rect,
capabilities: PopupBackendCapabilities,
) -> Result<ResolvedPopupPlacement, PopupPlacementError>
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.
impl<A> Clone for PopupRequest<A>
Clones every value and shares the content factory’s Rc.
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> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
Source§fn into_click_action(self) -> ClickAction<A>
fn into_click_action(self) -> ClickAction<A>
Implements the into_click_action helper used by this module.