Skip to main content

place_anchored

Function place_anchored 

pub fn place_anchored(
    anchor: Rect,
    size: (f64, f64),
    side: PopoverSide,
    gap: f64,
    viewport: Rect,
) -> (Rect, PopoverSide)
Expand description

Where a floating Panel of size goes against anchor (the control that opened it, or a zero-size pointer position) inside viewport: on side of the anchor, gap away, its leading edge on the anchor’s leading edge. It flips to the other side when side has no room and the other side has more, flips its alignment to the anchor’s trailing edge when it would run past the viewport’s trailing edge, and then shifts along the anchor into the viewport. Returns the panel and the side it opened on.

Every anchored floating Panel (context menus, popovers, dropdown lists) places itself through here, so a menu always opens at its trigger.