gtk4/
gesture_stylus.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use gdk::AxisUse;
4use glib::translate::*;
5
6use crate::{ffi, GestureStylus};
7
8impl GestureStylus {
9    /// Returns the current values for the requested @axes.
10    ///
11    /// This function must be called from the handler of one of the
12    /// [`down`][struct@crate::GestureStylus#down], [`motion`][struct@crate::GestureStylus#motion],
13    /// [`up`][struct@crate::GestureStylus#up] or [`proximity`][struct@crate::GestureStylus#proximity]
14    /// signals.
15    /// ## `axes`
16    /// array of requested axes, terminated with [`gdk::AxisUse::Ignore`][crate::gdk::AxisUse::Ignore]
17    ///
18    /// # Returns
19    ///
20    /// [`true`] if there is a current value for the axes
21    ///
22    /// ## `values`
23    /// return location for the axis values
24    #[doc(alias = "gtk_gesture_stylus_get_axes")]
25    #[doc(alias = "get_axes")]
26    pub fn axes(&self, axes: Vec<AxisUse>) -> Option<Vec<f64>> {
27        let mut values = std::ptr::null_mut();
28        unsafe {
29            let mut axes1: Vec<gdk::ffi::GdkAxisUse> = axes.iter().map(|a| a.into_glib()).collect();
30            axes1.push(gdk::ffi::GDK_AXIS_IGNORE);
31            if from_glib(ffi::gtk_gesture_stylus_get_axes(
32                self.to_glib_none().0,
33                axes1.as_mut_ptr(),
34                &mut values,
35            )) {
36                Some(FromGlibContainer::from_glib_container_num(
37                    values,
38                    axes.len(),
39                ))
40            } else {
41                None
42            }
43        }
44    }
45}