Skip to main content

euv_core/window/input/
enum.rs

1use super::*;
2
3/// Source pointer device class unified across desktop, tablet, mobile, and web.
4#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
5pub enum PointerDevice {
6    /// Mouse or trackpad cursor.
7    #[default]
8    Mouse,
9    /// Capacitive touch finger contact.
10    Touch,
11    /// Stylus or Apple Pencil contact with pressure/tilt metadata.
12    Stylus,
13}
14
15/// Mouse / stylus button identity.
16#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
17pub enum PointerButton {
18    /// Primary left click / finger tap.
19    #[default]
20    Primary,
21    /// Secondary right click / context button.
22    Secondary,
23    /// Middle scroll-wheel click.
24    Auxiliary,
25}
26
27/// Unified physical/logical key code covering desktop, iPadOS hardware keyboard, Android, and Web.
28#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
29pub enum KeyCode {
30    /// Unmapped key.
31    #[default]
32    Unknown,
33    /// Enter / Return key.
34    Enter,
35    /// Escape key.
36    Escape,
37    /// System Back navigation key/gesture (Android hardware/gesture Back, iOS/Web back command).
38    Back,
39    /// Tab key.
40    Tab,
41    /// Backspace key.
42    Backspace,
43    /// Delete key.
44    Delete,
45    /// Spacebar.
46    Space,
47    /// Arrow Up.
48    ArrowUp,
49    /// Arrow Down.
50    ArrowDown,
51    /// Arrow Left.
52    ArrowLeft,
53    /// Arrow Right.
54    ArrowRight,
55    /// Home key.
56    Home,
57    /// End key.
58    End,
59    /// Page Up.
60    PageUp,
61    /// Page Down.
62    PageDown,
63    /// Printable character key.
64    Character(char),
65}
66
67/// Mobile / desktop application lifecycle state transitions.
68#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
69pub enum LifecycleEvent {
70    /// Application resumed foreground activity.
71    Resumed,
72    /// Application moved to background / inactive state.
73    Paused,
74    /// Operating system signaled low-memory pressure.
75    LowMemory,
76    /// Application is terminating.
77    Terminated,
78}
79
80/// Input Method Editor (IME) composition event for CJK and mobile virtual keyboards.
81#[derive(Clone, Debug, Eq, PartialEq)]
82pub enum ImeEvent {
83    /// IME enabled on the active text input.
84    Enabled,
85    /// In-progress pre-edit text with optional selection range.
86    Preedit(String, Option<(usize, usize)>),
87    /// Final committed text string.
88    Commit(String),
89    /// IME dismissed.
90    Disabled,
91}
92
93/// Complete unified platform window event dispatched to the application loop.
94#[derive(Clone, Debug, PartialEq)]
95pub enum WindowEvent {
96    /// Window logical and physical dimensions changed.
97    Resized(WindowId, u32, u32, f32),
98    /// Safe-area insets updated (rotation, Stage Manager, virtual keyboard).
99    SafeAreaChanged(WindowId, SafeAreaInsets),
100    /// OS light/dark appearance toggled.
101    ThemeChanged(WindowId, ThemeMode),
102    /// Window gained or lost focus.
103    Focused(WindowId, bool),
104    /// OS requested window closure.
105    CloseRequested(WindowId),
106    /// Pointer pressed down.
107    PointerDown(WindowId, PointerEvent),
108    /// Pointer moved.
109    PointerMove(WindowId, PointerEvent),
110    /// Pointer released.
111    PointerUp(WindowId, PointerEvent),
112    /// Pointer gesture cancelled by OS.
113    PointerCancel(WindowId, u64),
114    /// Scroll wheel / trackpad / pan delta.
115    Scroll(WindowId, Point),
116    /// Keyboard key pressed.
117    KeyDown(WindowId, KeyEvent),
118    /// Keyboard key released.
119    KeyUp(WindowId, KeyEvent),
120    /// Direct UTF-8 text input event.
121    TextInput(WindowId, String),
122    /// IME composition lifecycle event.
123    Ime(WindowId, ImeEvent),
124    /// Application lifecycle transition.
125    Lifecycle(LifecycleEvent),
126    /// Platform requests a fresh rendered frame.
127    RedrawRequested(WindowId),
128    /// Operating system delivered a custom-scheme or universal deep link URI.
129    DeepLink(DeepLinkEvent),
130}
131
132/// Cross-platform high-level pointer/touch gesture classification emitted by `App`.
133#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
134pub enum GestureEventKind {
135    /// Clean single tap or click within tap slop.
136    #[default]
137    Tap,
138    /// Two consecutive clean taps within the double-tap time and distance window.
139    DoubleTap,
140    /// Stationary press held past the long-press threshold (`>= 450ms`).
141    LongPress,
142    /// Fast directional horizontal swipe to the left.
143    SwipeLeft,
144    /// Fast directional horizontal swipe to the right.
145    SwipeRight,
146    /// Fast directional vertical swipe upward.
147    SwipeUp,
148    /// Fast directional vertical swipe downward.
149    SwipeDown,
150    /// Continuous single-finger pan or drag gesture.
151    Pan,
152    /// Two-finger pinch-to-zoom gesture carrying relative `scale`.
153    Pinch,
154}