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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
//! Global overlay context singleton
//!
//! OverlayContext provides a global singleton for accessing the overlay manager
//! without requiring explicit context parameters.
//!
//! This enables components like Select to create dropdowns via overlay:
//!
//! ```ignore
//! use blinc_layout::overlay_state::get_overlay_manager;
//!
//! // In a component:
//! let mgr = get_overlay_manager();
//! mgr.dropdown()
//! .at(x, y)
//! .content(|| dropdown_content)
//! .show();
//! ```
//!
//! # Initialization
//!
//! The singleton must be initialized by the app layer before use:
//!
//! ```ignore
//! // In WindowedApp::run()
//! OverlayContext::init(overlay_manager);
//! ```
use Cell;
use OnceLock;
use crateOverlayManager;
/// Global overlay context instance
static OVERLAY_CONTEXT: = new;
// Thread-local flag indicating if we're currently rendering closing overlay content
//
// DEPRECATED: This mechanism is being replaced by explicit `MotionHandle.exit()` calls.
// Motion exit should be triggered explicitly via `query_motion(key).exit()` instead of
// relying on this flag captured at construction time.
thread_local!
/// Check if we're currently rendering overlay content that is closing
///
/// DEPRECATED: Use `query_motion(key).exit()` to explicitly trigger motion exit instead.
/// This flag-based mechanism doesn't work correctly because the flag resets after
/// `build_content()` returns, breaking multi-frame exit animations.
/// Set the overlay closing flag (call before/after building closing overlay content)
///
/// DEPRECATED: Use `query_motion(key).exit()` to explicitly trigger motion exit instead.
/// This flag-based mechanism doesn't work correctly because the flag resets after
/// `build_content()` returns, breaking multi-frame exit animations.
/// Global overlay context singleton
///
/// Provides access to the overlay manager without requiring explicit context parameters.
/// Named `OverlayContext` to avoid conflict with `OverlayState` FSM enum.
// =========================================================================
// Convenience Free Functions
// =========================================================================
/// Get the global overlay manager
///
/// This is a convenience wrapper around `OverlayContext::get().overlay_manager()`.
///
/// # Panics
///
/// Panics if `OverlayContext::init()` has not been called.
///
/// # Example
///
/// ```ignore
/// use blinc_layout::overlay_state::get_overlay_manager;
///
/// let mgr = get_overlay_manager();
/// mgr.dropdown()
/// .at(x, y)
/// .content(|| dropdown_content)
/// .show();
/// ```