Remove Legacy ItemGrid pages and simplify main event loop

This commit is contained in:
Neil Burrows 2021-02-12 15:17:55 +00:00
parent d7d21491cf
commit ef748eba18
8 changed files with 4 additions and 295 deletions

View File

@ -1,96 +0,0 @@
sub init()
m.top.itemComponentName = "ListPoster"
m.top.content = setData()
m.top.rowFocusAnimationStyle = "floatingFocus"
m.top.showRowLabel = [false]
m.top.setFocus(true)
end sub
sub updateSize()
m.top.numRows = 1
if m.top.itemsPerRow = invalid or m.top.itemsPerRow = 0 then
m.top.itemsPerRow = 6
end if
dimensions = m.top.getScene().currentDesignResolution
topBorder = 75
border = 96
topSpace = topBorder + 105
m.top.translation = [96, topSpace]
textHeight = 100
itemWidth = (dimensions["width"] - border*2) / m.top.itemsPerRow -20
itemHeight = itemWidth * 1.5 + textHeight
if itemHeight*m.top.rowsPerPage > (dimensions["height"] - topBorder - 115) then
ratio = (itemHeight*m.top.rowsPerPage) / (981 - topSpace - 15)
itemHeight = itemHeight / ratio
itemWidth = itemWidth / ratio
end if
m.top.visible = true
' Size of the individual rows
m.top.itemSize = [dimensions["width"] - border*2, itemHeight]
' Spacing between Rows
m.top.itemSpacing = [ 0, 10]
' Size of items in the row
m.top.rowItemSize = [ itemWidth, itemHeight ]
' Spacing between items in the row
itemSpace = (dimensions["width"] - border*2 - itemWidth*m.top.itemsPerRow) / (m.top.itemsPerRow-1)
m.top.rowItemSpacing = [ itemSpace-1, 0 ]
end sub
function setupRows()
updateSize()
objects = m.top.objects
itemsPerRow = m.top.itemsPerRow
n = objects.items.count()
' This tests to make sure we are at an integer number of rows
if int(n/itemsPerRow) = n/itemsPerRow then
m.top.numRows = n/itemsPerRow
' Otherwise we need an extra (not full) row for the leftovers
else
m.top.numRows = n/itemsPerRow + 1
end if
m.top.content = setData()
end function
function setData()
data = CreateObject("roSGNode", "ContentNode")
if m.top.objects = invalid then
' Return an empty node just to return something; we'll update once we have data
return data
end if
objects = m.top.objects
itemsPerRow = m.top.itemsPerRow
for rowNum = 1 to m.top.numRows
row = data.CreateChild("ContentNode")
for i = 1 to itemsPerRow
index = (rowNum - 1) * itemsPerRow + i
if index > objects.items.count() then
exit for
end if
row.appendChild(objects.items[index-1])
end for
end for
return data
end function
function onKeyEvent(key as string, press as boolean) as boolean
if not press then return false
return false
end function

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="ItemGrid" extends="RowList">
<interface>
<field id="itemsPerRow" type="int" />
<field id="rowsPerPage" type="int" value="2" />
<field id="objects" type="assocarray" onChange="setupRows" />
<field id="escapeButton" type="string" alwaysNotify="true" />
</interface>
<script type="text/brightscript" uri="ItemGrid.brs" />
</component>

View File

@ -1,14 +0,0 @@
sub init()
m.top.overhangTitle = "Collections"
end sub
function onKeyEvent(key as string, press as boolean) as boolean
if not press then return false
if key = "down"
m.top.lastFocus = m.top.focusedChild
m.top.findNode("paginator").setFocus(true)
end if
return false
end function

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="Collections" extends="JFGroup">
<children>
<ItemGrid id="picker" visible="true" itemsPerRow="6" />
<OptionsSlider id="options" />
<Rectangle translation="[0,981]" width="1920" height="100" color="#101010" />
</children>
<interface>
<field id="collectionSelected" alias="picker.itemSelected" />
<field id="objects" alias="picker.objects" />
<field id="pageNumber" type="integer" />
</interface>
<script type="text/brightscript" uri="Collections.brs" />
</component>

View File

@ -1,14 +0,0 @@
sub init()
end sub
function onKeyEvent(key as string, press as boolean) as boolean
if not press then return false
if key = "down"
m.top.lastFocus = m.top.focusedChild
m.top.findNode("paginator").setFocus(true)
end if
return false
end function

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="TVShows" extends="JFGroup">
<children>
<ItemGrid id="picker" visible="true" itemsPerRow="6" />
<OptionsSlider id="options" />
<Rectangle translation="[0,981]" width="1920" height="100" color="#101010" />
</children>
<interface>
<field id="seriesSelected" alias="picker.itemSelected" />
<field id="objects" alias="picker.objects" />
<field id="pageNumber" type="integer" />
</interface>
<script type="text/brightscript" uri="TVShows.brs" />
</component>

View File

@ -103,49 +103,12 @@ sub Main()
else if isNodeEvent(msg, "selectedItem")
' If you select a library from ANYWHERE, follow this flow
selectedItem = msg.getData()
if (selectedItem.type = "CollectionFolder" OR selectedItem.type = "UserView" OR selectedItem.type = "Folder") AND ( selectedItem.collectionType = "movies" or selectedItem.collectionType = "CollectionFolder")
if selectedItem.type = "CollectionFolder" OR selectedItem.type = "UserView" OR selectedItem.type = "Folder"
group.lastFocus = group.focusedChild
group.setFocus(false)
group.visible = false
m.overhang.title = selectedItem.title
group = CreateMovieListGroup(selectedItem)
group.overhangTitle = selectedItem.title
m.scene.appendChild(group)
else if (selectedItem.type = "CollectionFolder" OR selectedItem.type = "UserView") AND selectedItem.collectionType = "tvshows"
group.lastFocus = group.focusedChild
group.setFocus(false)
group.visible = false
m.overhang.title = selectedItem.title
group = CreateSeriesListGroup(selectedItem)
group.overhangTitle = selectedItem.title
m.scene.appendChild(group)
else if (selectedItem.type = "CollectionFolder" OR selectedItem.type = "UserView") AND selectedItem.collectionType = "boxsets" OR selectedItem.type = "Boxset"
group.lastFocus = group.focusedChild
group.setFocus(false)
group.visible = false
m.overhang.title = selectedItem.title
group = CreateCollectionsList(selectedItem)
group.overhangTitle = selectedItem.title
m.scene.appendChild(group)
else if ((selectedItem.type = "CollectionFolder" OR selectedItem.type = "UserView") AND selectedItem.collectionType = "livetv") OR selectedItem.type = "Channel"
group.lastFocus = group.focusedChild
group.setFocus(false)
group.visible = false
m.overhang.title = selectedItem.title
group = CreateChannelList(selectedItem)
group.overhangTitle = selectedItem.title
m.scene.appendChild(group)
else if selectedItem.type = "Boxset" or selectedItem.collectionType = "folders" then
group.lastFocus = group.focusedChild
group.setFocus(false)
group.visible = false
m.overhang.title = selectedItem.title
group = CreateCollectionDetailList(selectedItem.Id)
group = CreateItemGrid(selectedItem)
group.overhangTitle = selectedItem.title
m.scene.appendChild(group)
else if selectedItem.type = "Folder"
@ -154,7 +117,7 @@ sub Main()
group.visible = false
m.overhang.title = selectedItem.title
group = CreateCollectionsList(selectedItem)
group = CreateItemGrid(selectedItem)
group.overhangTitle = selectedItem.title
m.scene.appendChild(group)
else if selectedItem.type = "Episode" then

View File

@ -211,50 +211,6 @@ function CreateHomeGroup()
return group
end function
function CreateMovieListGroup(libraryItem)
group = CreateObject("roSGNode", "ItemGrid2")
group.parentItem = libraryItem
group.observeField("selectedItem", m.port)
group.observeField("quickPlayNode", m.port)
sidepanel = group.findNode("options")
movie_options = [
{"title": "Sort Field",
"base_title": "Sort Field",
"key": "movie_sort_field",
"default": "DateCreated",
"values": [
{display: tr("Date Added"), value: "DateCreated"},
{display: tr("Release Date"), value: "PremiereDate"},
{display: tr("Name"), value: "SortName"}
]},
{"title": "Sort Order",
"base_title": "Sort Order",
"key": "movie_sort_order",
"default": "Ascending",
"values": [
{display: tr("Descending"), value: "Descending"},
{display: tr("Ascending"), value: "Ascending"}
]}
]
new_options = []
for each opt in movie_options
o = CreateObject("roSGNode", "OptionsData")
o.title = tr(opt.title)
o.choices = opt.values
o.base_title = tr(opt.base_title)
o.config_key = opt.key
o.value = get_user_setting(opt.key, opt.default)
new_options.append([o])
end for
sidepanel.options = new_options
sidepanel.observeField("closeSidePanel", m.port)
return group
end function
function CreateMovieDetailsGroup(movie)
group = CreateObject("roSGNode", "MovieDetails")
@ -269,18 +225,6 @@ function CreateMovieDetailsGroup(movie)
return group
end function
function CreateSeriesListGroup(libraryItem)
group = CreateObject("roSGNode", "ItemGrid2")
group.parentItem = libraryItem
group.observeField("selectedItem", m.port)
sidepanel = group.findNode("options")
return group
end function
function CreateSeriesDetailsGroup(series)
group = CreateObject("roSGNode", "TVShowDetails")
@ -304,46 +248,10 @@ function CreateSeasonDetailsGroup(series, season)
return group
end function
function CreateCollectionsList(libraryItem)
function CreateItemGrid(libraryItem)
group = CreateObject("roSGNode", "ItemGrid2")
group.parentItem = libraryItem
group.observeField("selectedItem", m.port)
group.observeField("quickPlayNode", m.port)
sidepanel = group.findNode("options")
return group
end function
function CreateCollectionDetailList(collectionId)
sort_order = get_user_setting("movie_sort_order", "Ascending")
sort_field = get_user_setting("movie_sort_field", "SortName")
item_list = ItemList(collectionId, {
"SortBy": sort_field,
"SortOrder": sort_order
})
group = CreateObject("roSGNode", "CollectionDetail")
group.collectionId = collectionId
group.objects = item_list
group.observeField("selectedItem", m.port)
return group
end function
function CreateChannelList(libraryItem)
group = CreateObject("roSGNode", "ItemGrid2")
group.parentItem = libraryItem
group.observeField("selectedItem", m.port)
sidepanel = group.findNode("options")
return group
end function