Skip to main content

euv_core/scene/event/
struct.rs

1use super::*;
2
3/// Dispatched UI event envelope carrying target node and event payload.
4#[derive(Clone, Data, Debug, New, PartialEq)]
5pub struct UiEvent {
6    /// Scene node receiving this event.
7    #[get(type(copy))]
8    pub(crate) target: NodeId,
9    /// Specific event variant and payload.
10    pub(crate) kind: UiEventKind,
11}
12
13/// Attached event listener slots on a `SceneNode`.
14#[derive(Clone, CustomDebug, Data, Default)]
15pub struct EventHandlers {
16    /// Click / tap callback.
17    #[debug(skip)]
18    #[get(skip)]
19    pub(crate) on_click: Option<UiEventHandler>,
20    /// Pointer down callback.
21    #[debug(skip)]
22    #[get(skip)]
23    pub(crate) on_pointer_down: Option<UiEventHandler>,
24    /// Pointer move callback.
25    #[debug(skip)]
26    #[get(skip)]
27    pub(crate) on_pointer_move: Option<UiEventHandler>,
28    /// Pointer up callback.
29    #[debug(skip)]
30    #[get(skip)]
31    pub(crate) on_pointer_up: Option<UiEventHandler>,
32    /// Pointer cancel callback invoked when OS or gesture arbitration aborts an active press.
33    #[debug(skip)]
34    #[get(skip)]
35    pub(crate) on_pointer_cancel: Option<UiEventHandler>,
36    /// Pointer enter callback.
37    #[debug(skip)]
38    #[get(skip)]
39    pub(crate) on_pointer_enter: Option<UiEventHandler>,
40    /// Pointer leave callback.
41    #[debug(skip)]
42    #[get(skip)]
43    pub(crate) on_pointer_leave: Option<UiEventHandler>,
44    /// Scroll callback.
45    #[debug(skip)]
46    #[get(skip)]
47    pub(crate) on_scroll: Option<UiEventHandler>,
48    /// Key down callback.
49    #[debug(skip)]
50    #[get(skip)]
51    pub(crate) on_key_down: Option<UiEventHandler>,
52    /// Text change callback for input widgets.
53    #[debug(skip)]
54    #[get(skip)]
55    pub(crate) on_change: Option<UiEventHandler>,
56    /// Focus gained callback.
57    #[debug(skip)]
58    #[get(skip)]
59    pub(crate) on_focus: Option<UiEventHandler>,
60    /// Focus lost callback.
61    #[debug(skip)]
62    #[get(skip)]
63    pub(crate) on_blur: Option<UiEventHandler>,
64}
65
66/// Normalized scroll bounds and current offsets for a single scene node across standard and virtualized scroll views.
67#[derive(Clone, Copy, Debug, Default, Getter, New, PartialEq)]
68pub(crate) struct ScrollAxisMetrics {
69    /// Whether the node is an `Overflow::Scroll` container.
70    #[get(type(copy))]
71    pub(crate) is_scroll_box: bool,
72    /// Whether the node carries virtualized vertical scroll metrics.
73    #[get(type(copy))]
74    pub(crate) is_virtual: bool,
75    /// Current clamped horizontal scroll offset in logical pixels.
76    #[get(type(copy))]
77    pub(crate) cur_x: f32,
78    /// Maximum horizontal scroll extent in logical pixels.
79    #[get(type(copy))]
80    pub(crate) max_x: f32,
81    /// Current clamped vertical scroll offset in logical pixels.
82    #[get(type(copy))]
83    pub(crate) cur_y: f32,
84    /// Maximum vertical scroll extent in logical pixels.
85    #[get(type(copy))]
86    pub(crate) max_y: f32,
87    /// Full virtualized content height in logical pixels when `is_virtual` is `true`.
88    #[get(type(copy))]
89    pub(crate) total_virtual_h: f32,
90}
91
92/// Result of dispatching a scroll delta across an ancestor scroll chain.
93#[derive(Clone, Copy, Debug, Default, Getter, New, PartialEq)]
94pub(crate) struct ScrollDispatchOutcome {
95    /// Whether any container in the chain consumed non-zero scroll delta.
96    #[get(type(copy))]
97    pub(crate) moved: bool,
98    /// Outermost container that most recently consumed delta during chaining for gesture/smooth-scroll handoff.
99    #[get(skip)]
100    pub(crate) active_target: Option<NodeId>,
101}