scoop:scoop.window:0.1.0
src/input/pointer.scoop
Selected production source · src/input/pointer.scoop
1
package scoop.window3
/** Position and modifiers captured from one native positional input event. */4
public struct PointerState(5
val logicalPosition: LogicalPosition,6
val physicalPosition: PhysicalPosition,7
val scaleFactor: Double,8
val modifiers: Modifiers,9
val time: InputTime,10
val deviceId: DeviceId? = None11
)13
/** Native button numbering is retained for additional mouse buttons. */14
public enum MouseButton {15
Left, Right, Middle, Other(UInt)16
}18
/** Line deltas are never converted with an invented line height. */19
public enum ScrollDelta {20
LineDelta(Double, Double), PixelDelta(Double, Double)21
}23
/** A native phase; None is normal for traditional wheel events. */24
public enum ScrollPhase {25
None, MayBegin, Began, Stationary, Changed, Ended, Cancelled26
}28
/** Ends native positional input without synthesizing a successful release. */29
public enum PointerCancelReason {30
FocusLost, CaptureLost, SystemOperation, Modal31
}33
/**34
* Window-relative pointer events, with independent wheel and momentum phases.35
* Button carries a consecutive click count of at least one. The matching release36
* retains its press count; cancellation ends the sequence without a release.37
*/38
public enum PointerEvent {39
Entered(PointerState), Left(PointerState), Moved(PointerState),40
Button(PointerState, MouseButton, ElementState, Int),41
Wheel(PointerState, ScrollDelta, ScrollPhase, ScrollPhase),42
Cancelled(PointerCancelReason, InputTime)43
}45
internal fun copyPointerCancelReason(reason: Int): PointerCancelReason =46
when (reason) {47
0 -> PointerCancelReason.FocusLost48
1 -> PointerCancelReason.CaptureLost49
2 -> PointerCancelReason.SystemOperation50
3 -> PointerCancelReason.Modal51
else -> throw WindowException("unknown pointer cancellation", WindowErrorKind.NativeFailure)52
}