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/// Retained scene node stored contiguously inside `SceneTree`.
38#[derive(CustomDebug, Data)]
39pub struct SceneNode {
40 /// Generation tag matching live `NodeId` handles.
41 #[get(type(copy))]
42 #[get_mut(pub(crate))]
43 #[set(pub(crate))]
44 pub(crate) generation: u32,
45 /// Whether this arena slot is currently occupied.
46 #[get(type(copy))]
47 #[get_mut(pub(crate))]
48 #[set(pub(crate))]
49 pub(crate) alive: bool,
50 /// Semantic kind and node-specific payload.
51 pub(crate) kind: NodeKind,
52 /// Compiled layout, paint, and typography style.
53 #[get(type(copy))]
54 pub(crate) style: Style,
55 /// Optional hover paint override for zero-layout-cost hover feedback.
56 #[get(skip)]
57 pub(crate) hover_style: Option<PaintStyle>,
58 /// Computed layout box and scroll offsets.
59 #[get(type(copy))]
60 pub(crate) layout_box: LayoutBox,
61 /// Cached previous layout constraints for clean-subtree O(1) skipping.
62 #[get(skip)]
63 #[get_mut(pub(crate))]
64 #[set(pub(crate))]
65 pub(crate) last_constraint: Option<AvailableSpace>,
66 /// Surgical dirty bitmask.
67 #[get(type(copy))]
68 pub(crate) dirty: DirtyFlags,
69 /// Parent node handle if attached to the tree.
70 #[get(skip)]
71 pub(crate) parent: Option<NodeId>,
72 /// Ordered child node handles.
73 pub(crate) children: Vec<NodeId>,
74 /// Optional reconciliation key for keyed list items.
75 #[get(skip)]
76 pub(crate) key: Option<String>,
77 /// Interactive focus/hover/pressed state.
78 #[get(type(copy))]
79 pub(crate) interaction: InteractionState,
80 /// Event callbacks attached to this node.
81 pub(crate) handlers: EventHandlers,
82 /// Optional reactive ownership scope disposed when this node is removed.
83 #[get(skip)]
84 pub(crate) scope: Option<Scope>,
85 /// Optional custom 2D canvas draw callback.
86 #[debug(skip)]
87 #[get(skip)]
88 pub(crate) canvas_painter: Option<CanvasDrawCallback>,
89 /// Optional explicit semantic accessibility metadata for screen readers and ARIA bridges.
90 #[get(skip)]
91 pub(crate) a11y: Option<A11yProps>,
92 /// Optional virtualized scroll metrics `(scroll_y, total_content_height)` for overlay scrollbar thumb accuracy.
93 #[get(skip)]
94 pub(crate) virtual_scroll: Option<(f32, f32)>,
95 /// Registered `Lifecycle` observers receiving mount, activate, freeze, resume, unmount, and destroy hooks.
96 #[debug(skip)]
97 #[get(skip)]
98 pub(crate) lifecycles: Vec<Rc<dyn Lifecycle>>,
99}