Skip to main content

anchored_popup_origin

Function anchored_popup_origin 

Source
pub fn anchored_popup_origin(
    anchor_pos: Vec2,
    anchor_size: Vec2,
    popup: Vec2,
    viewport: Vec2,
    gap: f32,
    side: PopupSide,
) -> Vec2
Expand description

Viewport-space top-left for a popup-sized box anchored to a trigger rect (anchor_pos / anchor_size), preferring side and flipping to the opposite side of the viewport when the preferred placement would overflow. gap px separate the popup from the anchor on the primary axis; the cross axis aligns to the anchor’s leading edge and also flips inward when it would overflow.

Generalises the edge-flip tooltip::spawn_tooltip_popups performs so dropdown and menu panels can share one anchoring rule (Qt’s QToolTip / Adwaita popover contract).