nsIDOMSimpleGestureEvent.idl 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "nsIDOMMouseEvent.idl"
  6. /**
  7. * The nsIDOMSimpleGestureEvent interface is the datatype for all
  8. * Mozilla-specific simple gesture events in the Document Object Model.
  9. *
  10. * The following events are generated:
  11. *
  12. * MozSwipeGestureMayStart - Generated when the user starts a horizontal
  13. * swipe across the input device, but before we know whether the user
  14. * is actually scrolling past a scroll edge.
  15. * This event asks two questions: Should a swipe really be started, and
  16. * in which directions should the user be able to swipe? The first
  17. * question is answered by event listeners by calling or not calling
  18. * preventDefault() on the event. Since a swipe swallows all scroll
  19. * events, the default action of the swipe start event is *not* to
  20. * start a swipe. Call preventDefault() if you want a swipe to be
  21. * started. Doing so won't necessarily result in a swipe being started,
  22. * it only communicates an intention. Once Gecko determines whether a
  23. * swipe should actually be started, it will send a MozSwipeGestureStart
  24. * event.
  25. * The second question (swipe-able directions) is answered in the
  26. * allowedDirections field.
  27. *
  28. * MozSwipeGestureStart - This event signals the start of a swipe.
  29. * It guarantees a future MozSwipeGestureEnd event that will signal
  30. * the end of a swipe animation.
  31. *
  32. * MozSwipeGestureUpdate - Generated periodically while the user is
  33. * continuing a horizontal swipe gesture. The "delta" value represents
  34. * the current absolute gesture amount. This event may even be sent
  35. * after a MozSwipeGesture event fired in order to allow for fluid
  36. * completion of a swipe animation. The direction value is meaningless
  37. * on swipe update events.
  38. *
  39. * MozSwipeGestureEnd - Generated when the swipe animation is completed.
  40. *
  41. * MozSwipeGesture - Generated when the user releases a swipe across
  42. * across the input device. This event signals that the actual swipe
  43. * operation is complete, even though the animation might not be finished
  44. * yet. This event can be sent without accompanying start / update / end
  45. * events, and it can also be handled on its own if the consumer doesn't
  46. * want to handle swipe animation events.
  47. * Only the direction value has any significance, the delta value is
  48. * meaningless.
  49. *
  50. * MozMagnifyGestureStart - Generated when the user begins the magnify
  51. * ("pinch") gesture. The "delta" value represents the initial
  52. * movement.
  53. *
  54. * MozMagnifyGestureUpdate - Generated periodically while the user is
  55. * continuing the magnify ("pinch") gesture. The "delta" value
  56. * represents the movement since the last MozMagnifyGestureStart or
  57. * MozMagnifyGestureUpdate event.
  58. *
  59. * MozMagnifyGesture - Generated when the user has completed the
  60. * magnify ("pinch") gesture. If you only want to receive a single
  61. * event when the magnify gesture is complete, you only need to hook
  62. * this event and can safely ignore the MozMagnifyGestureStart and the
  63. * MozMagnifyGestureUpdate events. The "delta" value is the cumulative
  64. * amount represented by the user's gesture.
  65. *
  66. * MozRotateGestureStart - Generated when the user begins the rotation
  67. * gesture. The "delta" value represents the initial rotation.
  68. *
  69. * MozRotateGestureUpdate - Generated periodically while the user is
  70. * continuing the rotation gesture. The "delta" value represents the
  71. * rotation since the last MozRotateGestureStart or
  72. * MozRotateGestureUpdate event.
  73. *
  74. * MozRotateGesture - Generated when the user has completed the
  75. * rotation gesture. If you only want to receive a single event when
  76. * the rotation gesture is complete, you only need to hook this event
  77. * and can safely ignore the MozRotateGestureStart and the
  78. * MozRotateGestureUpdate events. The "delta" value is the cumulative
  79. * amount of rotation represented by the user's gesture.
  80. *
  81. * MozTapGesture - Generated when the user executes a two finger
  82. * tap gesture on the input device. Client coordinates contain the
  83. * center point of the tap.
  84. * (XXX On OS X, only Lion (10.7) and up)
  85. *
  86. * MozPressTapGesture - Generated when the user executes a press
  87. * and tap two finger gesture (first finger down, second finger down,
  88. * second finger up, first finger up) on the input device.
  89. * Client coordinates contain the center pivot point of the action.
  90. * (XXX Not implemented on Mac)
  91. *
  92. * MozEdgeUIGesture - Generated when the user swipes the display to
  93. * invoke edge ui.
  94. * (XXX Win8 only)
  95. *
  96. * Default behavior:
  97. *
  98. * Some operating systems support default behaviors for gesture events
  99. * when they are not handled by the application. Consumers should
  100. * use event.preventDefault() to prevent default behavior when
  101. * consuming events.
  102. */
  103. [builtinclass, uuid(c397f9a2-4266-4291-b282-3efd6d7afc57)]
  104. interface nsIDOMSimpleGestureEvent : nsIDOMMouseEvent
  105. {
  106. /* Swipe direction constants */
  107. const unsigned long DIRECTION_UP = 1;
  108. const unsigned long DIRECTION_DOWN = 2;
  109. const unsigned long DIRECTION_LEFT = 4;
  110. const unsigned long DIRECTION_RIGHT = 8;
  111. /* Rotational direction constants */
  112. const unsigned long ROTATION_COUNTERCLOCKWISE = 1;
  113. const unsigned long ROTATION_CLOCKWISE = 2;
  114. /* Read-write value for swipe events.
  115. *
  116. * Reports the directions that can be swiped to; multiple directions
  117. * should be OR'ed together.
  118. *
  119. * The allowedDirections field is designed to be set on SwipeGestureMayStart
  120. * events by event listeners. Its value after event dispatch determines
  121. * the behavior of the swipe animation that might be about to begin.
  122. * Specifically, if the user swipes in a direction that can't be swiped
  123. * to, the animation will have a bounce effect.
  124. * Future SwipeGestureUpdate, SwipeGesture and SwipeGestureEnd events
  125. * will carry the allowDirections value that was set on the SwipeMayStart
  126. * event. Changing this field on non-SwipeGestureMayStart events doesn't
  127. * have any effect.
  128. */
  129. attribute unsigned long allowedDirections;
  130. /* Direction of a gesture. Diagonals are indicated by OR'ing the
  131. * applicable constants together.
  132. *
  133. * Swipes gestures may occur in any direction.
  134. *
  135. * Magnify gestures do not have a direction.
  136. *
  137. * Rotation gestures will be either ROTATION_COUNTERCLOCKWISE or
  138. * ROTATION_CLOCKWISE.
  139. */
  140. readonly attribute unsigned long direction;
  141. /* Delta value for magnify, rotate and swipe gestures.
  142. *
  143. * For rotation, the value is in degrees and is positive for
  144. * clockwise rotation and negative for counterclockwise
  145. * rotation.
  146. *
  147. * For magnification, the value will be positive for a "zoom in"
  148. * (i.e, increased magnification) and negative for a "zoom out"
  149. * (i.e., decreased magnification). The particular units
  150. * represented by the "delta" are currently implementation specific.
  151. *
  152. * XXX - The units for measuring magnification are currently
  153. * unspecified because the units used by Mac OS X are currently
  154. * undocumented. The values are typically in the range of 0.0 to
  155. * 100.0, but it is only safe currently to rely on the delta being
  156. * positive or negative.
  157. *
  158. * For swipe start, update and end events, the value is a fraction
  159. * of one "page". If the resulting swipe will have DIRECTION_LEFT, the
  160. * delta value will be positive; for DIRECTION_RIGHT, delta is negative.
  161. * If this seems backwards to you, look at it this way: If the current
  162. * page is pushed to the right during the animation (positive delta),
  163. * the page left to the current page will be visible after the swipe
  164. * (DIRECTION_LEFT).
  165. *
  166. * Units on Windows represent the difference between the initial
  167. * and current/final width between the two touch points on the input
  168. * device and are measured in pixels.
  169. */
  170. readonly attribute double delta;
  171. /* Click count value for taps. */
  172. readonly attribute unsigned long clickCount;
  173. };