2023-10-03 16:11:25 +00:00
|
|
|
import "pkg:/source/utils/misc.bs"
|
2023-05-03 21:21:04 +00:00
|
|
|
|
2022-09-03 20:06:57 +00:00
|
|
|
sub init()
|
|
|
|
m.previouslyDisplayedSection = 0
|
|
|
|
end sub
|
|
|
|
|
|
|
|
sub onFocusChange()
|
|
|
|
if m.top.focus
|
|
|
|
m.top.getChild(m.top.displayedIndex).setFocus(true)
|
|
|
|
end if
|
|
|
|
end sub
|
|
|
|
|
|
|
|
sub displayedIndexChanged()
|
|
|
|
if not m.top.affectsFocus then return
|
|
|
|
|
|
|
|
if m.top.displayedIndex < 0
|
|
|
|
return
|
|
|
|
end if
|
|
|
|
|
|
|
|
if m.top.displayedIndex > (m.top.getChildCount() - 1)
|
|
|
|
return
|
|
|
|
end if
|
|
|
|
|
|
|
|
m.top.getChild(m.previouslyDisplayedSection).setFocus(false)
|
|
|
|
|
|
|
|
displayedSection = m.top.getChild(m.top.displayedIndex)
|
|
|
|
displayedSection.setFocus(true)
|
|
|
|
|
2022-09-27 01:26:17 +00:00
|
|
|
onDeckSection = invalid
|
|
|
|
previouslyOnDeckSection = invalid
|
|
|
|
|
|
|
|
if m.top.displayedIndex + 1 <= (m.top.getChildCount() - 1)
|
|
|
|
onDeckSection = m.top.getChild(m.top.displayedIndex + 1)
|
|
|
|
end if
|
|
|
|
|
|
|
|
if m.top.displayedIndex + 2 <= (m.top.getChildCount() - 1)
|
|
|
|
previouslyOnDeckSection = m.top.getChild(m.top.displayedIndex + 2)
|
|
|
|
end if
|
|
|
|
|
2022-09-03 20:06:57 +00:00
|
|
|
' Move sections either up or down depending on what index we're moving to
|
|
|
|
if m.top.displayedIndex > m.previouslyDisplayedSection
|
2022-09-27 01:26:17 +00:00
|
|
|
for i = m.previouslyDisplayedSection to m.top.displayedIndex - 1
|
|
|
|
m.top.getChild(i).callFunc("scrollOffTop")
|
|
|
|
end for
|
|
|
|
|
2022-09-03 20:06:57 +00:00
|
|
|
displayedSection.callFunc("showFromBottom")
|
2022-09-27 01:26:17 +00:00
|
|
|
if isValid(onDeckSection)
|
|
|
|
onDeckSection.callFunc("scrollUpToOnDeck")
|
|
|
|
end if
|
2022-09-03 20:06:57 +00:00
|
|
|
else if m.top.displayedIndex < m.previouslyDisplayedSection
|
2022-09-27 01:26:17 +00:00
|
|
|
m.top.getChild(m.top.displayedIndex + 1).callFunc("scrollDownToOnDeck")
|
2022-09-03 20:06:57 +00:00
|
|
|
displayedSection.callFunc("showFromTop")
|
2022-09-27 01:26:17 +00:00
|
|
|
|
|
|
|
if isValid(previouslyOnDeckSection)
|
|
|
|
previouslyOnDeckSection.callFunc("scrollOffOnDeck")
|
|
|
|
end if
|
2022-09-03 20:06:57 +00:00
|
|
|
end if
|
|
|
|
|
|
|
|
m.previouslyDisplayedSection = m.top.displayedIndex
|
|
|
|
end sub
|