Add HOME button to reset camera position

This commit is contained in:
UnicornFreedom 2024-10-10 17:39:03 +02:00
parent 74b498bdfb
commit 906f129901

View File

@ -238,10 +238,7 @@ class WorkspaceView extends Widget with Persistable with DragHandler with ClickH
eventHandlers += {
case ev@DragEvent(DragEvent.State.Drag, MouseEvent.Button.Left | MouseEvent.Button.Middle, _) =>
cameraOffset += ev.delta
for (node <- nodes)
node.position += ev.delta
windowPool.movePinnedWindows(ev.delta)
moveCameraOffset(ev.delta)
case ClickEvent(MouseEvent.Button.Left | MouseEvent.Button.Right, pos) =>
if (nodeSelector.isClosed) {
@ -269,6 +266,16 @@ class WorkspaceView extends Widget with Persistable with DragHandler with ClickH
case KeyEvent(KeyEvent.State.Press, Keyboard.KEY_F4, _) =>
profilerWindow.open()
case KeyEvent(KeyEvent.State.Press, Keyboard.KEY_HOME, _) =>
moveCameraOffset(-cameraOffset)
}
private def moveCameraOffset(delta: Vector2D): Unit = {
cameraOffset += delta
for (node <- nodes)
node.position += delta
windowPool.movePinnedWindows(delta)
}
private def openSelector(p: Vector2D): Unit = {