-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdoc.go
More file actions
51 lines (51 loc) · 1.71 KB
/
Copy pathdoc.go
File metadata and controls
51 lines (51 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Package overlay provides an overlay stack for displaying floating content
// above the normal widget tree.
//
// Overlays are used by dropdowns, popovers, tooltips, dialogs, and any
// widget that needs to float above the main UI. The package manages their
// lifecycle, event dispatch, and draw order.
//
// # Stack
//
// The core abstraction is [Stack], owned by the [app.Window], which manages
// a last-in-first-out collection of [Overlay] widgets. Events are dispatched
// to the top overlay before reaching the regular widget tree, and overlays
// are drawn after (on top of) the regular tree.
//
// stack := overlay.NewStack(func() { requestRedraw() })
// stack.Push(myOverlay)
// stack.Pop()
//
// # Container
//
// [Container] is a ready-made [Overlay] implementation that wraps content
// with a full-window transparent backdrop. Clicks on the backdrop (outside
// the content) trigger dismissal. For modal overlays, a semi-transparent
// scrim is drawn behind the content:
//
// c := overlay.NewContainer(menuWidget, windowSize,
// overlay.WithOnDismiss(func() { closeMenu() }),
// overlay.WithModal(true),
// )
//
// # Positioning
//
// The [Position] helper calculates where an overlay should appear relative
// to an anchor widget, with automatic viewport clamping to keep the overlay
// on screen:
//
// pos := overlay.Position(
// overlay.PlacementBelow,
// anchorBounds,
// overlaySize,
// windowSize,
// 4, // gap
// )
//
// # Integration
//
// Widgets push overlays via the [widget.OverlayManager] interface obtained
// from [widget.Context], and never import the overlay package directly.
// This avoids circular dependencies between widget packages and the overlay
// infrastructure.
package overlay