euv_core/scene/node/struct.rs
1use super::*;
2
3/// Computed layout geometry cached on every scene node.
4#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
5pub struct LayoutBox {
6 /// Absolute border-box bounds in root logical coordinates.
7 #[get(type(copy))]
8 pub(crate) bounds: Rect,
9 /// Inner content-box bounds inside padding and border.
10 #[get(type(copy))]
11 pub(crate) content_bounds: Rect,
12 /// Intrinsic scrollable content size.
13 #[get(type(copy))]
14 pub(crate) content_size: Size,
15 /// Active scroll offset inside scroll containers.
16 #[get(type(copy))]
17 pub(crate) scroll_offset: Point,
18}
19
20/// Interactive visual state flags on a scene node.
21#[derive(Clone, Copy, Data, Debug, Default, Eq, Hash, New, PartialEq)]
22pub struct InteractionState {
23 /// Whether the node can receive keyboard focus.
24 #[get(type(copy))]
25 pub(crate) focusable: bool,
26 /// Whether the node currently holds keyboard focus.
27 #[get(type(copy))]
28 pub(crate) focused: bool,
29 /// Whether a pointer currently hovers over this node.
30 #[get(type(copy))]
31 pub(crate) hovered: bool,
32 /// Whether a pointer is actively pressed on this node.
33 #[get(type(copy))]
34 pub(crate) pressed: bool,
35}
36
37/// Lazily allocated cold optional metadata boxed out of `SceneNode` to keep the hot node arena compact.
38#[derive(CustomDebug, Data, Default)]
39pub(crate) struct NodeExtras {
40 /// Optional hover paint override for zero-layout-cost hover feedback.
41 #[get(skip)]
42 pub(crate) hover_style: Option<PaintStyle>,
43 /// Optional reconciliation key for keyed list items.
44 #[get(skip)]
45 pub(crate) key: Option<String>,
46 /// Event callbacks attached to this node.
47 pub(crate) handlers: EventHandlers,
48 /// Optional reactive ownership scope disposed when this node is removed.
49 #[get(skip)]
50 pub(crate) scope: Option<Scope>,
51 /// Optional custom 2D canvas draw callback.
52 #[debug(skip)]
53 #[get(skip)]
54 pub(crate) canvas_painter: Option<CanvasDrawCallback>,
55 /// Optional explicit semantic accessibility metadata for screen readers and ARIA bridges.
56 #[get(skip)]
57 pub(crate) a11y: Option<A11yProps>,
58 /// Optional virtualized scroll metrics `(scroll_y, total_content_height)` for overlay scrollbar thumb accuracy.
59 #[get(skip)]
60 pub(crate) virtual_scroll: Option<(f32, f32)>,
61 /// Registered `Lifecycle` observers receiving mount, activate, freeze, resume, unmount, and destroy hooks.
62 #[debug(skip)]
63 #[get(skip)]
64 pub(crate) lifecycles: Vec<Rc<dyn Lifecycle>>,
65}
66
67/// Retained scene node stored contiguously inside `SceneTree`.
68#[derive(CustomDebug, Data)]
69pub struct SceneNode {
70 /// Generation tag matching live `NodeId` handles.
71 #[get(type(copy))]
72 #[get_mut(pub(crate))]
73 #[set(pub(crate))]
74 pub(crate) generation: u32,
75 /// Whether this arena slot is currently occupied.
76 #[get(type(copy))]
77 #[get_mut(pub(crate))]
78 #[set(pub(crate))]
79 pub(crate) alive: bool,
80 /// Semantic kind and node-specific payload.
81 pub(crate) kind: NodeKind,
82 /// Compiled layout, paint, and typography style.
83 #[get(type(copy))]
84 pub(crate) style: Style,
85 /// Computed layout box and scroll offsets.
86 #[get(type(copy))]
87 pub(crate) layout_box: LayoutBox,
88 /// Cached previous layout constraints for clean-subtree O(1) skipping.
89 #[get(skip)]
90 #[get_mut(pub(crate))]
91 #[set(pub(crate))]
92 pub(crate) last_constraint: Option<AvailableSpace>,
93 /// Surgical dirty bitmask.
94 #[get(type(copy))]
95 pub(crate) dirty: DirtyFlags,
96 /// Parent node handle if attached to the tree.
97 #[get(skip)]
98 pub(crate) parent: Option<NodeId>,
99 /// Ordered child node handles.
100 pub(crate) children: Vec<NodeId>,
101 /// Interactive focus/hover/pressed state.
102 #[get(type(copy))]
103 pub(crate) interaction: InteractionState,
104 /// Lazily boxed cold optional metadata (handlers, hover style, a11y, lifecycles, scope, canvas, key, virtual scroll).
105 #[debug(skip)]
106 #[get(skip)]
107 #[get_mut(skip)]
108 #[set(skip)]
109 pub(crate) extras: Option<Box<NodeExtras>>,
110}