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
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use gdk_sys;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;
use Device;
#[cfg(any(feature = "v3_22", feature = "dox"))]
use DevicePadFeature;

glib_wrapper! {
    /// `DevicePad` is an interface implemented by devices of type
    /// `InputSource::TabletPad`, it allows querying the features provided
    /// by the pad device.
    ///
    /// Tablet pads may contain one or more groups, each containing a subset
    /// of the buttons/rings/strips available. `DevicePad::get_n_groups`
    /// can be used to obtain the number of groups, `DevicePad::get_n_features`
    /// and `DevicePad::get_feature_group` can be combined to find out the
    /// number of buttons/rings/strips the device has, and how are they grouped.
    ///
    /// Each of those groups have different modes, which may be used to map
    /// each individual pad feature to multiple actions. Only one mode is
    /// effective (current) for each given group, different groups may have
    /// different current modes. The number of available modes in a group can
    /// be found out through `DevicePad::get_group_n_modes`, and the current
    /// mode for a given group will be notified through the `EventPadGroupMode`
    /// event.
    ///
    /// Feature: `v3_22`
    ///
    /// # Implements
    ///
    /// [`DevicePadExt`](trait.DevicePadExt.html), [`DeviceExt`](trait.DeviceExt.html)
    pub struct DevicePad(Interface<gdk_sys::GdkDevicePad>) @requires Device;

    match fn {
        get_type => || gdk_sys::gdk_device_pad_get_type(),
    }
}

pub const NONE_DEVICE_PAD: Option<&DevicePad> = None;

/// Trait containing all `DevicePad` methods.
///
/// Feature: `v3_22`
///
/// # Implementors
///
/// [`DevicePad`](struct.DevicePad.html)
pub trait DevicePadExt: 'static {
    /// Returns the group the given `feature` and `idx` belong to,
    /// or -1 if feature/index do not exist in `self`.
    ///
    /// Feature: `v3_22`
    ///
    /// ## `feature`
    /// the feature type to get the group from
    /// ## `feature_idx`
    /// the index of the feature to get the group from
    ///
    /// # Returns
    ///
    /// The group number of the queried pad feature.
    #[cfg(any(feature = "v3_22", feature = "dox"))]
    fn get_feature_group(&self, feature: DevicePadFeature, feature_idx: i32) -> i32;

    /// Returns the number of modes that `group` may have.
    ///
    /// Feature: `v3_22`
    ///
    /// ## `group_idx`
    /// group to get the number of available modes from
    ///
    /// # Returns
    ///
    /// The number of modes available in `group`.
    #[cfg(any(feature = "v3_22", feature = "dox"))]
    fn get_group_n_modes(&self, group_idx: i32) -> i32;

    /// Returns the number of features a tablet pad has.
    ///
    /// Feature: `v3_22`
    ///
    /// ## `feature`
    /// a pad feature
    ///
    /// # Returns
    ///
    /// The amount of elements of type `feature` that this pad has.
    #[cfg(any(feature = "v3_22", feature = "dox"))]
    fn get_n_features(&self, feature: DevicePadFeature) -> i32;

    /// Returns the number of groups this pad device has. Pads have
    /// at least one group. A pad group is a subcollection of
    /// buttons/strip/rings that is affected collectively by a same
    /// current mode.
    ///
    /// Feature: `v3_22`
    ///
    ///
    /// # Returns
    ///
    /// The number of button/ring/strip groups in the pad.
    #[cfg(any(feature = "v3_22", feature = "dox"))]
    fn get_n_groups(&self) -> i32;
}

impl<O: IsA<DevicePad>> DevicePadExt for O {
    #[cfg(any(feature = "v3_22", feature = "dox"))]
    fn get_feature_group(&self, feature: DevicePadFeature, feature_idx: i32) -> i32 {
        unsafe {
            gdk_sys::gdk_device_pad_get_feature_group(
                self.as_ref().to_glib_none().0,
                feature.to_glib(),
                feature_idx,
            )
        }
    }

    #[cfg(any(feature = "v3_22", feature = "dox"))]
    fn get_group_n_modes(&self, group_idx: i32) -> i32 {
        unsafe {
            gdk_sys::gdk_device_pad_get_group_n_modes(self.as_ref().to_glib_none().0, group_idx)
        }
    }

    #[cfg(any(feature = "v3_22", feature = "dox"))]
    fn get_n_features(&self, feature: DevicePadFeature) -> i32 {
        unsafe {
            gdk_sys::gdk_device_pad_get_n_features(
                self.as_ref().to_glib_none().0,
                feature.to_glib(),
            )
        }
    }

    #[cfg(any(feature = "v3_22", feature = "dox"))]
    fn get_n_groups(&self) -> i32 {
        unsafe { gdk_sys::gdk_device_pad_get_n_groups(self.as_ref().to_glib_none().0) }
    }
}

impl fmt::Display for DevicePad {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "DevicePad")
    }
}