scoop:scoop.window:0.1.0
src/input/contact.scoop
Selected production source · src/input/contact.scoop
1
package scoop.window3
/** Identifies one contact lifetime within a window; native values may be reused. */4
public struct ContactId(val value: Long): Equals<ContactId>, Hash {5
public override operator fun equals(other: ContactId): Boolean = value == other.value6
public override fun hash(): Long = value.hash()7
}9
/** Direct screen contact or a pen tip, separate from indirect native gestures. */10
public enum ContactKind {11
Touch, Pen12
}14
/** Pressure is present only when the device supplies a normalized value. */15
public struct ContactState(16
val id: ContactId,17
val kind: ContactKind,18
val pointer: PointerState,19
val pressure: Double? = None20
)22
public enum ContactEvent {23
Began(ContactState), Moved(ContactState), Ended(ContactState),24
Cancelled(ContactId, PointerCancelReason, InputTime)25
}27
public val ContactEvent.id: ContactId get() =28
when (this) {29
case Began(val value) -> value.id30
case Moved(val value) -> value.id31
case Ended(val value) -> value.id32
case Cancelled(val value, _, _) -> value33
}35
public val ContactEvent.time: InputTime get() =36
when (this) {37
case Began(val value) -> value.pointer.time38
case Moved(val value) -> value.pointer.time39
case Ended(val value) -> value.pointer.time40
case Cancelled(_, _, val value) -> value41
}