gdk4/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::{ffi, Device, DevicePadFeature};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 /// [`DevicePad`][crate::DevicePad] is an interface implemented by devices of type
10 /// [`InputSource::TabletPad`][crate::InputSource::TabletPad]
11 ///
12 /// It allows querying the features provided 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
18 /// the 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 each
21 /// individual pad feature to multiple actions. Only one mode is effective
22 /// (current) for each given group, different groups may have different
23 /// current modes. The number of available modes in a group can be found
24 /// out through [`DevicePadExt::group_n_modes()`][crate::prelude::DevicePadExt::group_n_modes()], and the current mode
25 /// for a given group will be notified through events of type `GDK_PAD_GROUP_MODE`.
26 ///
27 /// # Implements
28 ///
29 /// [`DevicePadExt`][trait@crate::prelude::DevicePadExt], [`DeviceExt`][trait@crate::prelude::DeviceExt]
30 #[doc(alias = "GdkDevicePad")]
31 pub struct DevicePad(Interface<ffi::GdkDevicePad, ffi::GdkDevicePadInterface>) @requires Device;
32
33 match fn {
34 type_ => || ffi::gdk_device_pad_get_type(),
35 }
36}
37
38impl DevicePad {
39 pub const NONE: Option<&'static DevicePad> = None;
40}
41
42mod sealed {
43 pub trait Sealed {}
44 impl<T: super::IsA<super::DevicePad>> Sealed for T {}
45}
46
47/// Trait containing all [`struct@DevicePad`] methods.
48///
49/// # Implementors
50///
51/// [`DevicePad`][struct@crate::DevicePad]
52pub trait DevicePadExt: IsA<DevicePad> + sealed::Sealed + 'static {
53 /// Returns the group the given @feature and @idx belong to.
54 ///
55 /// f the feature or index do not exist in @self, -1 is returned.
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.
105 ///
106 /// Pads have at least one group. A pad group is a subcollection of
107 /// buttons/strip/rings that is affected collectively by a same
108 /// current mode.
109 ///
110 /// # Returns
111 ///
112 /// The number of button/ring/strip groups in the pad.
113 #[doc(alias = "gdk_device_pad_get_n_groups")]
114 #[doc(alias = "get_n_groups")]
115 fn n_groups(&self) -> i32 {
116 unsafe { ffi::gdk_device_pad_get_n_groups(self.as_ref().to_glib_none().0) }
117 }
118}
119
120impl<O: IsA<DevicePad>> DevicePadExt for O {}