Skip to main content

fret_ui/tree/layers/
types.rs

1use super::super::*;
2
3slotmap::new_key_type! {
4    pub struct UiLayerId;
5}
6
7/// Stable mechanism contract for installing an overlay root into a window-scoped [`UiTree`].
8///
9/// The runtime only owns the layer/root substrate. Higher-level overlay policy stays in
10/// `ecosystem/*` and can refine the layer after installation (for example by changing focus or
11/// pointer-occlusion behavior).
12#[derive(Debug, Clone, Copy, PartialEq, Eq)]
13pub struct OverlayRootOptions {
14    /// Whether this layer blocks input to underlay roots when visible.
15    ///
16    /// On install, this also seeds `blocks_underlay_focus` to the same value. Policy code can
17    /// diverge the focus barrier later via `UiTree::set_layer_blocks_underlay_focus(...)`.
18    pub blocks_underlay_input: bool,
19    /// Whether this layer participates in hit testing inside its own subtree.
20    pub hit_testable: bool,
21}
22
23impl OverlayRootOptions {
24    pub const fn new(blocks_underlay_input: bool) -> Self {
25        Self {
26            blocks_underlay_input,
27            hit_testable: true,
28        }
29    }
30}
31
32impl Default for OverlayRootOptions {
33    fn default() -> Self {
34        Self::new(false)
35    }
36}
37
38#[derive(Debug, Clone)]
39pub(in crate::tree) struct UiLayer {
40    pub(in crate::tree) root: NodeId,
41    pub(in crate::tree) visible: bool,
42    pub(in crate::tree) blocks_underlay_input: bool,
43    pub(in crate::tree) blocks_underlay_focus: bool,
44    pub(in crate::tree) hit_testable: bool,
45    pub(in crate::tree) pointer_occlusion: PointerOcclusion,
46    pub(in crate::tree) wants_pointer_down_outside_events: bool,
47    pub(in crate::tree) consume_pointer_down_outside_events: bool,
48    pub(in crate::tree) pointer_down_outside_branches: Vec<NodeId>,
49    /// Elements that should cause this overlay to dismiss when they are inside the scroll-event
50    /// target (Radix Tooltip "close on scroll" outcome).
51    pub(in crate::tree) scroll_dismiss_elements: Vec<crate::GlobalElementId>,
52    pub(in crate::tree) wants_pointer_move_events: bool,
53    pub(in crate::tree) wants_timer_events: bool,
54}