1use crate::ffi;
4use glib::translate::*;
5
6#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
15pub struct EventScroll(crate::Event);
16
17event_wrapper!(EventScroll, GdkEventScroll);
18event_subtype!(EventScroll, ffi::GDK_SCROLL);
19
20impl EventScroll {
21 #[doc(alias = "get_time")]
22 pub fn time(&self) -> u32 {
23 self.as_ref().time
24 }
25
26 #[doc(alias = "get_position")]
27 pub fn position(&self) -> (f64, f64) {
28 let x = self.as_ref().x;
29 let y = self.as_ref().y;
30 (x, y)
31 }
32
33 #[doc(alias = "get_state")]
34 pub fn state(&self) -> crate::ModifierType {
35 unsafe { from_glib(self.as_ref().state) }
36 }
37
38 #[doc(alias = "get_device")]
39 pub fn device(&self) -> Option<crate::Device> {
40 unsafe { from_glib_none(self.as_ref().device) }
41 }
42
43 #[doc(alias = "get_direction")]
44 pub fn direction(&self) -> crate::ScrollDirection {
45 unsafe { from_glib(self.as_ref().direction) }
46 }
47
48 #[doc(alias = "get_root")]
49 pub fn root(&self) -> (f64, f64) {
50 let x_root = self.as_ref().x_root;
51 let y_root = self.as_ref().y_root;
52 (x_root, y_root)
53 }
54
55 #[doc(alias = "get_delta")]
56 pub fn delta(&self) -> (f64, f64) {
57 let dx = self.as_ref().delta_x;
58 let dy = self.as_ref().delta_y;
59 (dx, dy)
60 }
61
62 #[doc(alias = "get_is_stop")]
63 pub fn is_stop(&self) -> bool {
64 self.as_ref().is_stop & 1 != 0
65 }
66}