pub fn position_popup(
anchor: Rect,
desired_size: Size,
placement: PopupPlacement,
alignment: PopupAlignment,
gap: f32,
) -> Result<Rect, PopupPlacementError>Expand description
Positions a popup relative to an anchor without viewport flip or clamp.
Procedural overlays use this primitive before their window viewport is
available. Once a viewport is known, prefer resolve_popup_placement.
All geometry is global logical pixels. Center alignment may produce negative
coordinates; no clipping occurs here.
§Errors
Returns typed validation errors or UnrepresentableGeometry on arithmetic
overflow to non-finite edges.
§Examples
use ailloli_ui_core::{Rect, Size}; use ailloli_ui_runtime::popup::*;
let bounds = position_popup(Rect::new(10.0, 20.0, 20.0, 5.0), Size::new(10.0, 4.0), PopupPlacement::Bottom, PopupAlignment::Center, 2.0)?;
assert_eq!(bounds, Rect::new(15.0, 27.0, 10.0, 4.0));