scoop:scoop.window:0.1.0
src/native/input/gestures.scoop
Selected production source · src/native/input/gestures.scoop
1
package scoop.window3
internal 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.None15
1 -> GesturePhase.Began16
2 -> GesturePhase.Changed17
3 -> GesturePhase.Ended18
4 -> GesturePhase.Cancelled19
else -> throw WindowException(20
"unknown native gesture phase",21
WindowErrorKind.NativeFailure22
)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
}30
}