scoop:scoop.window:0.1.0
src/input/gesture.scoop
Selected production source · src/input/gesture.scoop
1
package scoop.window3
/** A phase supplied by the native recognizer; None is an independent event. */4
public enum GesturePhase {5
None, Began, Changed, Ended, Cancelled6
}8
/** Kinds of system-recognized gestures, independent of application recognizers. */9
public enum GestureKind {10
Magnify, Rotate, Swipe11
}13
/**14
* Magnify multiplies the current scale by (1 + delta). Rotate carries clockwise15
* radians. Swipe carries a discrete direction, positive right/down, not a pixel16
* distance. The positional state does not change mouse buttons or create touch17
* contacts. Device identity remains unknown when the platform cannot provide it.18
*/19
public enum GestureEvent {20
Magnify(PointerState, GesturePhase, Double),21
Rotate(PointerState, GesturePhase, Double),22
Swipe(PointerState, Double, Double)23
}25
public val GestureEvent.kind: GestureKind get() =26
when (this) {27
case Magnify(_, _, _) -> GestureKind.Magnify28
case Rotate(_, _, _) -> GestureKind.Rotate29
case Swipe(_, _, _) -> GestureKind.Swipe30
}32
public val GestureEvent.state: PointerState get() =33
when (this) {34
case Magnify(val value, _, _) -> value35
case Rotate(val value, _, _) -> value36
case Swipe(val value, _, _) -> value37
}39
/** Swipe is always discrete and has no continuous sequence phase. */40
public val GestureEvent.phase: GesturePhase get() =41
when (this) {42
case Magnify(_, val value, _) -> value43
case Rotate(_, val value, _) -> value44
case Swipe(_, _, _) -> GesturePhase.None45
}