Expand description
Top-level overlay / Popup primitive.
Compose parity with androidx.compose.ui.window.Popup: content composed
inside a Popup renders in a top-level overlay that draws above all
normal content and is not clipped by the bounds of the ancestor the
call site sits under. This is what lets a text field’s selection handles
hang below the last line, and a contextual menu float above a selection,
without being cut off by a scrolling parent’s clip rectangle.
§How it works
Composition is single-rooted and both paint order and hit-test order are
derived purely from tree position (later sibling = on top, and a node is
only clipped by an ancestor that opted into clip_to_bounds). Therefore the
only way for content to draw above everything and escape any ancestor
clip is to be composed as a last-order sibling directly under an unclipped
root. PopupHost provides exactly that root: it wraps the whole app in an
unclipped, viewport-filling [Box] and renders every registered popup as a
trailing child, positioned absolutely at its anchor.
Popup itself emits no node at its call site. Instead it registers
its (position, content) into a PopupRegistry carried down the tree by
a [CompositionLocal]; the enclosing PopupHost reads that registry and
composes the content at the root. Registration/teardown is reactive:
adding, removing, or moving a popup invalidates the host so it recomposes.
Structs§
- Popup
Registry - Shared, cheaply-cloneable handle to the popup registry provided by the
nearest
PopupHost.
Functions§
- Popup
- Composes
contentin the top-level overlay layer, positioned atanchorshifted byoffset(logical px, window coordinates). - Popup
Dismissable - A
Popupwith an outside-tap dismissal: the host renders a viewport-filling scrim beneath the content that callson_dismiss— the analogue of Compose’sPopup(onDismissRequest = …). Menus and pickers use this; anchored chrome like selection handles uses plainPopup. - Popup
Dismissable When - A dismissable popup whose modal scrim can be disabled without unmounting its visual content. Controls with an exit animation use this to stop intercepting the rest of the UI as soon as dismissal begins while their popup surface finishes animating out.
- Popup
Host - Installs the top-level overlay layer and composes
contentbeneath it. - local_
popup_ viewport - The
PopupHost’s live measured viewport size (logical px), published on every measure pass through a shared cell. Overlay content (selection menus, the loupe) reads it to clamp itself to the window edges;Size::ZEROmeans “not measured yet” (or no host) — treat as unclamped.