remove backdrop when alpha menu is active and add a bunch of debug logging

This commit is contained in:
Charles Ewert 2024-08-03 22:01:58 -04:00
parent a93c893df4
commit d2c60e1364
3 changed files with 38 additions and 6 deletions

View File

@ -6,6 +6,7 @@ import "pkg:/source/roku_modules/log/LogMixin.brs"
sub init() sub init()
m.log = log.Logger("ItemGrid") m.log = log.Logger("ItemGrid")
m.log.debug("start init()")
m.options = m.top.findNode("options") m.options = m.top.findNode("options")
m.showItemCount = m.global.session.user.settings["itemgrid.showItemCount"] m.showItemCount = m.global.session.user.settings["itemgrid.showItemCount"]
@ -70,6 +71,7 @@ sub init()
m.resetGrid = m.global.session.user.settings["itemgrid.reset"] m.resetGrid = m.global.session.user.settings["itemgrid.reset"]
m.top.gridTitles = m.global.session.user.settings["itemgrid.gridTitles"] m.top.gridTitles = m.global.session.user.settings["itemgrid.gridTitles"]
m.log.debug("end init()")
end sub end sub
'Genre Item Selected 'Genre Item Selected
@ -79,6 +81,7 @@ end sub
'Load initial set of Data 'Load initial set of Data
sub loadInitialItems() sub loadInitialItems()
m.log.debug("start loadInitialItems()")
m.loadItemsTask.control = "stop" m.loadItemsTask.control = "stop"
startLoadingSpinner() startLoadingSpinner()
@ -227,6 +230,7 @@ sub loadInitialItems()
startLoadingSpinner(false) startLoadingSpinner(false)
m.loadItemsTask.control = "RUN" m.loadItemsTask.control = "RUN"
SetUpOptions() SetUpOptions()
m.log.debug("end loadInitialItems()")
end sub end sub
' Set Movies view, sort, and filter options ' Set Movies view, sort, and filter options
@ -438,6 +442,7 @@ end sub
'Handle loaded data, and add to Grid 'Handle loaded data, and add to Grid
sub ItemDataLoaded(msg) sub ItemDataLoaded(msg)
m.log.debug("start ItemDataLoaded()")
itemData = msg.GetData() itemData = msg.GetData()
m.loadItemsTask.unobserveField("content") m.loadItemsTask.unobserveField("content")
m.loadItemsTask.content = [] m.loadItemsTask.content = []
@ -494,22 +499,28 @@ sub ItemDataLoaded(msg)
end if end if
stopLoadingSpinner() stopLoadingSpinner()
m.log.debug("end ItemDataLoaded()")
end sub end sub
'Set Background Image 'Set Background Image
sub SetBackground(backgroundUri as string) sub SetBackground(backgroundUri as string)
m.log.debug("start SetBackground()", backgroundUri, m.swapAnimation.state, m.newBackdrop.loadStatus)
'If a new image is being loaded, or transitioned to, store URL to load next 'If a new image is being loaded, or transitioned to, store URL to load next
if m.swapAnimation.state <> "stopped" or m.newBackdrop.loadStatus = "loading" if not m.top.alphaActive
m.queuedBGUri = backgroundUri if m.swapAnimation.state <> "stopped" or m.newBackdrop.loadStatus = "loading"
return m.log.debug("caching new background URI")
m.queuedBGUri = backgroundUri
return
end if
end if end if
m.newBackdrop.uri = backgroundUri m.newBackdrop.uri = backgroundUri
m.log.debug("end SetBackground()")
end sub end sub
'Handle new item being focused 'Handle new item being focused
sub onItemFocused() sub onItemFocused()
m.log.debug("start onItemFocused()", m.itemGrid.currFocusRow, m.itemGrid.itemFocused)
focusedRow = m.itemGrid.currFocusRow focusedRow = m.itemGrid.currFocusRow
@ -518,7 +529,7 @@ sub onItemFocused()
updateTitle() updateTitle()
' If no selected item, set background to parent backdrop ' If no selected item, set background to parent backdrop
if itemInt = -1 if itemInt = -1 or focusedRow = -1
return return
end if end if
@ -531,6 +542,7 @@ sub onItemFocused()
if focusedRow >= m.loadedRows - 5 and m.loadeditems < m.loadItemsTask.totalRecordCount if focusedRow >= m.loadedRows - 5 and m.loadeditems < m.loadItemsTask.totalRecordCount
loadMoreData() loadMoreData()
end if end if
m.log.debug("end onItemFocused()")
end sub end sub
'When Image Loading Status changes 'When Image Loading Status changes
@ -551,6 +563,7 @@ sub swapDone()
'If there is another one to load 'If there is another one to load
if m.newBackdrop.uri <> m.queuedBGUri and m.queuedBGUri <> "" if m.newBackdrop.uri <> m.queuedBGUri and m.queuedBGUri <> ""
m.log.debug("Loading queued backdrop image", m.queuedBGUri)
SetBackground(m.queuedBGUri) SetBackground(m.queuedBGUri)
m.queuedBGUri = "" m.queuedBGUri = ""
end if end if
@ -559,6 +572,7 @@ end sub
'Load next set of items 'Load next set of items
sub loadMoreData() sub loadMoreData()
m.log.debug("start loadMoreData()")
if m.Loading = true then return if m.Loading = true then return
startLoadingSpinner(false) startLoadingSpinner(false)
@ -566,6 +580,7 @@ sub loadMoreData()
m.loadItemsTask.startIndex = m.loadedItems m.loadItemsTask.startIndex = m.loadedItems
m.loadItemsTask.observeField("content", "ItemDataLoaded") m.loadItemsTask.observeField("content", "ItemDataLoaded")
m.loadItemsTask.control = "RUN" m.loadItemsTask.control = "RUN"
m.log.debug("end loadMoreData()")
end sub end sub
'Item Selected 'Item Selected
@ -760,6 +775,20 @@ function getItemFocused()
return invalid return invalid
end function end function
sub alphaActiveChanged()
m.log.debug("start alphaActiveChanged()", m.top.alphaActive)
if m.top.alphaActive
' fade into an empty backdrop
m.swapAnimation.state = "stop"
m.queuedBGUri = ""
' use a 1px image because we can't use the animation to fade into a blank uri string
SetBackground("pkg:/images/1px-262626.png")
end if
m.log.debug("end alphaActiveChanged()")
end sub
function onKeyEvent(key as string, press as boolean) as boolean function onKeyEvent(key as string, press as boolean) as boolean
if not press then return false if not press then return false
@ -826,11 +855,14 @@ function onKeyEvent(key as string, press as boolean) as boolean
return true return true
end if end if
else if key = "left" and topGrp.isinFocusChain() else if key = "left" and topGrp.isinFocusChain()
m.log.debug("Now entering alpha menu")
m.top.alphaActive = true m.top.alphaActive = true
topGrp.setFocus(false) topGrp.setFocus(false)
m.alphaMenu.setFocus(true) m.alphaMenu.setFocus(true)
return true return true
else if key = "right" and m.alpha.isinFocusChain() else if key = "right" and m.alpha.isinFocusChain()
m.log.debug("Now leaving alpha menu")
m.top.alphaActive = false m.top.alphaActive = false
m.alphaMenu.setFocus(false) m.alphaMenu.setFocus(false)
topGrp.setFocus(true) topGrp.setFocus(true)

View File

@ -33,7 +33,7 @@
<field id="quickPlayNode" type="node" alwaysNotify="true" /> <field id="quickPlayNode" type="node" alwaysNotify="true" />
<field id="imageDisplayMode" type="string" value="scaleToZoom" /> <field id="imageDisplayMode" type="string" value="scaleToZoom" />
<field id="alphaSelected" type="string" alias="alpha.letterSelected" alwaysNotify="true" onChange="alphaSelectedChanged" /> <field id="alphaSelected" type="string" alias="alpha.letterSelected" alwaysNotify="true" onChange="alphaSelectedChanged" />
<field id="alphaActive" type="boolean" value="false" /> <field id="alphaActive" type="boolean" value="false" onChange="alphaActiveChanged" />
<field id="jumpToItem" type="integer" value="" /> <field id="jumpToItem" type="integer" value="" />
<field id="gridTitles" type="string" /> <field id="gridTitles" type="string" />
</interface> </interface>

BIN
images/1px-262626.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 B