Fix AudioOptions navigation

This commit is contained in:
NeilClack
2026-08-08 00:59:22 -05:00
parent 843170b282
commit 1b80265e80
2 changed files with 24 additions and 22 deletions
+16 -14
View File
@@ -15,10 +15,12 @@ import (
"rhemawavetech.com/rhemawave/internal/shaderManager"
)
// focusToggle is the focus state of the audio on/off toggle, the bottommost
// focusable item. Focus states increase from top to bottom on screen:
// 0 = Audio Track entry, 1 = Output Device entry, focusToggle = toggle.
const focusToggle = 2
// focusToggle is the focus state of the audio on/off toggle, the topmost
// focusable item on screen (Y increases upward). Focus states increase from
// top to bottom: focusToggle = toggle, 1 = Output Device, maxFocus = Audio Track.
const focusToggle = 0
const maxFocus = 2
const triangleSize = float32(16)
@@ -304,10 +306,10 @@ func (p *AudioOptions) updateCursorPosition() {
switch {
case p.focusState == focusToggle:
item = &p.AudioStatusToggle
case p.focusState == 0:
item = &p.audioTrackItem
case p.focusState == 1:
item = &p.outputDeviceItem
case p.focusState == 2:
item = &p.audioTrackItem
default:
return
}
@@ -329,16 +331,16 @@ func (p *AudioOptions) ToggleAudio() {
}
// moveFocus returns the focus state after moving by delta (1 = down, -1 = up)
// on screen. Focus states run 0 (Audio Track) to focusToggle (toggle), so
// navigation never skips the Output Device entry.
// on screen. Focus states run focusToggle (toggle) to maxFocus (Audio Track),
// so navigation never skips the Output Device entry.
func moveFocus(current, delta int) int {
next := current + delta
if next < 0 {
next = 0
}
if next > focusToggle {
if next < focusToggle {
next = focusToggle
}
if next > maxFocus {
next = maxFocus
}
return next
}
@@ -353,10 +355,10 @@ func (p *AudioOptions) HandleEvent(event *sdl.Event) error {
switch p.focusState {
case focusToggle:
p.ToggleAudio()
case 0:
p.Context.NavigateTo(TRACKS)
case 1:
p.Context.NavigateTo(AUDIO_DEVICES)
case 2:
p.Context.NavigateTo(TRACKS)
}
case sdl.K_DOWN: