1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Take a look at the license at the top of the repository in the LICENSE file.

use gdk::AxisUse;
use glib::translate::*;

use crate::GestureStylus;

impl GestureStylus {
    /// Returns the current values for the requested @axes.
    ///
    /// This function must be called from the handler of one of the
    /// [`down`][struct@crate::GestureStylus#down], [`motion`][struct@crate::GestureStylus#motion],
    /// [`up`][struct@crate::GestureStylus#up] or [`proximity`][struct@crate::GestureStylus#proximity]
    /// signals.
    /// ## `axes`
    /// array of requested axes, terminated with [`gdk::AxisUse::Ignore`][crate::gdk::AxisUse::Ignore]
    ///
    /// # Returns
    ///
    /// [`true`] if there is a current value for the axes
    ///
    /// ## `values`
    /// return location for the axis values
    #[doc(alias = "gtk_gesture_stylus_get_axes")]
    #[doc(alias = "get_axes")]
    pub fn axes(&self, axes: Vec<AxisUse>) -> Option<Vec<f64>> {
        let mut values = std::ptr::null_mut();
        unsafe {
            let mut axes1: Vec<gdk::ffi::GdkAxisUse> = axes.iter().map(|a| a.into_glib()).collect();
            axes1.push(gdk::ffi::GDK_AXIS_IGNORE);
            if from_glib(ffi::gtk_gesture_stylus_get_axes(
                self.to_glib_none().0,
                axes1.as_mut_ptr(),
                &mut values,
            )) {
                Some(FromGlibContainer::from_glib_container_num(
                    values,
                    axes.len(),
                ))
            } else {
                None
            }
        }
    }
}