grafix_toolbox/kit/opengl/context/
event.rs1use super::*;
2
3#[derive(Debug, Clone)]
4pub enum Event {
5 MouseMove { at: Vec2, m: Mod },
6 MouseButton { button: Click, m: Mod },
7 Scroll { at: Vec2, m: Mod },
8 Keyboard { key: Key, m: Mod },
9 Char { ch: char },
10 OfferFocus,
11 Defocus,
12}
13
14#[derive(Default, Debug, Clone, Copy)]
15pub enum EventReply {
16 Accept,
17 Reject,
18 #[default]
19 Pass,
20 DropFocus,
21}
22
23bitflags! {#[derive(Default, Debug, Clone, Copy, PartialEq)]
24pub struct Mod: u16 {
25 const PRESS = 0x1;
26 const RELEASE = 0x2;
27 const SHIFT = 0x10;
28 const CTRL = 0x20;
29 const ALT = 0x40;
30 const WIN = 0x80;
31 const LEFT = 0x100;
32 const MID = 0x200;
33 const RIGHT = 0x400;
34}}
35impl Mod {
36 pub fn pressed(&self) -> bool {
37 self.contains(Mod::PRESS)
38 }
39 pub fn released(&self) -> bool {
40 self.contains(Mod::RELEASE)
41 }
42 pub fn ctrl(&self) -> bool {
43 self.contains(Mod::CTRL)
44 }
45 pub fn shift(&self) -> bool {
46 self.contains(Mod::SHIFT)
47 }
48 pub fn alt(&self) -> bool {
49 self.contains(Mod::ALT)
50 }
51 pub fn win(&self) -> bool {
52 self.contains(Mod::WIN)
53 }
54 pub fn lmb(&self) -> bool {
55 self.contains(Mod::LEFT)
56 }
57 pub fn mmb(&self) -> bool {
58 self.contains(Mod::MID)
59 }
60 pub fn rmb(&self) -> bool {
61 self.contains(Mod::RIGHT)
62 }
63}
64
65#[derive(Debug, Clone, Copy)]
66pub enum Click {
67 Left,
68 Right,
69 Middle,
70}
71
72pub use sdl2::keyboard::Keycode as Key;