pub enum OverlayAnchor {
Owner,
Rect(Rect),
Window {
point: Point,
offset: Vec2,
},
}Expand description
What a slot places its surface against.
Owner and Rect resolve to a window-space rect in the owner’s
paint, where the owner’s absolute origin is finally known; nothing is
subscribed to and nothing is cached across frames, so an anchor follows
its owner across scroll, relayout and animation for free. Window is
already window-space and skips that resolution entirely — see its own
docs for why it is updated from event instead.
Variants§
Owner
The owner’s own bounds — a trigger floating a menu under itself.
Rect(Rect)
A rect in the owner’s local space: a caret, a selection’s bounding
box, a press point, one row of a list. Translated by the owner’s paint
origin, so a caller states it in the same coordinates its layout and
event already speak.
Window
An absolute window-space point the surface’s top-left tracks directly — a drag ghost following the pointer rather than an owner’s bounds.
The placed rect is always point + offset, sized to the pod’s own
content size: no side, alignment or collision flip applies, because
there is no anchor rect to place against, only a point — so none of
OverlayPlacement’s side/align/flip/clamp fields apply to it either
(place is never called for this variant). The rect is clamped into
the window area when OverlaySlot::set_clamp_to_window has turned
that on (default false, so the ghost may trail off the window’s edge
with the pointer).
Set once (with whatever offset the gesture’s grab point needs) via
OverlaySlot::set_anchor, then updated every pointer Move/Down
with OverlaySlot::set_window_anchor, which keeps offset and only
moves point — see that method for why the update belongs in the
owner’s event rather than waiting for the next paint.