HMS

Home Media Server for Roku Players
git clone https://www.brianlane.com/git/HMS
Log | Files | Refs | README | LICENSE

commit 91dc7da9bd2c5d23d84d2a874249fd79ee40e5fe
parent 9880d299fde0bb705dbe3e1d906b258038f07748
Author: Brian C. Lane <bcl@brianlane.com>
Date:   Mon, 14 Nov 2022 17:38:39 -0800

Populate PosterGrid with posters

This is tricky, and prone to crashing if it is wrong.
Currently it works, but it may not be *right*. Improve it later.

Diffstat:
MHMS/components/MainScene.brs | 57++++++++++++++++++++++++++++++++++++++++++---------------
1 file changed, 42 insertions(+), 15 deletions(-)

diff --git a/HMS/components/MainScene.brs b/HMS/components/MainScene.brs @@ -70,22 +70,37 @@ end sub sub OnMetadataLoaded() print "MainScene->OnMetadataLoaded()" - print m.metadataTask.metadata - - ' Totally not sure about this - m.gridPanel = m.panels.CreateChild("GridPanel") - - m.posterGrid = CreateObject("roSGNode", "PosterGrid") - m.posterGrid.basePosterSize="[240,320]" - m.posterGrid.itemSpacing="[8,8]" - m.posterGrid.caption1NumLines="1" - m.posterGrid.numColumns="3" - m.posterGrid.numRows="2" -' m.posterGrid.observeField("focusedItem", "OnPosterGridSelected") - m.gridPanel.grid = m.posterGrid - m.gridPanel.appendChild(m.posterGrid) + print "Got "; m.metadataTask.metadata.Count(); " items." + m.metadata = m.metadataTask.metadata + + ' Create one GridPanel and one PosterGrid, then reuse them for each category + ' This may not be quite right, but it works for now. + if m.gridPanel = invalid then + print "Creating new GridPanel" + m.gridPanel = m.panels.CreateChild("GridPanel") + m.gridPanel.panelSize = "full" + m.gridPanel.isFullScreen = true + m.gridPanel.focusable = true + m.gridPanel.hasNextPanel = false + m.gridPanel.createNextPanelOnItemFocus = false + + m.posterGrid = CreateObject("roSGNode", "PosterGrid") + m.posterGrid.basePosterSize = "[222, 330]" + m.posterGrid.itemSpacing = "[6, 9]" + m.posterGrid.posterDisplayMode = "scaleToZoom" + m.posterGrid.caption1NumLines = "1" + m.posterGrid.numColumns = "7" + m.posterGrid.numRows = "3" + m.posterGrid.ObserveField("itemSelected", "OnPostedSelected") + m.posterGrid.ObserveField("itemFocused", "OnPosterFocused") + + m.gridPanel.appendChild(m.PosterGrid) + m.gridPanel.grid = m.posterGrid + m.listPanel.nextPanel = m.gridPanel + end if + cn = CreateObject("roSGNode", "ContentNode") - for each item in m.metadataTask.metadata + for each item in m.metadata n = CreateObject("roSGNode", "ContentNode") n.HDPosterUrl = item.HDPosterUrl n.SDPosterUrl = item.SDPosterUrl @@ -95,6 +110,18 @@ sub OnMetadataLoaded() m.posterGrid.content = cn end sub +sub OnPosterSelected() + print "MainScene->OnPosterGridSelected()" + print m.posterGrid.itemSelected + print m.metadata[m.posterGrid.itemSelected].ShortDescriptionLine1 +end sub + +sub OnPosterFocused() + print "MainScene->OnPosterGridSelected()" + print m.posterGrid.itemFocused + print m.metadata[m.posterGrid.itemFocused].ShortDescriptionLine1 +end sub + sub OnLabelListSelected() print "MainScene->OnLabelListSelected()" end sub