Scoop API

scoop:scoop.window:0.1.0

src/input/gesture.scoop

Selected production source · src/input/gesture.scoop

1package scoop.window
3/** A phase supplied by the native recognizer; None is an independent event. */
4public enum GesturePhase {
5 None, Began, Changed, Ended, Cancelled
6}
8/** Kinds of system-recognized gestures, independent of application recognizers. */
9public enum GestureKind {
10 Magnify, Rotate, Swipe
13/**
14 * Magnify multiplies the current scale by (1 + delta). Rotate carries clockwise
15 * radians. Swipe carries a discrete direction, positive right/down, not a pixel
16 * distance. The positional state does not change mouse buttons or create touch
17 * contacts. Device identity remains unknown when the platform cannot provide it.
18 */
19public enum GestureEvent {
20 Magnify(PointerState, GesturePhase, Double),
21 Rotate(PointerState, GesturePhase, Double),
22 Swipe(PointerState, Double, Double)
25public val GestureEvent.kind: GestureKind get() =
26 when (this) {
27 case Magnify(_, _, _) -> GestureKind.Magnify
28 case Rotate(_, _, _) -> GestureKind.Rotate
29 case Swipe(_, _, _) -> GestureKind.Swipe
30 }
32public val GestureEvent.state: PointerState get() =
33 when (this) {
34 case Magnify(val value, _, _) -> value
35 case Rotate(val value, _, _) -> value
36 case Swipe(val value, _, _) -> value
37 }
39/** Swipe is always discrete and has no continuous sequence phase. */
40public val GestureEvent.phase: GesturePhase get() =
41 when (this) {
42 case Magnify(_, val value, _) -> value
43 case Rotate(_, val value, _) -> value
44 case Swipe(_, _, _) -> GesturePhase.None
45 }