Scoop API

scoop:scoop.window:0.1.0

src/native/input/gestures.scoop

Selected production source · src/native/input/gestures.scoop

1package scoop.window
3internal fun copyGestureEvent(header: NativeEventHeader, event: NativeGestureData): GestureEvent {
4 val state =
5 PointerState(
6 LogicalPosition(event.x, event.y),
7 PhysicalPosition(event.physicalX, event.physicalY),
8 event.scale,
9 platformModifiers(event.modifiers),
10 copyInputTime(header)
11 )
12 val phase =
13 when (event.phase) {
14 0 -> GesturePhase.None
15 1 -> GesturePhase.Began
16 2 -> GesturePhase.Changed
17 3 -> GesturePhase.Ended
18 4 -> GesturePhase.Cancelled
19 else -> throw WindowException(
20 "unknown native gesture phase",
21 WindowErrorKind.NativeFailure
22 )
23 }
24 return when (event.kind) {
25 0 -> GestureEvent.Magnify(state, phase, event.deltaX)
26 1 -> GestureEvent.Rotate(state, phase, event.deltaX)
27 2 -> GestureEvent.Swipe(state, event.deltaX, event.deltaY)
28 else -> throw WindowException("unknown native gesture kind", WindowErrorKind.NativeFailure)
29 }