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.
impl PopupPlacementSpec
Builder and accessor operations for semantic placement input.
Sourcepub const fn new(anchor: Rect, desired_size: Size) -> Self
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));Sourcepub const fn anchor(self) -> Rect
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);Sourcepub const fn desired_size(self) -> Size
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);Sourcepub const fn placement(self) -> PopupPlacement
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);Sourcepub const fn alignment(self) -> PopupAlignment
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);Sourcepub const fn gap(self) -> f32
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);Sourcepub const fn allows_flip(self) -> bool
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());Sourcepub const fn with_placement(self, placement: PopupPlacement) -> Self
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);Sourcepub const fn with_alignment(self, alignment: PopupAlignment) -> Self
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);Sourcepub const fn with_gap(self, gap: f32) -> Self
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);Sourcepub const fn with_flip(self, allow_flip: bool) -> Self
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
impl Clone for PopupPlacementSpec
Source§fn clone(&self) -> PopupPlacementSpec
fn clone(&self) -> PopupPlacementSpec
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PopupPlacementSpec
impl Debug for PopupPlacementSpec
Source§impl PartialEq for PopupPlacementSpec
impl PartialEq for PopupPlacementSpec
impl Copy for PopupPlacementSpec
impl StructuralPartialEq for PopupPlacementSpec
Auto Trait Implementations§
impl Freeze for PopupPlacementSpec
impl RefUnwindSafe for PopupPlacementSpec
impl Send for PopupPlacementSpec
impl Sync for PopupPlacementSpec
impl Unpin for PopupPlacementSpec
impl UnwindSafe for PopupPlacementSpec
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.