Skip to main content

gdk/auto/
device_pad.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{Device, DevicePadFeature};
6use glib::{prelude::*, translate::*};
7use std::fmt;
8
9glib::wrapper! {
10    /// [`DevicePad`][crate::DevicePad] is an interface implemented by devices of type
11    /// [`InputSource::TabletPad`][crate::InputSource::TabletPad], it allows querying the features provided
12    /// by the pad device.
13    ///
14    /// Tablet pads may contain one or more groups, each containing a subset
15    /// of the buttons/rings/strips available. [`DevicePadExt::n_groups()`][crate::prelude::DevicePadExt::n_groups()]
16    /// can be used to obtain the number of groups, [`DevicePadExt::n_features()`][crate::prelude::DevicePadExt::n_features()]
17    /// and [`DevicePadExt::feature_group()`][crate::prelude::DevicePadExt::feature_group()] can be combined to find out the
18    /// number of buttons/rings/strips the device has, and how are they grouped.
19    ///
20    /// Each of those groups have different modes, which may be used to map
21    /// each individual pad feature to multiple actions. Only one mode is
22    /// effective (current) for each given group, different groups may have
23    /// different current modes. The number of available modes in a group can
24    /// be found out through [`DevicePadExt::group_n_modes()`][crate::prelude::DevicePadExt::group_n_modes()], and the current
25    /// mode for a given group will be notified through the [`EventPadGroupMode`][crate::EventPadGroupMode]
26    /// event.
27    ///
28    /// # Implements
29    ///
30    /// [`DevicePadExt`][trait@crate::prelude::DevicePadExt], [`DeviceExt`][trait@crate::prelude::DeviceExt], [`DeviceExtManual`][trait@crate::prelude::DeviceExtManual]
31    #[doc(alias = "GdkDevicePad")]
32    pub struct DevicePad(Interface<ffi::GdkDevicePad, ffi::GdkDevicePadInterface>) @requires Device;
33
34    match fn {
35        type_ => || ffi::gdk_device_pad_get_type(),
36    }
37}
38
39impl DevicePad {
40    pub const NONE: Option<&'static DevicePad> = None;
41}
42
43mod sealed {
44    pub trait Sealed {}
45    impl<T: super::IsA<super::DevicePad>> Sealed for T {}
46}
47
48/// Trait containing all [`struct@DevicePad`] methods.
49///
50/// # Implementors
51///
52/// [`DevicePad`][struct@crate::DevicePad]
53pub trait DevicePadExt: IsA<DevicePad> + sealed::Sealed + 'static {
54    /// Returns the group the given `feature` and `idx` belong to,
55    /// or -1 if feature/index do not exist in `self`.
56    /// ## `feature`
57    /// the feature type to get the group from
58    /// ## `feature_idx`
59    /// the index of the feature to get the group from
60    ///
61    /// # Returns
62    ///
63    /// The group number of the queried pad feature.
64    #[doc(alias = "gdk_device_pad_get_feature_group")]
65    #[doc(alias = "get_feature_group")]
66    fn feature_group(&self, feature: DevicePadFeature, feature_idx: i32) -> i32 {
67        unsafe {
68            ffi::gdk_device_pad_get_feature_group(
69                self.as_ref().to_glib_none().0,
70                feature.into_glib(),
71                feature_idx,
72            )
73        }
74    }
75
76    /// Returns the number of modes that `group` may have.
77    /// ## `group_idx`
78    /// group to get the number of available modes from
79    ///
80    /// # Returns
81    ///
82    /// The number of modes available in `group`.
83    #[doc(alias = "gdk_device_pad_get_group_n_modes")]
84    #[doc(alias = "get_group_n_modes")]
85    fn group_n_modes(&self, group_idx: i32) -> i32 {
86        unsafe { ffi::gdk_device_pad_get_group_n_modes(self.as_ref().to_glib_none().0, group_idx) }
87    }
88
89    /// Returns the number of features a tablet pad has.
90    /// ## `feature`
91    /// a pad feature
92    ///
93    /// # Returns
94    ///
95    /// The amount of elements of type `feature` that this pad has.
96    #[doc(alias = "gdk_device_pad_get_n_features")]
97    #[doc(alias = "get_n_features")]
98    fn n_features(&self, feature: DevicePadFeature) -> i32 {
99        unsafe {
100            ffi::gdk_device_pad_get_n_features(self.as_ref().to_glib_none().0, feature.into_glib())
101        }
102    }
103
104    /// Returns the number of groups this pad device has. Pads have
105    /// at least one group. A pad group is a subcollection of
106    /// buttons/strip/rings that is affected collectively by a same
107    /// current mode.
108    ///
109    /// # Returns
110    ///
111    /// The number of button/ring/strip groups in the pad.
112    #[doc(alias = "gdk_device_pad_get_n_groups")]
113    #[doc(alias = "get_n_groups")]
114    fn n_groups(&self) -> i32 {
115        unsafe { ffi::gdk_device_pad_get_n_groups(self.as_ref().to_glib_none().0) }
116    }
117}
118
119impl<O: IsA<DevicePad>> DevicePadExt for O {}
120
121impl fmt::Display for DevicePad {
122    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
123        f.write_str("DevicePad")
124    }
125}