Support left, right navigation while viewing photos

This commit is contained in:
Jimi 2022-11-18 22:57:40 -07:00
parent 380c22cfc3
commit 78ab9e9233
5 changed files with 44 additions and 33 deletions

View File

@ -724,9 +724,10 @@ function onKeyEvent(key as string, press as boolean) as boolean
return true
else if itemToPlay <> invalid and itemToPlay.type = "Photo"
' Spawn photo player task
photoPlayer = CreateObject("roSgNode", "PhotoPlayerTask")
photoPlayer.itemContent = itemToPlay
photoPlayer.control = "RUN"
photoPlayer = CreateObject("roSgNode", "PhotoDetails")
photoPlayer.items = markupGrid
photoPlayer.itemIndex = markupGrid.itemFocused
m.global.sceneManager.callfunc("pushScene", photoPlayer)
return true
end if
else if key = "left" and topGrp.isinFocusChain()

View File

@ -1,13 +1,17 @@
sub init()
m.top.optionsAvailable = false ' Change once Shuffle option is added
m.top.overhangVisible = false
itemContentChanged()
end sub
sub itemContentChanged()
m.LoadLibrariesTask = createObject("roSGNode", "LoadPhotoTask")
m.LoadLibrariesTask.itemContent = m.top.itemContent
m.LoadLibrariesTask.observeField("results", "onPhotoLoaded")
m.LoadLibrariesTask.control = "RUN"
if isValidToContinue(m.top.itemIndex)
m.LoadLibrariesTask = createObject("roSGNode", "LoadPhotoTask")
itemContent = m.top.items.content.getChild(m.top.itemIndex)
m.LoadLibrariesTask.itemContent = itemContent
m.LoadLibrariesTask.observeField("results", "onPhotoLoaded")
m.LoadLibrariesTask.control = "RUN"
end if
end sub
sub onPhotoLoaded()
@ -19,3 +23,33 @@ sub onPhotoLoaded()
message_dialog("This image type is not supported.")
end if
end sub
function onKeyEvent(key as string, press as boolean) as boolean
if not press then return false
if key = "right"
if isValidToContinue(m.top.itemIndex + 1)
m.top.itemIndex++
end if
return true
end if
if key = "left"
if isValidToContinue(m.top.itemIndex - 1)
m.top.itemIndex--
end if
return true
end if
return false
end function
function isValidToContinue(index as integer)
if isValid(m.top.items) and isValid(m.top.items.content)
if index >= 0 and index < m.top.items.content.getChildCount()
return true
end if
end if
return false
end function

View File

@ -6,7 +6,8 @@
</LayoutGroup>
</children>
<interface>
<field id="itemContent" type="node" onChange="itemContentChanged" />
<field id="items" type="node" />
<field id="itemIndex" type="integer" value="-1" onChange="itemContentChanged" />
</interface>
<script type="text/brightscript" uri="PhotoDetails.brs" />
<script type="text/brightscript" uri="pkg:/source/utils/misc.brs" />

View File

@ -1,17 +0,0 @@
sub init()
m.top.functionName = "loadItems"
end sub
sub loadItems()
item = m.top.itemContent
group = CreateObject("roSGNode", "PhotoDetails")
group.optionsAvailable = false
m.global.sceneManager.callFunc("pushScene", group)
group.itemContent = item
' TODO/FIXME:
' Wait some time and move to the next photo...
end sub

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="PhotoPlayerTask" extends="Task">
<interface>
<field id="itemContent" type="node" />
</interface>
<script type="text/brightscript" uri="PhotoPlayerTask.brs" />
</component>