1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gtk.Gesture; 26 27 private import gdk.Device; 28 private import gdk.Event; 29 private import gdk.Window; 30 private import glib.ListG; 31 private import gobject.ObjectG; 32 private import gobject.Signals; 33 private import gtk.EventController; 34 public import gtkc.gdktypes; 35 private import gtkc.gtk; 36 public import gtkc.gtktypes; 37 38 39 /** 40 * #GtkGesture is the base object for gesture recognition, although this 41 * object is quite generalized to serve as a base for multi-touch gestures, 42 * it is suitable to implement single-touch and pointer-based gestures (using 43 * the special %NULL #GdkEventSequence value for these). 44 * 45 * The number of touches that a #GtkGesture need to be recognized is controlled 46 * by the #GtkGesture:n-points property, if a gesture is keeping track of less 47 * or more than that number of sequences, it won't check wether the gesture 48 * is recognized. 49 * 50 * As soon as the gesture has the expected number of touches, the gesture will 51 * run the #GtkGesture::check signal regularly on input events until the gesture 52 * is recognized, the criteria to consider a gesture as "recognized" is left to 53 * #GtkGesture subclasses. 54 * 55 * A recognized gesture will then emit the following signals: 56 * - #GtkGesture::begin when the gesture is recognized. 57 * - A number of #GtkGesture::update, whenever an input event is processed. 58 * - #GtkGesture::end when the gesture is no longer recognized. 59 * 60 * ## Event propagation 61 * 62 * In order to receive events, a gesture needs to either set a propagation phase 63 * through gtk_event_controller_set_propagation_phase(), or feed those manually 64 * through gtk_event_controller_handle_event(). 65 * 66 * In the capture phase, events are propagated from the toplevel down to the 67 * target widget, and gestures that are attached to containers above the widget 68 * get a chance to interact with the event before it reaches the target. 69 * 70 * After the capture phase, GTK+ emits the traditional #GtkWidget::button-press, 71 * #GtkWidget::button-release, #GtkWidget::touch-event, etc signals. Gestures 72 * with the %GTK_PHASE_TARGET phase are fed events from the default #GtkWidget::event 73 * handlers. 74 * 75 * In the bubble phase, events are propagated up from the target widget to the 76 * toplevel, and gestures that are attached to containers above the widget get 77 * a chance to interact with events that have not been handled yet. 78 * 79 * ## States of a sequence # {#touch-sequence-states} 80 * 81 * Whenever input interaction happens, a single event may trigger a cascade of 82 * #GtkGestures, both across the parents of the widget receiving the event and 83 * in parallel within an individual widget. It is a responsibility of the 84 * widgets using those gestures to set the state of touch sequences accordingly 85 * in order to enable cooperation of gestures around the #GdkEventSequences 86 * triggering those. 87 * 88 * Within a widget, gestures can be grouped through gtk_gesture_group(), 89 * grouped gestures synchronize the state of sequences, so calling 90 * gtk_gesture_set_sequence_state() on one will effectively propagate 91 * the state throughout the group. 92 * 93 * By default, all sequences start out in the #GTK_EVENT_SEQUENCE_NONE state, 94 * sequences in this state trigger the gesture event handler, but event 95 * propagation will continue unstopped by gestures. 96 * 97 * If a sequence enters into the #GTK_EVENT_SEQUENCE_DENIED state, the gesture 98 * group will effectively ignore the sequence, letting events go unstopped 99 * through the gesture, but the "slot" will still remain occupied while 100 * the touch is active. 101 * 102 * If a sequence enters in the #GTK_EVENT_SEQUENCE_CLAIMED state, the gesture 103 * group will grab all interaction on the sequence, by: 104 * - Setting the same sequence to #GTK_EVENT_SEQUENCE_DENIED on every other gesture 105 * group within the widget, and every gesture on parent widgets in the propagation 106 * chain. 107 * - calling #GtkGesture::cancel on every gesture in widgets underneath in the 108 * propagation chain. 109 * - Stopping event propagation after the gesture group handles the event. 110 * 111 * Note: if a sequence is set early to #GTK_EVENT_SEQUENCE_CLAIMED on 112 * #GDK_TOUCH_BEGIN/#GDK_BUTTON_PRESS (so those events are captured before 113 * reaching the event widget, this implies #GTK_PHASE_CAPTURE), one similar 114 * event will emulated if the sequence changes to #GTK_EVENT_SEQUENCE_DENIED. 115 * This way event coherence is preserved before event propagation is unstopped 116 * again. 117 * 118 * Sequence states can't be changed freely, see gtk_gesture_set_sequence_state() 119 * to know about the possible lifetimes of a #GdkEventSequence. 120 * 121 * ## Touchpad gestures 122 * 123 * On the platforms that support it, #GtkGesture will handle transparently 124 * touchpad gesture events. The only precautions users of #GtkGesture should do 125 * to enable this support are: 126 * - Enabling %GDK_TOUCHPAD_GESTURE_MASK on their #GdkWindows 127 * - If the gesture has %GTK_PHASE_NONE, ensuring events of type 128 * %GDK_TOUCHPAD_SWIPE and %GDK_TOUCHPAD_PINCH are handled by the #GtkGesture 129 */ 130 public class Gesture : EventController 131 { 132 /** the main Gtk struct */ 133 protected GtkGesture* gtkGesture; 134 135 /** Get the main Gtk struct */ 136 public GtkGesture* getGestureStruct() 137 { 138 return gtkGesture; 139 } 140 141 /** the main Gtk struct as a void* */ 142 protected override void* getStruct() 143 { 144 return cast(void*)gtkGesture; 145 } 146 147 protected override void setStruct(GObject* obj) 148 { 149 gtkGesture = cast(GtkGesture*)obj; 150 super.setStruct(obj); 151 } 152 153 /** 154 * Sets our main struct and passes it to the parent class. 155 */ 156 public this (GtkGesture* gtkGesture, bool ownedRef = false) 157 { 158 this.gtkGesture = gtkGesture; 159 super(cast(GtkEventController*)gtkGesture, ownedRef); 160 } 161 162 /** 163 */ 164 165 public static GType getType() 166 { 167 return gtk_gesture_get_type(); 168 } 169 170 /** 171 * If there are touch sequences being currently handled by @gesture, 172 * this function returns %TRUE and fills in @rect with the bounding 173 * box containing all active touches. Otherwise, %FALSE will be 174 * returned. 175 * 176 * Note: This function will yield unexpected results on touchpad 177 * gestures. Since there is no correlation between physical and 178 * pixel distances, these will look as if constrained in an 179 * infinitely small area, @rect width and height will thus be 0 180 * regardless of the number of touchpoints. 181 * 182 * Params: 183 * rect = bounding box containing all active touches. 184 * 185 * Return: %TRUE if there are active touches, %FALSE otherwise 186 * 187 * Since: 3.14 188 */ 189 public bool getBoundingBox(out GdkRectangle rect) 190 { 191 return gtk_gesture_get_bounding_box(gtkGesture, &rect) != 0; 192 } 193 194 /** 195 * If there are touch sequences being currently handled by @gesture, 196 * this function returns %TRUE and fills in @x and @y with the center 197 * of the bounding box containing all active touches. Otherwise, %FALSE 198 * will be returned. 199 * 200 * Params: 201 * x = X coordinate for the bounding box center 202 * y = Y coordinate for the bounding box center 203 * 204 * Return: %FALSE if no active touches are present, %TRUE otherwise 205 * 206 * Since: 3.14 207 */ 208 public bool getBoundingBoxCenter(out double x, out double y) 209 { 210 return gtk_gesture_get_bounding_box_center(gtkGesture, &x, &y) != 0; 211 } 212 213 /** 214 * Returns the master #GdkDevice that is currently operating 215 * on @gesture, or %NULL if the gesture is not being interacted. 216 * 217 * Return: a #GdkDevice, or %NULL 218 * 219 * Since: 3.14 220 */ 221 public Device getDevice() 222 { 223 auto p = gtk_gesture_get_device(gtkGesture); 224 225 if(p is null) 226 { 227 return null; 228 } 229 230 return ObjectG.getDObject!(Device)(cast(GdkDevice*) p); 231 } 232 233 /** 234 * Returns all gestures in the group of @gesture 235 * 236 * Return: The list 237 * of #GtkGestures, free with g_list_free() 238 * 239 * Since: 3.14 240 */ 241 public ListG getGroup() 242 { 243 auto p = gtk_gesture_get_group(gtkGesture); 244 245 if(p is null) 246 { 247 return null; 248 } 249 250 return new ListG(cast(GList*) p); 251 } 252 253 /** 254 * Returns the last event that was processed for @sequence. 255 * 256 * Params: 257 * sequence = a #GdkEventSequence 258 * 259 * Return: The last event from @sequence 260 */ 261 public Event getLastEvent(GdkEventSequence* sequence) 262 { 263 auto p = gtk_gesture_get_last_event(gtkGesture, sequence); 264 265 if(p is null) 266 { 267 return null; 268 } 269 270 return ObjectG.getDObject!(Event)(cast(GdkEvent*) p); 271 } 272 273 /** 274 * Returns the #GdkEventSequence that was last updated on @gesture. 275 * 276 * Return: The last updated sequence 277 * 278 * Since: 3.14 279 */ 280 public GdkEventSequence* getLastUpdatedSequence() 281 { 282 return gtk_gesture_get_last_updated_sequence(gtkGesture); 283 } 284 285 /** 286 * If @sequence is currently being interpreted by @gesture, this 287 * function returns %TRUE and fills in @x and @y with the last coordinates 288 * stored for that event sequence. The coordinates are always relative to the 289 * widget allocation. 290 * 291 * Params: 292 * sequence = a #GdkEventSequence, or %NULL for pointer events 293 * x = return location for X axis of the sequence coordinates 294 * y = return location for Y axis of the sequence coordinates 295 * 296 * Return: %TRUE if @sequence is currently interpreted 297 * 298 * Since: 3.14 299 */ 300 public bool getPoint(GdkEventSequence* sequence, out double x, out double y) 301 { 302 return gtk_gesture_get_point(gtkGesture, sequence, &x, &y) != 0; 303 } 304 305 /** 306 * Returns the @sequence state, as seen by @gesture. 307 * 308 * Params: 309 * sequence = a #GdkEventSequence 310 * 311 * Return: The sequence state in @gesture 312 * 313 * Since: 3.14 314 */ 315 public GtkEventSequenceState getSequenceState(GdkEventSequence* sequence) 316 { 317 return gtk_gesture_get_sequence_state(gtkGesture, sequence); 318 } 319 320 /** 321 * Returns the list of #GdkEventSequences currently being interpreted 322 * by @gesture. 323 * 324 * Return: A list 325 * of #GdkEventSequences, the list elements are owned by GTK+ 326 * and must not be freed or modified, the list itself must be deleted 327 * through g_list_free() 328 * 329 * Since: 3.14 330 */ 331 public ListG getSequences() 332 { 333 auto p = gtk_gesture_get_sequences(gtkGesture); 334 335 if(p is null) 336 { 337 return null; 338 } 339 340 return new ListG(cast(GList*) p); 341 } 342 343 /** 344 * Returns the user-defined window that receives the events 345 * handled by @gesture. See gtk_gesture_set_window() for more 346 * information. 347 * 348 * Return: the user defined window, or %NULL if none 349 * 350 * Since: 3.14 351 */ 352 public Window getWindow() 353 { 354 auto p = gtk_gesture_get_window(gtkGesture); 355 356 if(p is null) 357 { 358 return null; 359 } 360 361 return ObjectG.getDObject!(Window)(cast(GdkWindow*) p); 362 } 363 364 /** 365 * Adds @gesture to the same group than @group_gesture. Gestures 366 * are by default isolated in their own groups. 367 * 368 * When gestures are grouped, the state of #GdkEventSequences 369 * is kept in sync for all of those, so calling gtk_gesture_set_sequence_state(), 370 * on one will transfer the same value to the others. 371 * 372 * Groups also perform an "implicit grabbing" of sequences, if a 373 * #GdkEventSequence state is set to #GTK_EVENT_SEQUENCE_CLAIMED on one group, 374 * every other gesture group attached to the same #GtkWidget will switch the 375 * state for that sequence to #GTK_EVENT_SEQUENCE_DENIED. 376 * 377 * Params: 378 * gesture = a #GtkGesture 379 * 380 * Since: 3.14 381 */ 382 public void group(Gesture gesture) 383 { 384 gtk_gesture_group(gtkGesture, (gesture is null) ? null : gesture.getGestureStruct()); 385 } 386 387 /** 388 * Returns %TRUE if @gesture is currently handling events corresponding to 389 * @sequence. 390 * 391 * Params: 392 * sequence = a #GdkEventSequence 393 * 394 * Return: %TRUE if @gesture is handling @sequence 395 * 396 * Since: 3.14 397 */ 398 public bool handlesSequence(GdkEventSequence* sequence) 399 { 400 return gtk_gesture_handles_sequence(gtkGesture, sequence) != 0; 401 } 402 403 /** 404 * Returns %TRUE if the gesture is currently active. 405 * A gesture is active meanwhile there are touch sequences 406 * interacting with it. 407 * 408 * Return: %TRUE if gesture is active 409 * 410 * Since: 3.14 411 */ 412 public bool isActive() 413 { 414 return gtk_gesture_is_active(gtkGesture) != 0; 415 } 416 417 /** 418 * Returns %TRUE if both gestures pertain to the same group. 419 * 420 * Params: 421 * other = another #GtkGesture 422 * 423 * Return: whether the gestures are grouped 424 * 425 * Since: 3.14 426 */ 427 public bool isGroupedWith(Gesture other) 428 { 429 return gtk_gesture_is_grouped_with(gtkGesture, (other is null) ? null : other.getGestureStruct()) != 0; 430 } 431 432 /** 433 * Returns %TRUE if the gesture is currently recognized. 434 * A gesture is recognized if there are as many interacting 435 * touch sequences as required by @gesture, and #GtkGesture::check 436 * returned %TRUE for the sequences being currently interpreted. 437 * 438 * Return: %TRUE if gesture is recognized 439 * 440 * Since: 3.14 441 */ 442 public bool isRecognized() 443 { 444 return gtk_gesture_is_recognized(gtkGesture) != 0; 445 } 446 447 /** 448 * Sets the state of @sequence in @gesture. Sequences start 449 * in state #GTK_EVENT_SEQUENCE_NONE, and whenever they change 450 * state, they can never go back to that state. Likewise, 451 * sequences in state #GTK_EVENT_SEQUENCE_DENIED cannot turn 452 * back to a not denied state. With these rules, the lifetime 453 * of an event sequence is constrained to the next four: 454 * 455 * * None 456 * * None → Denied 457 * * None → Claimed 458 * * None → Claimed → Denied 459 * 460 * Note: Due to event handling ordering, it may be unsafe to 461 * set the state on another gesture within a #GtkGesture::begin 462 * signal handler, as the callback might be executed before 463 * the other gesture knows about the sequence. A safe way to 464 * perform this could be: 465 * 466 * |[ 467 * static void 468 * first_gesture_begin_cb (GtkGesture *first_gesture, 469 * GdkEventSequence *sequence, 470 * gpointer user_data) 471 * { 472 * gtk_gesture_set_sequence_state (first_gesture, sequence, GTK_EVENT_SEQUENCE_ACCEPTED); 473 * gtk_gesture_set_sequence_state (second_gesture, sequence, GTK_EVENT_SEQUENCE_DENIED); 474 * } 475 * 476 * static void 477 * second_gesture_begin_cb (GtkGesture *second_gesture, 478 * GdkEventSequence *sequence, 479 * gpointer user_data) 480 * { 481 * if (gtk_gesture_get_sequence_state (first_gesture, sequence) == GTK_EVENT_SEQUENCE_ACCEPTED) 482 * gtk_gesture_set_sequence_state (second_gesture, sequence, GTK_EVENT_SEQUENCE_DENIED); 483 * } 484 * ]| 485 * 486 * If both gestures are in the same group, just set the state on 487 * the gesture emitting the event, the sequence will be already 488 * be initialized to the group's global state when the second 489 * gesture processes the event. 490 * 491 * Params: 492 * sequence = a #GdkEventSequence 493 * state = the sequence state 494 * 495 * Return: %TRUE if @sequence is handled by @gesture, 496 * and the state is changed successfully 497 * 498 * Since: 3.14 499 */ 500 public bool setSequenceState(GdkEventSequence* sequence, GtkEventSequenceState state) 501 { 502 return gtk_gesture_set_sequence_state(gtkGesture, sequence, state) != 0; 503 } 504 505 /** 506 * Sets the state of all sequences that @gesture is currently 507 * interacting with. See gtk_gesture_set_sequence_state() 508 * for more details on sequence states. 509 * 510 * Params: 511 * state = the sequence state 512 * 513 * Return: %TRUE if the state of at least one sequence 514 * was changed successfully 515 * 516 * Since: 3.14 517 */ 518 public bool setState(GtkEventSequenceState state) 519 { 520 return gtk_gesture_set_state(gtkGesture, state) != 0; 521 } 522 523 /** 524 * Sets a specific window to receive events about, so @gesture 525 * will effectively handle only events targeting @window, or 526 * a child of it. @window must pertain to gtk_event_controller_get_widget(). 527 * 528 * Params: 529 * window = a #GdkWindow, or %NULL 530 * 531 * Since: 3.14 532 */ 533 public void setWindow(Window window) 534 { 535 gtk_gesture_set_window(gtkGesture, (window is null) ? null : window.getWindowStruct()); 536 } 537 538 /** 539 * Separates @gesture into an isolated group. 540 * 541 * Since: 3.14 542 */ 543 public void ungroup() 544 { 545 gtk_gesture_ungroup(gtkGesture); 546 } 547 548 int[string] connectedSignals; 549 550 void delegate(GdkEventSequence*, Gesture)[] onBeginListeners; 551 /** 552 * This signal is emitted when the gesture is recognized. This means the 553 * number of touch sequences matches #GtkGesture:n-points, and the #GtkGesture::check 554 * handler(s) returned #TRUE. 555 * 556 * Note: These conditions may also happen when an extra touch (eg. a third touch 557 * on a 2-touches gesture) is lifted, in that situation @sequence won't pertain 558 * to the current set of active touches, so don't rely on this being true. 559 * 560 * Params: 561 * sequence = the #GdkEventSequence that made the gesture to be recognized 562 * 563 * Since: 3.14 564 */ 565 void addOnBegin(void delegate(GdkEventSequence*, Gesture) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 566 { 567 if ( "begin" !in connectedSignals ) 568 { 569 Signals.connectData( 570 this, 571 "begin", 572 cast(GCallback)&callBackBegin, 573 cast(void*)this, 574 null, 575 connectFlags); 576 connectedSignals["begin"] = 1; 577 } 578 onBeginListeners ~= dlg; 579 } 580 extern(C) static void callBackBegin(GtkGesture* gestureStruct, GdkEventSequence* sequence, Gesture _gesture) 581 { 582 foreach ( void delegate(GdkEventSequence*, Gesture) dlg; _gesture.onBeginListeners ) 583 { 584 dlg(sequence, _gesture); 585 } 586 } 587 588 void delegate(Event, Gesture)[] onBeginGenericListeners; 589 /** 590 * This signal is emitted when the gesture is recognized. This means the 591 * number of touch sequences matches #GtkGesture:n-points, and the #GtkGesture::check 592 * handler(s) returned #TRUE. 593 * 594 * Note: These conditions may also happen when an extra touch (eg. a third touch 595 * on a 2-touches gesture) is lifted, in that situation @sequence won't pertain 596 * to the current set of active touches, so don't rely on this being true. 597 * 598 * Params: 599 * sequence = the #GdkEventSequence that made the gesture to be recognized 600 * 601 * Since: 3.14 602 */ 603 void addOnBegin(void delegate(Event, Gesture) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 604 { 605 if ( "begin-generic-event" !in connectedSignals ) 606 { 607 Signals.connectData( 608 this, 609 "begin", 610 cast(GCallback)&callBackBeginGeneric, 611 cast(void*)this, 612 null, 613 connectFlags); 614 connectedSignals["begin-generic-event"] = 1; 615 } 616 onBeginGenericListeners ~= dlg; 617 } 618 extern(C) static void callBackBeginGeneric(GtkGesture* gestureStruct, GdkEvent* sequence, Gesture _gesture) 619 { 620 foreach ( void delegate(Event, Gesture) dlg; _gesture.onBeginGenericListeners ) 621 { 622 dlg(ObjectG.getDObject!(Event)(sequence), _gesture); 623 } 624 } 625 626 void delegate(GdkEventSequence*, Gesture)[] onCancelListeners; 627 /** 628 * This signal is emitted whenever a sequence is cancelled. This usually 629 * happens on active touches when gtk_event_controller_reset() is called 630 * on @gesture (manually, due to grabs...), or the individual @sequence 631 * was claimed by parent widgets' controllers (see gtk_gesture_set_sequence_state()). 632 * 633 * @gesture must forget everything about @sequence as a reaction to this signal. 634 * 635 * Params: 636 * sequence = the #GdkEventSequence that was cancelled 637 * 638 * Since: 3.14 639 */ 640 void addOnCancel(void delegate(GdkEventSequence*, Gesture) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 641 { 642 if ( "cancel" !in connectedSignals ) 643 { 644 Signals.connectData( 645 this, 646 "cancel", 647 cast(GCallback)&callBackCancel, 648 cast(void*)this, 649 null, 650 connectFlags); 651 connectedSignals["cancel"] = 1; 652 } 653 onCancelListeners ~= dlg; 654 } 655 extern(C) static void callBackCancel(GtkGesture* gestureStruct, GdkEventSequence* sequence, Gesture _gesture) 656 { 657 foreach ( void delegate(GdkEventSequence*, Gesture) dlg; _gesture.onCancelListeners ) 658 { 659 dlg(sequence, _gesture); 660 } 661 } 662 663 void delegate(Event, Gesture)[] onCancelGenericListeners; 664 /** 665 * This signal is emitted whenever a sequence is cancelled. This usually 666 * happens on active touches when gtk_event_controller_reset() is called 667 * on @gesture (manually, due to grabs...), or the individual @sequence 668 * was claimed by parent widgets' controllers (see gtk_gesture_set_sequence_state()). 669 * 670 * @gesture must forget everything about @sequence as a reaction to this signal. 671 * 672 * Params: 673 * sequence = the #GdkEventSequence that was cancelled 674 * 675 * Since: 3.14 676 */ 677 void addOnCancel(void delegate(Event, Gesture) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 678 { 679 if ( "cancel-generic-event" !in connectedSignals ) 680 { 681 Signals.connectData( 682 this, 683 "cancel", 684 cast(GCallback)&callBackCancelGeneric, 685 cast(void*)this, 686 null, 687 connectFlags); 688 connectedSignals["cancel-generic-event"] = 1; 689 } 690 onCancelGenericListeners ~= dlg; 691 } 692 extern(C) static void callBackCancelGeneric(GtkGesture* gestureStruct, GdkEvent* sequence, Gesture _gesture) 693 { 694 foreach ( void delegate(Event, Gesture) dlg; _gesture.onCancelGenericListeners ) 695 { 696 dlg(ObjectG.getDObject!(Event)(sequence), _gesture); 697 } 698 } 699 700 void delegate(GdkEventSequence*, Gesture)[] onEndListeners; 701 /** 702 * This signal is emitted when @gesture either stopped recognizing the event 703 * sequences as something to be handled (the #GtkGesture::check handler returned 704 * %FALSE), or the number of touch sequences became higher or lower than 705 * #GtkGesture:n-points. 706 * 707 * Note: @sequence might not pertain to the group of sequences that were 708 * previously triggering recognition on @gesture (ie. a just pressed touch 709 * sequence that exceeds #GtkGesture:n-points). This situation may be detected 710 * by checking through gtk_gesture_handles_sequence(). 711 * 712 * Params: 713 * sequence = the #GdkEventSequence that made gesture recognition to finish 714 * 715 * Since: 3.14 716 */ 717 void addOnEnd(void delegate(GdkEventSequence*, Gesture) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 718 { 719 if ( "end" !in connectedSignals ) 720 { 721 Signals.connectData( 722 this, 723 "end", 724 cast(GCallback)&callBackEnd, 725 cast(void*)this, 726 null, 727 connectFlags); 728 connectedSignals["end"] = 1; 729 } 730 onEndListeners ~= dlg; 731 } 732 extern(C) static void callBackEnd(GtkGesture* gestureStruct, GdkEventSequence* sequence, Gesture _gesture) 733 { 734 foreach ( void delegate(GdkEventSequence*, Gesture) dlg; _gesture.onEndListeners ) 735 { 736 dlg(sequence, _gesture); 737 } 738 } 739 740 void delegate(Event, Gesture)[] onEndGenericListeners; 741 /** 742 * This signal is emitted when @gesture either stopped recognizing the event 743 * sequences as something to be handled (the #GtkGesture::check handler returned 744 * %FALSE), or the number of touch sequences became higher or lower than 745 * #GtkGesture:n-points. 746 * 747 * Note: @sequence might not pertain to the group of sequences that were 748 * previously triggering recognition on @gesture (ie. a just pressed touch 749 * sequence that exceeds #GtkGesture:n-points). This situation may be detected 750 * by checking through gtk_gesture_handles_sequence(). 751 * 752 * Params: 753 * sequence = the #GdkEventSequence that made gesture recognition to finish 754 * 755 * Since: 3.14 756 */ 757 void addOnEnd(void delegate(Event, Gesture) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 758 { 759 if ( "end-generic-event" !in connectedSignals ) 760 { 761 Signals.connectData( 762 this, 763 "end", 764 cast(GCallback)&callBackEndGeneric, 765 cast(void*)this, 766 null, 767 connectFlags); 768 connectedSignals["end-generic-event"] = 1; 769 } 770 onEndGenericListeners ~= dlg; 771 } 772 extern(C) static void callBackEndGeneric(GtkGesture* gestureStruct, GdkEvent* sequence, Gesture _gesture) 773 { 774 foreach ( void delegate(Event, Gesture) dlg; _gesture.onEndGenericListeners ) 775 { 776 dlg(ObjectG.getDObject!(Event)(sequence), _gesture); 777 } 778 } 779 780 void delegate(GdkEventSequence*, GtkEventSequenceState, Gesture)[] onSequenceStateChangedListeners; 781 /** 782 * This signal is emitted whenever a sequence state changes. See 783 * gtk_gesture_set_sequence_state() to know more about the expectable 784 * sequence lifetimes. 785 * 786 * Params: 787 * sequence = the #GdkEventSequence that was cancelled 788 * state = the new sequence state 789 * 790 * Since: 3.14 791 */ 792 void addOnSequenceStateChanged(void delegate(GdkEventSequence*, GtkEventSequenceState, Gesture) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 793 { 794 if ( "sequence-state-changed" !in connectedSignals ) 795 { 796 Signals.connectData( 797 this, 798 "sequence-state-changed", 799 cast(GCallback)&callBackSequenceStateChanged, 800 cast(void*)this, 801 null, 802 connectFlags); 803 connectedSignals["sequence-state-changed"] = 1; 804 } 805 onSequenceStateChangedListeners ~= dlg; 806 } 807 extern(C) static void callBackSequenceStateChanged(GtkGesture* gestureStruct, GdkEventSequence* sequence, GtkEventSequenceState state, Gesture _gesture) 808 { 809 foreach ( void delegate(GdkEventSequence*, GtkEventSequenceState, Gesture) dlg; _gesture.onSequenceStateChangedListeners ) 810 { 811 dlg(sequence, state, _gesture); 812 } 813 } 814 815 void delegate(Event, GtkEventSequenceState, Gesture)[] onSequenceStateChangedGenericListeners; 816 /** 817 * This signal is emitted whenever a sequence state changes. See 818 * gtk_gesture_set_sequence_state() to know more about the expectable 819 * sequence lifetimes. 820 * 821 * Params: 822 * sequence = the #GdkEventSequence that was cancelled 823 * state = the new sequence state 824 * 825 * Since: 3.14 826 */ 827 void addOnSequenceStateChanged(void delegate(Event, GtkEventSequenceState, Gesture) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 828 { 829 if ( "sequence-state-changed-generic-event" !in connectedSignals ) 830 { 831 Signals.connectData( 832 this, 833 "sequence-state-changed", 834 cast(GCallback)&callBackSequenceStateChangedGeneric, 835 cast(void*)this, 836 null, 837 connectFlags); 838 connectedSignals["sequence-state-changed-generic-event"] = 1; 839 } 840 onSequenceStateChangedGenericListeners ~= dlg; 841 } 842 extern(C) static void callBackSequenceStateChangedGeneric(GtkGesture* gestureStruct, GdkEvent* sequence, GtkEventSequenceState state, Gesture _gesture) 843 { 844 foreach ( void delegate(Event, GtkEventSequenceState, Gesture) dlg; _gesture.onSequenceStateChangedGenericListeners ) 845 { 846 dlg(ObjectG.getDObject!(Event)(sequence), state, _gesture); 847 } 848 } 849 850 void delegate(GdkEventSequence*, Gesture)[] onUpdateListeners; 851 /** 852 * This signal is emitted whenever an event is handled while the gesture is 853 * recognized. @sequence is guaranteed to pertain to the set of active touches. 854 * 855 * Params: 856 * sequence = the #GdkEventSequence that was updated 857 * 858 * Since: 3.14 859 */ 860 void addOnUpdate(void delegate(GdkEventSequence*, Gesture) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 861 { 862 if ( "update" !in connectedSignals ) 863 { 864 Signals.connectData( 865 this, 866 "update", 867 cast(GCallback)&callBackUpdate, 868 cast(void*)this, 869 null, 870 connectFlags); 871 connectedSignals["update"] = 1; 872 } 873 onUpdateListeners ~= dlg; 874 } 875 extern(C) static void callBackUpdate(GtkGesture* gestureStruct, GdkEventSequence* sequence, Gesture _gesture) 876 { 877 foreach ( void delegate(GdkEventSequence*, Gesture) dlg; _gesture.onUpdateListeners ) 878 { 879 dlg(sequence, _gesture); 880 } 881 } 882 883 void delegate(Event, Gesture)[] onUpdateGenericListeners; 884 /** 885 * This signal is emitted whenever an event is handled while the gesture is 886 * recognized. @sequence is guaranteed to pertain to the set of active touches. 887 * 888 * Params: 889 * sequence = the #GdkEventSequence that was updated 890 * 891 * Since: 3.14 892 */ 893 void addOnUpdate(void delegate(Event, Gesture) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 894 { 895 if ( "update-generic-event" !in connectedSignals ) 896 { 897 Signals.connectData( 898 this, 899 "update", 900 cast(GCallback)&callBackUpdateGeneric, 901 cast(void*)this, 902 null, 903 connectFlags); 904 connectedSignals["update-generic-event"] = 1; 905 } 906 onUpdateGenericListeners ~= dlg; 907 } 908 extern(C) static void callBackUpdateGeneric(GtkGesture* gestureStruct, GdkEvent* sequence, Gesture _gesture) 909 { 910 foreach ( void delegate(Event, Gesture) dlg; _gesture.onUpdateGenericListeners ) 911 { 912 dlg(ObjectG.getDObject!(Event)(sequence), _gesture); 913 } 914 } 915 }