[orx-camera] Add propagationCancelled checks

This commit is contained in:
Edwin Jakobs
2023-07-11 16:16:33 +02:00
parent ddb308bb9b
commit 12da813b09

View File

@@ -43,29 +43,33 @@ class Camera2D : Extension, ChangeEvents {
rotationCenter = it.position rotationCenter = it.position
} }
mouse.dragged.listen { mouse.dragged.listen {
when (it.button) { if (!it.propagationCancelled) {
MouseButton.LEFT -> view = buildTransform { when (it.button) {
translate(it.dragDisplacement) MouseButton.LEFT -> view = buildTransform {
} * view translate(it.dragDisplacement)
} * view
MouseButton.RIGHT -> view = buildTransform { MouseButton.RIGHT -> view = buildTransform {
translate(rotationCenter) translate(rotationCenter)
rotate(it.dragDisplacement.x + it.dragDisplacement.y) rotate(it.dragDisplacement.x + it.dragDisplacement.y)
translate(-rotationCenter) translate(-rotationCenter)
} * view } * view
else -> Unit else -> Unit
}
dirty = true
} }
dirty = true
} }
mouse.scrolled.listen { mouse.scrolled.listen {
val scaleFactor = 1.0 - it.rotation.y * 0.03 if (!it.propagationCancelled) {
view = buildTransform { val scaleFactor = 1.0 - it.rotation.y * 0.03
translate(it.position) view = buildTransform {
scale(scaleFactor) translate(it.position)
translate(-it.position) scale(scaleFactor)
} * view translate(-it.position)
dirty = true } * view
dirty = true
}
} }
} }