Struct gtk::PadController [−][src]
pub struct PadController(_);
Expand description
PadController
is an event controller for the pads found in drawing
tablets (The collection of buttons and tactile sensors often found around
the stylus-sensitive area).
These buttons and sensors have no implicit meaning, and by default they
perform no action, this event controller is provided to map those to
GAction
objects, thus letting the application give those a more semantic
meaning.
Buttons and sensors are not constrained to triggering a single action, some
GDK_SOURCE_TABLET_PAD
devices feature multiple “modes”, all these input
elements have one current mode, which may determine the final action
being triggered. Pad devices often divide buttons and sensors into groups,
all elements in a group share the same current mode, but different groups
may have different modes. See gdk_device_pad_get_n_groups()
and
gdk_device_pad_get_group_n_modes()
.
Each of the actions that a given button/strip/ring performs for a given
mode is defined by PadActionEntry
, it contains an action name that
will be looked up in the given gio::ActionGroup
and activated whenever the
specified input element and mode are triggered.
A simple example of PadController
usage, assigning button 1 in all
modes and pad devices to an “invert-selection” action:
GtkPadActionEntry *pad_actions[] = {
{ GTK_PAD_ACTION_BUTTON, 1, -1, "Invert selection", "pad-actions.invert-selection" },
…
};
…
action_group = g_simple_action_group_new ();
action = g_simple_action_new ("pad-actions.invert-selection", NULL);
g_signal_connect (action, "activate", on_invert_selection_activated, NULL);
g_action_map_add_action (G_ACTION_MAP (action_group), action);
…
pad_controller = gtk_pad_controller_new (window, action_group, NULL);
The actions belonging to rings/strips will be activated with a parameter
of type G_VARIANT_TYPE_DOUBLE
bearing the value of the given axis, it
is required that those are made stateful and accepting this glib::VariantType
.
Implements
Implementations
pub fn new<P: IsA<Window>, Q: IsA<ActionGroup>>(
window: &P,
group: &Q,
pad: Option<&Device>
) -> PadController
This is supported on crate feature v3_22
only.
pub fn new<P: IsA<Window>, Q: IsA<ActionGroup>>(
window: &P,
group: &Q,
pad: Option<&Device>
) -> PadController
v3_22
only.Creates a new PadController
that will associate events from pad
to
actions. A None
pad may be provided so the controller manages all pad devices
generically, it is discouraged to mix PadController
objects with None
and non-None
pad
argument on the same window
, as execution order is not
guaranteed.
The PadController
is created with no mapped actions. In order to map pad
events to actions, use set_action_entries()
or
set_action()
.
window
a Window
group
gio::ActionGroup
to trigger actions from
pad
A GDK_SOURCE_TABLET_PAD
device, or None
to handle all pads
Returns
A newly created PadController
This is supported on crate feature v3_22
only.
v3_22
only.Creates a new builder-pattern struct instance to construct PadController
objects.
This method returns an instance of PadControllerBuilder
which can be used to create PadController
objects.
pub fn set_action(
&self,
type_: PadActionType,
index: i32,
mode: i32,
label: &str,
action_name: &str
)
This is supported on crate feature v3_22
only.
pub fn set_action(
&self,
type_: PadActionType,
index: i32,
mode: i32,
label: &str,
action_name: &str
)
v3_22
only.Adds an individual action to self
. This action will only be activated
if the given button/ring/strip number in index
is interacted while
the current mode is mode
. -1 may be used for simple cases, so the action
is triggered on all modes.
The given label
should be considered user-visible, so internationalization
rules apply. Some windowing systems may be able to use those for user
feedback.
type_
the type of pad feature that will trigger this action
index
the 0-indexed button/ring/strip number that will trigger this action
mode
the mode that will trigger this action, or -1 for all modes.
label
Human readable description of this action, this string should be deemed user-visible.
action_name
action name that will be activated in the gio::ActionGroup
v3_22
only.v3_22
only.This is a convenience function to add a group of action entries on
self
. See PadActionEntry
and set_action()
.
entries
the action entries to set on self
Trait Implementations
type Parent = EventController
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Returns the type identifier of Self
.
Auto Trait Implementations
impl RefUnwindSafe for PadController
impl !Send for PadController
impl !Sync for PadController
impl Unpin for PadController
impl UnwindSafe for PadController
Blanket Implementations
Mutably borrows from an owned value. Read more
Upcasts an object to a superclass or interface T
. Read more
Upcasts an object to a reference of its superclass or interface T
. Read more
Tries to downcast to a subclass or interface implementor T
. Read more
Tries to downcast to a reference of its subclass or interface implementor T
. Read more
Tries to cast to an object of type T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read more
Tries to cast to reference to an object of type T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read more
Casts to T
unconditionally. Read more
Casts to &T
unconditionally. Read more
Returns true
if the object is an instance of (can be cast to) T
.
pub fn set_properties_from_value(
&self,
property_values: &[(&str, Value)]
) -> Result<(), BoolError>
pub fn set_property<'a, N, V>(
&self,
property_name: N,
value: V
) -> Result<(), BoolError> where
V: ToValue,
N: Into<&'a str>,
pub fn set_property_from_value<'a, N>(
&self,
property_name: N,
value: &Value
) -> Result<(), BoolError> where
N: Into<&'a str>,
Safety Read more
Safety Read more
Safety Read more
Safety Read more
pub fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec) + Send + Sync,
pub fn connect_notify_local<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec),
pub unsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: Fn(&T, &ParamSpec),
pub fn has_property<'a, N>(&self, property_name: N, type_: Option<Type>) -> bool where
N: Into<&'a str>,
pub fn find_property<'a, N>(&self, property_name: N) -> Option<ParamSpec> where
N: Into<&'a str>,
pub fn connect<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,
N: Into<&'a str>,
Same as connect
but takes a SignalId
instead of a signal name.
pub fn connect_local<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: Fn(&[Value]) -> Option<Value> + 'static,
N: Into<&'a str>,
Same as connect_local
but takes a SignalId
instead of a signal name.
pub unsafe fn connect_unsafe<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: Fn(&[Value]) -> Option<Value>,
N: Into<&'a str>,
Same as connect_unsafe
but takes a SignalId
instead of a signal name.
Emit signal by signal id.
Emit signal with details by signal id.
Emit signal by it’s name.
pub fn bind_property<'a, O, N, M>(
&'a self,
source_property: N,
target: &'a O,
target_property: M
) -> BindingBuilder<'a> where
O: ObjectType,
N: Into<&'a str>,
M: Into<&'a str>,
Same as emit
but takes Value
for the arguments.
Same as emit_by_name
but takes Value
for the arguments.
Returns a SendValue
clone of self
.
impl<'a, T, C> FromValueOptional<'a> for T where
C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError>,
T: FromValue<'a, Checker = C>,