flatland_client_ui/
input.rs1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4pub enum UiKeyEventKind {
5 Press,
6 Release,
7 Repeat,
8}
9
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
11pub struct UiKeyModifiers {
12 pub shift: bool,
13 pub control: bool,
14 pub alt: bool,
15}
16
17impl UiKeyModifiers {
18 pub fn contains_shift(self) -> bool {
19 self.shift
20 }
21
22 pub fn contains_control(self) -> bool {
23 self.control
24 }
25
26 pub fn contains_alt(self) -> bool {
27 self.alt
28 }
29}
30
31#[derive(Debug, Clone, Copy, PartialEq, Eq)]
32pub enum UiKeyCode {
33 Char(char),
34 Up,
35 Down,
36 Left,
37 Right,
38 Esc,
39 Enter,
40 Tab,
41 BackTab,
42 PageUp,
43 PageDown,
44 Delete,
45 Backspace,
46 Space,
47 ShiftLeft,
48 ShiftRight,
49}
50
51#[derive(Debug, Clone, Copy, PartialEq, Eq)]
52pub struct UiKeyEvent {
53 pub kind: UiKeyEventKind,
54 pub code: UiKeyCode,
55 pub modifiers: UiKeyModifiers,
56}
57
58#[derive(Debug, Clone, Copy, PartialEq, Eq)]
59pub enum UiMouseButton {
60 Left,
61 Right,
62 Middle,
63}
64
65#[derive(Debug, Clone, Copy, PartialEq)]
66pub enum UiPointerEvent {
67 Move {
68 x: f32,
69 y: f32,
70 },
71 Click {
72 x: f32,
73 y: f32,
74 button: UiMouseButton,
75 shift: bool,
77 },
78 Scroll {
79 x: f32,
80 y: f32,
81 delta: f32,
82 },
83}