overhauled navigation, it doesn't suck now

This commit is contained in:
2026-08-09 23:47:10 -05:00
parent f70e9b0b08
commit 75f0cbded6
3 changed files with 199 additions and 40 deletions
+59 -40
View File
@@ -59,50 +59,27 @@ QtObject {
property int focusRegion: bottomWindow.mainMenuNavRegions.GamesList
property int dockMenuIndex: 0
NavigationManager {
id: navigationManager
rootItem: bottomRoot
}
Connections {
target: inputManager
function onActionPressed(action) {
if (action === InputManager.Up) {
if (bottomWindow.focusRegion < bottomWindow.mainMenuNavRegions.Count - 1) {
bottomWindow.focusRegion += 1
}
}
if (action === InputManager.Down) {
if (bottomWindow.focusRegion > 0) {
bottomWindow.focusRegion -= 1
}
}
if (action === InputManager.Left || action === InputManager.Right) {
switch (bottomWindow.focusRegion) {
case bottomWindow.mainMenuNavRegions.GamesList:
if (action === InputManager.Left) {
if (gamesList.currentIndex > 0) {
gamesList.currentIndex -= 1
}
} else {
if (gamesList.currentIndex < gamesList.count - 1) {
gamesList.currentIndex += 1
}
}
break
case bottomWindow.mainMenuNavRegions.DockMenu:
if (action === InputManager.Left) {
if (bottomWindow.dockMenuIndex > 0) {
bottomWindow.dockMenuIndex -= 1
}
} else {
if (bottomWindow.dockMenuIndex < dockRepeater.count - 1) {
bottomWindow.dockMenuIndex += 1
}
}
break
}
switch (action) {
case InputManager.Up:
case InputManager.Down:
case InputManager.Left:
case InputManager.Right:
navigationManager.move(action)
break
}
}
}
Rectangle {
id: bottomRoot
anchors.fill: parent
@@ -135,17 +112,36 @@ QtObject {
model: 20
Component.onCompleted: {
if (currentItem) {
navigationManager.focusItem(currentItem)
}
}
delegate: Rectangle {
id: gameTile
width: 110
height: 110
color: bottomWindow.focusRegion === bottomWindow.mainMenuNavRegions.GamesList && index === gamesList.currentIndex ? "blue" : "white"
color: navigationManager.currentItem === gameTile ? "blue" : "white"
function navFocus() {
gamesList.currentIndex = index
}
Component.onCompleted: {
navigationManager.registerItem(gameTile)
}
Component.onDestruction: {
navigationManager.unregisterItem(gameTile)
}
MouseArea {
anchors.fill: parent
onClicked: {
bottomWindow.focusRegion = bottomWindow.mainMenuNavRegions.GamesList
gamesList.currentIndex = index
navigationManager.focusItem(gameTile)
}
}
}
@@ -165,9 +161,32 @@ QtObject {
model: 5
Rectangle {
id: dockButton
width: 60
height: 60
color: bottomWindow.focusRegion === bottomWindow.mainMenuNavRegions.DockMenu && index === bottomWindow.dockMenuIndex ? "blue" : "white"
color: navigationManager.currentItem === dockButton ? "blue" : "white"
function navFocus() {
bottomWindow.dockMenuIndex = index
}
Component.onCompleted: {
navigationManager.registerItem(dockButton)
}
Component.onDestruction: {
navigationManager.unregisterItem(dockButton)
}
MouseArea {
anchors.fill: parent
onClicked: {
navigationManager.focusItem(dockButton)
}
}
}
}
}