Skip to main content

gdk/
event_touchpad_pinch.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::translate::*;
4
5/// Generated during touchpad swipe gestures.
6#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
7pub struct EventTouchpadPinch(crate::Event);
8
9event_wrapper!(EventTouchpadPinch, GdkEventTouchpadPinch);
10event_subtype!(EventTouchpadPinch, ffi::GDK_TOUCHPAD_PINCH);
11
12impl EventTouchpadPinch {
13    pub fn is_phase(&self) -> bool {
14        unsafe { from_glib(self.as_ref().phase as _) }
15    }
16
17    #[doc(alias = "get_n_fingers")]
18    pub fn n_fingers(&self) -> i8 {
19        self.as_ref().n_fingers
20    }
21
22    #[doc(alias = "get_time")]
23    pub fn time(&self) -> u32 {
24        self.as_ref().time
25    }
26
27    #[doc(alias = "get_position")]
28    pub fn position(&self) -> (f64, f64) {
29        let x = self.as_ref().x;
30        let y = self.as_ref().y;
31        (x, y)
32    }
33
34    #[doc(alias = "get_delta")]
35    pub fn delta(&self) -> (f64, f64) {
36        let dx = self.as_ref().dx;
37        let dy = self.as_ref().dy;
38        (dx, dy)
39    }
40
41    #[doc(alias = "get_angle_delta")]
42    pub fn angle_delta(&self) -> f64 {
43        self.as_ref().angle_delta
44    }
45
46    #[doc(alias = "get_scale")]
47    pub fn scale(&self) -> f64 {
48        self.as_ref().scale
49    }
50
51    #[doc(alias = "get_root")]
52    pub fn root(&self) -> (f64, f64) {
53        let x_root = self.as_ref().x_root;
54        let y_root = self.as_ref().y_root;
55        (x_root, y_root)
56    }
57
58    #[doc(alias = "get_state")]
59    pub fn state(&self) -> crate::ModifierType {
60        unsafe { from_glib(self.as_ref().state) }
61    }
62}