-
-
Save andreymusth/318cc9f2e64a7ab0e303e54309b6824c to your computer and use it in GitHub Desktop.
process full
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun process( | |
pointerEvent: PointerInputEvent, | |
positionCalculator: PositionCalculator | |
): ProcessResult { | |
// Gets a new PointerInputChangeEvent with the PointerInputEvent. | |
val internalPointerEvent = | |
pointerInputChangeEventProducer.produce(pointerEvent, positionCalculator) | |
// Add new hit paths to the tracker due to down events. | |
internalPointerEvent.changes.values.forEach { pointerInputChange -> | |
if (pointerInputChange.changedToDownIgnoreConsumed()) { | |
root.hitTest( | |
pointerInputChange.position, | |
hitResult | |
) | |
if (hitResult.isNotEmpty()) { | |
hitPathTracker.addHitPath(pointerInputChange.id, hitResult) | |
hitResult.clear() | |
} | |
} | |
} | |
// Remove [PointerInputFilter]s that are no longer valid and refresh the offset information | |
// for those that are. | |
hitPathTracker.removeDetachedPointerInputFilters() | |
// Dispatch to PointerInputFilters | |
val dispatchedToSomething = hitPathTracker.dispatchChanges(internalPointerEvent) | |
var anyMovementConsumed = false | |
// Remove hit paths from the tracker due to up events, and calculate if we have consumed | |
// any movement | |
internalPointerEvent.changes.values.forEach { pointerInputChange -> | |
if (pointerInputChange.changedToUpIgnoreConsumed()) { | |
hitPathTracker.removeHitPath(pointerInputChange.id) | |
} | |
if (pointerInputChange.positionChangeConsumed()) { | |
anyMovementConsumed = true | |
} | |
} | |
return ProcessResult(dispatchedToSomething, anyMovementConsumed) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment