Class: Gtk::Gesture

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Instance Method Summary collapse

Instance Method Details

#deviceGdk::Device

Returns the master Gdk::Device that is currently operating on gesture, or nil if the gesture is not being interacted.

Returns:

#get_bounding_box(rect) ⇒ TrueClass

If there are touch sequences being currently handled by gesture, this function 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.

Parameters:

  • rect (Gdk::Rectangle)

    bounding box containing all active touches.

Returns:

  • (TrueClass)

    true if there are active touches, false otherwise

#get_bounding_box_center(x, y) ⇒ TrueClass

If there are touch sequences being currently handled by gesture, this function returns true and fills in x and y with the center of the bounding box containing all active touches. Otherwise, false will be returned.

Parameters:

  • x (Float)

    X coordinate for the bounding box center

  • y (Float)

    Y coordinate for the bounding box center

Returns:

  • (TrueClass)

    false if no active touches are present, true otherwise

#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.

Parameters:

  • sequence (Gdk::EventSequence)

    a Gdk::EventSequence

Returns:

  • (Gdk::Event)

    The last event from sequence

#get_point(sequence, x, y) ⇒ TrueClass

If sequence is currently being interpreted by gesture, this function 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.

Parameters:

  • sequence (Gdk::EventSequence)

    a Gdk::EventSequence, or nil for pointer events

  • x (Float)

    return location for X axis of the sequence coordinates

  • y (Float)

    return location for Y axis of the sequence coordinates

Returns:

  • (TrueClass)

    true if sequence is currently interpreted

#get_sequence_state(sequence) ⇒ Gtk::EventSequenceState

Returns the sequence state, as seen by gesture.

Parameters:

  • sequence (Gdk::EventSequence)

    a Gdk::EventSequence

Returns:

#group(gesture) ⇒ nil

Adds gesture to the same group than group_gesture. Gestures are by default isolated in their own groups.

When gestures are grouped, the state of Gdk::EventSequences is kept in sync for all of those, so calling gtk_gesture_set_sequence_state(), on one will transfer the same value to the others.

Groups also perform an “implicit grabbing” of sequences, if a Gdk::EventSequence state is set to #GTK_EVENT_SEQUENCE_CLAIMED on one group, every other gesture group attached to the same Gtk::Widget will switch the state for that sequence to #GTK_EVENT_SEQUENCE_DENIED.

Parameters:

Returns:

  • (nil)

#handles_sequence(sequence) ⇒ TrueClass

Returns true if gesture is currently handling events corresponding to sequence.

Parameters:

  • sequence (Gdk::EventSequence)

    a Gdk::EventSequence or nil

Returns:

  • (TrueClass)

    true if gesture is handling sequence, false otherwise

#is_activeTrueClass

Returns true if the gesture is currently active. A gesture is active meanwhile there are touch sequences interacting with it.

Returns:

  • (TrueClass)

    true if gesture is active

#is_grouped_with(other) ⇒ TrueClass

Returns true if both gestures pertain to the same group.

Parameters:

Returns:

  • (TrueClass)

    whether the gestures are grouped

#is_recognizedTrueClass

Returns true if the gesture is currently recognized. A gesture is recognized if there are as many interacting touch sequences as required by gesture, and Gtk::Gesture::check returned true for the sequences being currently interpreted.

Returns:

  • (TrueClass)

    true if gesture is recognized

#last_updated_sequenceGdk::EventSequence

Returns the Gdk::EventSequence that was last updated on gesture.

Returns:

  • (Gdk::EventSequence)

    The last updated sequence

#n_pointsInteger

The number of touch points that trigger recognition on this gesture,

Returns:

  • (Integer)

    n-points

#n_points=(n_points) ⇒ Integer

The number of touch points that trigger recognition on this gesture,

Parameters:

  • n_points (Integer)

Returns:

  • (Integer)

    n-points

  • (Integer)

    n-points

#sequencesGLib::List

Returns the list of Gdk::EventSequences currently being interpreted by gesture.

Returns:

  • (GLib::List)

    A list of Gdk::EventSequences, the list elements are owned by GTK+ and must not be freed or modified, the list itself must be deleted through g_list_free()

#set_sequence_state(sequence, state) ⇒ TrueClass

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 Gtk::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.

Parameters:

Returns:

  • (TrueClass)

    true if sequence is handled by gesture, and the state is changed successfully

#state=(state) ⇒ TrueClass

Sets the state of all sequences that gesture is currently interacting with. See gtk_gesture_set_sequence_state() for more details on sequence states.

Parameters:

Returns:

  • (TrueClass)

    true if the state of at least one sequence was changed successfully

#ungroupnil

Separates gesture into an isolated group.

Returns:

  • (nil)

#windowGdk::Window

If non-nil, the gesture will only listen for events that happen on this Gdk::Window, or a child of it.

Returns:

#window=(window) ⇒ Gdk::Window

If non-nil, the gesture will only listen for events that happen on this Gdk::Window, or a child of it.

Parameters:

Returns: