ori_core/event/
pointer.rs1use glam::Vec2;
2
3use crate::Modifiers;
4
5#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
6pub enum PointerButton {
7 Primary,
8 Secondary,
9 Tertiary,
10 Other(u16),
11}
12
13#[derive(Clone, Debug, Default)]
14pub struct PointerEvent {
15 pub id: u64,
17 pub position: Vec2,
19 pub scroll_delta: Vec2,
21 pub pressed: bool,
23 pub left: bool,
25 pub button: Option<PointerButton>,
27 pub modifiers: Modifiers,
29}
30
31impl PointerEvent {
32 pub fn is_pressed(&self, button: PointerButton) -> bool {
34 self.pressed && self.button == Some(button)
35 }
36
37 pub fn is_released(&self, button: PointerButton) -> bool {
39 !self.pressed && self.button == Some(button)
40 }
41
42 pub fn is_press(&self) -> bool {
44 self.pressed && self.button.is_some()
45 }
46
47 pub fn is_release(&self) -> bool {
49 !self.pressed && self.button.is_some()
50 }
51}