1use gdk_sys;
6use glib::translate::*;
7
8#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
9pub struct EventScroll(::Event);
10
11event_wrapper!(EventScroll, GdkEventScroll);
12event_subtype!(EventScroll, gdk_sys::GDK_SCROLL);
13
14impl EventScroll {
15 pub fn get_time(&self) -> u32 {
16 self.as_ref().time
17 }
18
19 pub fn get_position(&self) -> (f64, f64) {
20 let x = self.as_ref().x;
21 let y = self.as_ref().y;
22 (x, y)
23 }
24
25 pub fn get_state(&self) -> ::ModifierType {
26 from_glib(self.as_ref().state)
27 }
28
29 pub fn get_device(&self) -> Option<::Device> {
30 unsafe { from_glib_none(self.as_ref().device) }
31 }
32
33 pub fn get_direction(&self) -> ::ScrollDirection {
34 from_glib(self.as_ref().direction)
35 }
36
37 pub fn get_root(&self) -> (f64, f64) {
38 let x_root = self.as_ref().x_root;
39 let y_root = self.as_ref().y_root;
40 (x_root, y_root)
41 }
42
43 pub fn get_delta(&self) -> (f64, f64) {
44 let dx = self.as_ref().delta_x;
45 let dy = self.as_ref().delta_y;
46 (dx, dy)
47 }
48
49 pub fn get_is_stop(&self) -> bool {
50 self.as_ref().is_stop & 1 != 0
51 }
52}