Skip to main content

OverlayManagerInner

Struct OverlayManagerInner 

Source
pub struct OverlayManagerInner { /* private fields */ }
Expand description

Inner state of the overlay manager

Implementations§

Source§

impl OverlayManagerInner

Source

pub fn new() -> Self

Create a new overlay manager

Source

pub fn set_viewport(&mut self, width: f32, height: f32)

Update viewport dimensions (in logical pixels)

Source

pub fn set_viewport_with_scale( &mut self, width: f32, height: f32, scale_factor: f32, )

Update viewport dimensions with scale factor

Source

pub fn scale_factor(&self) -> f32

Get the current scale factor

Source

pub fn set_toast_corner(&mut self, corner: Corner)

Set toast corner preference

Source

pub fn take_dirty(&self) -> bool

Check and clear dirty flag (content changed, needs full rebuild)

Source

pub fn is_dirty(&self) -> bool

Check dirty flag without clearing (for peeking before render)

Source

pub fn take_animation_dirty(&self) -> bool

Check and clear animation dirty flag (just needs re-render, no content rebuild)

Source

pub fn needs_redraw(&self) -> bool

Check if needs any kind of redraw (content or animation)

Source

pub fn add( &mut self, config: OverlayConfig, content: impl Fn() -> Div + Send + Sync + 'static, ) -> OverlayHandle

Add a new overlay

Source

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.)

Source

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
Source

pub fn close(&mut self, handle: OverlayHandle)

Close an overlay by handle

Source

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.

Source

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.

Source

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.

Source

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.

Source

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)
Source

pub fn is_closing(&self, handle: OverlayHandle) -> bool

Check if overlay is in closing state (exit animation playing)

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn close_top(&mut self)

Close the topmost overlay

Source

pub fn close_all_of(&mut self, kind: OverlayKind)

Close all overlays of a specific kind

Source

pub fn close_all(&mut self)

Close all overlays

Source

pub fn cleanup(&mut self)

Remove closed overlays

Source

pub fn handle_escape(&mut self) -> bool

Handle escape key - close topmost dismissable overlay

Source

pub fn has_blocking_overlay(&self) -> bool

Check if any modal is blocking interaction

Source

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.

Source

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.

Source

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 coordinate
  • y - Logical y coordinate
§Returns

True if the click is on a backdrop (outside content), false if on content or no overlay

Source

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.

Source

pub fn overlays_sorted(&self) -> Vec<&ActiveOverlay>

Get overlays sorted by z-priority

Source

pub fn has_visible_overlays(&self) -> bool

Check if there are any visible overlays

Source

pub fn has_animating_overlays(&self) -> bool

Check if any overlay is currently animating (entering or exiting)

Source

pub fn overlay_count(&self) -> usize

Get the number of overlays

Source

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

Source

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.

Source

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.

Source

pub fn layout_toasts(&self) -> Vec<(OverlayHandle, f32, f32)>

Layout toasts in a stack

Trait Implementations§

Source§

impl Default for OverlayManagerInner

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> NodeState for T
where T: Send + 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Get self as Any for downcasting
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Get self as mutable Any for downcasting
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more