Skip to main content

enigma_3d/
event.rs

1use std::sync::Arc;
2use crate::AppState;
3
4// winit event re-export
5pub use winit::event::*;
6
7#[derive(Copy, Clone)]
8pub enum EventCharacteristic {
9    KeyPress(VirtualKeyCode),
10    MousePress(MouseButton),
11    MouseDown(MouseButton),
12    MouseScroll(MouseScrollDelta),
13    //TODO: impl more events
14}
15
16#[derive(Copy, Clone)]
17pub struct EventModifiers {
18    pub ctrl: bool,
19    pub shift: bool,
20    pub alt: bool,
21}
22
23impl EventModifiers {
24    pub fn new(ctrl: bool, shift: bool, alt: bool) -> Self {
25        Self {
26            ctrl,
27            shift,
28            alt,
29        }
30    }
31    pub fn default() -> Self {
32        Self {
33            ctrl: false,
34            shift: false,
35            alt: false,
36        }
37    }
38}
39
40impl PartialEq for EventModifiers {
41    fn eq(&self, other: &Self) -> bool {
42        self.ctrl == other.ctrl && self.shift == other.shift && self.alt == other.alt
43    }
44}
45
46pub type EventFunction = Arc<dyn Fn(&mut AppState)>;