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