Class: Gtk::Gesture
- Inherits:
-
EventController
- Object
- EventController
- Gtk::Gesture
- Defined in:
- (unknown)
Direct Known Subclasses
Instance Method Summary collapse
-
#device ⇒ Gdk::Device
Returns the logical
GdkDevicethat is currently operating on gesture. -
#get_bounding_box(rect) ⇒ Boolean
If there are touch sequences being currently handled by gesture, returns true and fills in rect with the bounding box containing all active touches.
-
#get_bounding_box_center(x, y) ⇒ Boolean
If there are touch sequences being currently handled by gesture, returns true and fills in x and y with the center of the bounding box containing all active touches.
-
#get_last_event(sequence) ⇒ Gdk::Event
Returns the last event that was processed for sequence.
-
#get_point(sequence, x, y) ⇒ Boolean
If sequence is currently being interpreted by gesture, returns true and fills in x and y with the last coordinates stored for that event sequence.
-
#get_sequence_state(sequence) ⇒ Gtk::EventSequenceState
Returns the sequence state, as seen by gesture.
-
#group(gesture) ⇒ nil
Adds gesture to the same group than group_gesture.
-
#handles_sequence(sequence) ⇒ Boolean
Returns true if gesture is currently handling events corresponding to sequence.
-
#is_active ⇒ Boolean
Returns true if the gesture is currently active.
-
#is_grouped_with(other) ⇒ Boolean
Returns true if both gestures pertain to the same group.
-
#is_recognized ⇒ Boolean
Returns true if the gesture is currently recognized.
-
#last_updated_sequence ⇒ Gdk::EventSequence
Returns the
GdkEventSequencethat was last updated on gesture. -
#n_points ⇒ Integer
The number of touch points that trigger recognition on this gesture.
-
#n_points=(n_points) ⇒ Integer
The number of touch points that trigger recognition on this gesture.
-
#sequences ⇒ GLib::List<Gdk::EventSequence>
Returns the list of
GdkEventSequencescurrently being interpreted by gesture. -
#set_sequence_state(sequence, state) ⇒ Boolean
Sets the state of sequence in gesture.
-
#state=(state) ⇒ Boolean
Sets the state of all sequences that gesture is currently interacting with.
-
#ungroup ⇒ nil
Separates gesture into an isolated group.
Methods inherited from EventController
#current_event, #current_event_device, #current_event_state, #current_event_time, #name, #name=, #propagation_limit, #propagation_limit=, #propagation_phase, #propagation_phase=, #reset, #static_name=, #widget, #widget=
Instance Method Details
#device ⇒ Gdk::Device
Returns the logical GdkDevice that is currently operating
on gesture.
This returns nil if the gesture is not being interacted.
#get_bounding_box(rect) ⇒ Boolean
If there are touch sequences being currently handled by gesture, returns true and fills in rect with the bounding box containing all active touches.
Otherwise, false will be returned.
Note: This function will yield unexpected results on touchpad gestures. Since there is no correlation between physical and pixel distances, these will look as if constrained in an infinitely small area, rect width and height will thus be 0 regardless of the number of touchpoints.
#get_bounding_box_center(x, y) ⇒ Boolean
If there are touch sequences being currently handled by gesture, returns true and fills in x and y with the center of the bounding box containing all active touches.
Otherwise, false will be returned.
#get_last_event(sequence) ⇒ Gdk::Event
Returns the last event that was processed for sequence.
Note that the returned pointer is only valid as long as the sequence is still interpreted by the gesture. If in doubt, you should make a copy of the event.
#get_point(sequence, x, y) ⇒ Boolean
If sequence is currently being interpreted by gesture, returns true and fills in x and y with the last coordinates stored for that event sequence.
The coordinates are always relative to the widget allocation.
#get_sequence_state(sequence) ⇒ Gtk::EventSequenceState
Returns the sequence state, as seen by gesture.
#group(gesture) ⇒ nil
Adds gesture to the same group than group_gesture.
Gestures are by default isolated in their own groups.
Both gestures must have been added to the same widget before they can be grouped.
When gestures are grouped, the state of GdkEventSequences
is kept in sync for all of those, so calling
[methodGtk.Gesture.set_sequence_state], on one will transfer
the same value to the others.
Groups also perform an "implicit grabbing" of sequences, if a
GdkEventSequence state is set to %GTK_EVENT_SEQUENCE_CLAIMED
on one group, every other gesture group attached to the same
GtkWidget will switch the state for that sequence to
%GTK_EVENT_SEQUENCE_DENIED.
#handles_sequence(sequence) ⇒ Boolean
Returns true if gesture is currently handling events corresponding to sequence.
#is_active ⇒ Boolean
Returns true if the gesture is currently active.
A gesture is active while there are touch sequences interacting with it.
#is_grouped_with(other) ⇒ Boolean
Returns true if both gestures pertain to the same group.
#is_recognized ⇒ Boolean
Returns true if the gesture is currently recognized.
A gesture is recognized if there are as many interacting touch sequences as required by gesture.
#last_updated_sequence ⇒ Gdk::EventSequence
Returns the GdkEventSequence that was last updated on gesture.
#n_points ⇒ Integer
The number of touch points that trigger recognition on this gesture.
#n_points=(n_points) ⇒ Integer
The number of touch points that trigger recognition on this gesture.
#sequences ⇒ GLib::List<Gdk::EventSequence>
Returns the list of GdkEventSequences currently being interpreted
by gesture.
#set_sequence_state(sequence, state) ⇒ Boolean
Sets the state of sequence in gesture.
Sequences start in state %GTK_EVENT_SEQUENCE_NONE, and whenever they change state, they can never go back to that state. Likewise, sequences in state %GTK_EVENT_SEQUENCE_DENIED cannot turn back to a not denied state. With these rules, the lifetime of an event sequence is constrained to the next four:
- None
- None → Denied
- None → Claimed
- None → Claimed → Denied
Note: Due to event handling ordering, it may be unsafe to set the state on another gesture within a [signalGtk.Gesture::begin] signal handler, as the callback might be executed before the other gesture knows about the sequence. A safe way to perform this could be:
static void
first_gesture_begin_cb (GtkGesture *first_gesture,
GdkEventSequence *sequence,
gpointer user_data)
{
gtk_gesture_set_sequence_state (first_gesture, sequence, GTK_EVENT_SEQUENCE_CLAIMED);
gtk_gesture_set_sequence_state (second_gesture, sequence, GTK_EVENT_SEQUENCE_DENIED);
}
static void
second_gesture_begin_cb (GtkGesture *second_gesture,
GdkEventSequence *sequence,
gpointer user_data)
{
if (gtk_gesture_get_sequence_state (first_gesture, sequence) == GTK_EVENT_SEQUENCE_CLAIMED)
gtk_gesture_set_sequence_state (second_gesture, sequence, GTK_EVENT_SEQUENCE_DENIED);
}
If both gestures are in the same group, just set the state on the gesture emitting the event, the sequence will be already be initialized to the group's global state when the second gesture processes the event.
#state=(state) ⇒ Boolean
Sets the state of all sequences that gesture is currently interacting with.
Sequences start in state %GTK_EVENT_SEQUENCE_NONE, and whenever they change state, they can never go back to that state. Likewise, sequences in state %GTK_EVENT_SEQUENCE_DENIED cannot turn back to a not denied state. With these rules, the lifetime of an event sequence is constrained to the next four:
- None
- None → Denied
- None → Claimed
- None → Claimed → Denied
Note: Due to event handling ordering, it may be unsafe to set the state on another gesture within a [signalGtk.Gesture::begin] signal handler, as the callback might be executed before the other gesture knows about the sequence. A safe way to perform this could be:
static void
first_gesture_begin_cb (GtkGesture *first_gesture,
GdkEventSequence *sequence,
gpointer user_data)
{
gtk_gesture_set_state (first_gesture, GTK_EVENT_SEQUENCE_CLAIMED);
gtk_gesture_set_state (second_gesture, GTK_EVENT_SEQUENCE_DENIED);
}
static void
second_gesture_begin_cb (GtkGesture *second_gesture,
GdkEventSequence *sequence,
gpointer user_data)
{
if (gtk_gesture_get_sequence_state (first_gesture, sequence) == GTK_EVENT_SEQUENCE_CLAIMED)
gtk_gesture_set_state (second_gesture, GTK_EVENT_SEQUENCE_DENIED);
}
If both gestures are in the same group, just set the state on the gesture emitting the event, the sequence will be already be initialized to the group's global state when the second gesture processes the event.
#ungroup ⇒ nil
Separates gesture into an isolated group.