pub struct OverlayManagerInner { /* private fields */ }Expand description
Inner state of the overlay manager
Implementations§
Source§impl OverlayManagerInner
impl OverlayManagerInner
Sourcepub fn set_viewport(&mut self, width: f32, height: f32)
pub fn set_viewport(&mut self, width: f32, height: f32)
Update viewport dimensions (in logical pixels)
Sourcepub fn set_viewport_with_scale(
&mut self,
width: f32,
height: f32,
scale_factor: f32,
)
pub fn set_viewport_with_scale( &mut self, width: f32, height: f32, scale_factor: f32, )
Update viewport dimensions with scale factor
Sourcepub fn scale_factor(&self) -> f32
pub fn scale_factor(&self) -> f32
Get the current scale factor
Sourcepub fn set_toast_corner(&mut self, corner: Corner)
pub fn set_toast_corner(&mut self, corner: Corner)
Set toast corner preference
Sourcepub fn take_dirty(&self) -> bool
pub fn take_dirty(&self) -> bool
Check and clear dirty flag (content changed, needs full rebuild)
Sourcepub fn take_animation_dirty(&self) -> bool
pub fn take_animation_dirty(&self) -> bool
Check and clear animation dirty flag (just needs re-render, no content rebuild)
Sourcepub fn needs_redraw(&self) -> bool
pub fn needs_redraw(&self) -> bool
Check if needs any kind of redraw (content or animation)
Sourcepub fn add(
&mut self,
config: OverlayConfig,
content: impl Fn() -> Div + Send + Sync + 'static,
) -> OverlayHandle
pub fn add( &mut self, config: OverlayConfig, content: impl Fn() -> Div + Send + Sync + 'static, ) -> OverlayHandle
Add a new overlay
Sourcepub fn add_with_close_callback(
&mut self,
config: OverlayConfig,
content: impl Fn() -> Div + Send + Sync + 'static,
on_close: Option<OnCloseCallback>,
) -> OverlayHandle
pub fn add_with_close_callback( &mut self, config: OverlayConfig, content: impl Fn() -> Div + Send + Sync + 'static, on_close: Option<OnCloseCallback>, ) -> OverlayHandle
Add a new overlay with a close callback
The callback is invoked when the overlay is dismissed (backdrop click, escape, etc.)
Sourcepub fn update(&mut self, current_time_ms: u64)
pub fn update(&mut self, current_time_ms: u64)
Update overlay states - call this every frame
This handles:
- Transitioning Opening -> Open after enter animation completes
- Transitioning Closing -> Closed after exit animation completes
- Auto-dismissing toasts after their duration expires
- Removing closed overlays
Sourcepub fn close(&mut self, handle: OverlayHandle)
pub fn close(&mut self, handle: OverlayHandle)
Close an overlay by handle
Sourcepub fn close_immediate(&mut self, handle: OverlayHandle)
pub fn close_immediate(&mut self, handle: OverlayHandle)
Close an overlay immediately, skipping any exit animation
This directly sets the overlay to Closed state so it will be removed on the next update cycle. Use this when you need to ensure an overlay is gone before opening a replacement.
Sourcepub fn cancel_close(&mut self, handle: OverlayHandle)
pub fn cancel_close(&mut self, handle: OverlayHandle)
Cancel a pending close and return overlay to Open state
Used when mouse re-enters a hover card during exit animation. This interrupts the exit animation and keeps the overlay visible.
Sourcepub fn hover_leave(&mut self, handle: OverlayHandle)
pub fn hover_leave(&mut self, handle: OverlayHandle)
Trigger hover leave event - starts close delay countdown
For overlays with close_delay_ms configured (like hover cards),
this transitions to PendingClose state. The overlay will close
after the delay unless hover_enter is called.
Sourcepub fn hover_enter(&mut self, handle: OverlayHandle)
pub fn hover_enter(&mut self, handle: OverlayHandle)
Trigger hover enter event - cancels close delay countdown
If overlay is in PendingClose state, this cancels the delay and returns to Open state.
Sourcepub fn is_pending_close(&self, handle: OverlayHandle) -> bool
pub fn is_pending_close(&self, handle: OverlayHandle) -> bool
Check if an overlay is in PendingClose state or has queued close
Returns true if:
- Overlay is in PendingClose state (waiting for close delay), OR
- Overlay is in Opening state with pending_close_on_open flag set (close will happen as soon as opening animation completes)
Sourcepub fn is_closing(&self, handle: OverlayHandle) -> bool
pub fn is_closing(&self, handle: OverlayHandle) -> bool
Check if overlay is in closing state (exit animation playing)
Sourcepub fn set_content_size(
&mut self,
handle: OverlayHandle,
width: f32,
height: f32,
)
pub fn set_content_size( &mut self, handle: OverlayHandle, width: f32, height: f32, )
Set the cached content size for an overlay (for hit testing)
This is typically called from an on_ready callback after the overlay
content has been laid out, providing accurate size for backdrop click detection.
Sourcepub fn handle_scroll(&mut self, delta_y: f32) -> bool
pub fn handle_scroll(&mut self, delta_y: f32) -> bool
Update positions of overlays that follow scroll
This is called from the scroll handler to update positions of overlays
with follows_scroll: true. The delta is subtracted from the y position
since scrolling down means content moves up.
Returns true if any overlay positions were updated.
Sourcepub fn get_scroll_offsets(&self) -> Vec<(String, f32)>
pub fn get_scroll_offsets(&self) -> Vec<(String, f32)>
Get scroll offsets for all visible overlays with follows_scroll enabled
Returns a list of (element_id, offset_y) pairs for rendering. The element_id is the unique wrapper ID for each overlay’s content.
Sourcepub fn get_visible_overlay_bounds(&self) -> Vec<(f32, f32, f32, f32)>
pub fn get_visible_overlay_bounds(&self) -> Vec<(f32, f32, f32, f32)>
Get bounds of all visible overlays for occlusion testing
Returns a list of (x, y, width, height) rectangles for all visible overlay content. This can be used to determine if a hit test point is within an overlay’s bounds, which helps block hover events on UI elements underneath overlays.
Note: Uses default size (300x200) for overlays without cached size.
Sourcepub fn close_all_of(&mut self, kind: OverlayKind)
pub fn close_all_of(&mut self, kind: OverlayKind)
Close all overlays of a specific kind
Sourcepub fn handle_escape(&mut self) -> bool
pub fn handle_escape(&mut self) -> bool
Handle escape key - close topmost dismissable overlay
Sourcepub fn has_blocking_overlay(&self) -> bool
pub fn has_blocking_overlay(&self) -> bool
Check if any modal is blocking interaction
Sourcepub fn has_dismissable_overlay(&self) -> bool
pub fn has_dismissable_overlay(&self) -> bool
Check if any overlay with dismiss-on-click-outside behavior is visible
This includes dropdowns, context menus, popovers, and other overlays that should be dismissed when clicking outside.
Sourcepub fn handle_backdrop_click(&mut self) -> bool
pub fn handle_backdrop_click(&mut self) -> bool
Handle backdrop click - close topmost overlay if it has dismiss-on-click behavior
Returns true if a click was handled (overlay closed), false otherwise. The caller should call this when a mouse click is detected and there’s a blocking overlay.
Sourcepub fn is_backdrop_click(&self, x: f32, y: f32) -> bool
pub fn is_backdrop_click(&self, x: f32, y: f32) -> bool
Check if a click at the given position should dismiss an overlay
This checks if the click is outside the content bounds of any open overlay with backdrop dismiss enabled. Uses cached content sizes for hit testing.
§Arguments
x- Logical x coordinatey- Logical y coordinate
§Returns
True if the click is on a backdrop (outside content), false if on content or no overlay
Sourcepub fn handle_click_at(&mut self, x: f32, y: f32) -> bool
pub fn handle_click_at(&mut self, x: f32, y: f32) -> bool
Handle click at position - dismisses if on backdrop
Convenience method that combines is_backdrop_click and handle_backdrop_click.
Sourcepub fn overlays_sorted(&self) -> Vec<&ActiveOverlay>
pub fn overlays_sorted(&self) -> Vec<&ActiveOverlay>
Get overlays sorted by z-priority
Sourcepub fn has_visible_overlays(&self) -> bool
pub fn has_visible_overlays(&self) -> bool
Check if there are any visible overlays
Sourcepub fn has_animating_overlays(&self) -> bool
pub fn has_animating_overlays(&self) -> bool
Check if any overlay is currently animating (entering or exiting)
Sourcepub fn overlay_count(&self) -> usize
pub fn overlay_count(&self) -> usize
Get the number of overlays
Sourcepub fn build_overlay_tree(&self) -> Option<RenderTree>
pub fn build_overlay_tree(&self) -> Option<RenderTree>
Build the overlay render tree (DEPRECATED - use build_overlay_layer instead)
This method creates a separate RenderTree for overlays. Prefer using
build_overlay_layer() which returns a Div that can be composed into
the main UI tree for unified event routing and incremental updates.
Source§impl OverlayManagerInner
impl OverlayManagerInner
Sourcepub fn build_overlay_layer(&self) -> Div
pub fn build_overlay_layer(&self) -> Div
Build the overlay layer container for the main UI tree
This ALWAYS returns a Div container with a stable ID, even when empty. This enables subtree rebuilds to update overlay content without triggering a full UI rebuild.
The container uses absolute positioning so it doesn’t affect main UI layout. When empty (no visible overlays), the container has zero size so it doesn’t block events to the UI below.
Sourcepub fn build_overlay_content(&self) -> Div
pub fn build_overlay_content(&self) -> Div
Build overlay layer content for subtree rebuild
This is called when overlay content changes to queue a subtree rebuild instead of triggering a full UI rebuild.
Sourcepub fn layout_toasts(&self) -> Vec<(OverlayHandle, f32, f32)>
pub fn layout_toasts(&self) -> Vec<(OverlayHandle, f32, f32)>
Layout toasts in a stack