Make search behave more like web

This commit is contained in:
Nick Bisby 2019-03-16 17:11:50 -05:00
parent d0a0a94471
commit 1a2e31f3d2
No known key found for this signature in database
GPG Key ID: F6E0C4E6D0B5EB36
4 changed files with 28 additions and 55 deletions

View File

@ -6,7 +6,7 @@
</children>
<interface>
<field id="escape" type="boolean" alwaysNotify="true" />
<field id="search_value" type="string" />
<field id="search_value" type="string" alwaysNotify="true" />
</interface>
<script type="text/brightscript">
<![CDATA[

View File

@ -12,10 +12,12 @@
m.top.itemComponentName = "ListPoster"
m.top.content = getData()
m.top.rowFocusAnimationStyle = "floatingFocus"
updateSize()
m.top.showRowLabel = [ true ]
m.top.rowLabelOffset = [0, 20]
m.top.showRowCounter = [ true ]
m.top.setFocus(true)
end sub
@ -33,24 +35,13 @@
itemHeight = itemWidth * 1.5 + textHeight
m.top.itemSize = [dimensions["width"] - border*2, itemHeight]
m.top.itemSpacing = [0, 10]
m.top.itemSpacing = [0, 50]
m.top.rowItemSize = [ itemWidth, itemHeight ]
m.top.rowItemSpacing = [0, 0]
end sub
sub setData()
itemData = m.top.itemData
rowSize = m.top.rowSize
n = itemData.SearchHints.count()
if int(n/rowSize) = n/rowSize then
m.top.numRows = n/rowSize
else
m.top.numRows = n/rowSize + 1
end if
m.top.content = getData()
end sub
@ -65,29 +56,27 @@
' todo - Or get the old data? I can't remember...
data = CreateObject("roSGNode", "ContentNode")
for rownum=1 to m.top.numRows
row = data.CreateChild("ContentNode")
for i=1 to rowSize
index = (rowNum - 1) * rowSize + i
if index > itemData.SearchHints.count() then exit for
datum = itemData.SearchHints[index-1]
item = row.CreateChild("SearchData")
item.full_Data = datum
end for
end for
' TODO - pre-scan the item list and only add things which have results
addRow(data, "Movies", "Movie")
addRow(data, "Episodes", "Episode")
addRow(data, "Artists", "AlbumArtist")
addRow(data, "Albums", "Album")
addRow(data, "Songs", "Audio")
addRow(data, "People", "Person")
return data
end function
function onKeyEvent(key as string, press as boolean) as boolean
if not press then return false
if key = "down" and (m.top.itemFocused + 1) = m.top.content.getChildCount()
m.top.getScene().findNode("pager").setFocus(true)
m.top.getScene().findNode("pager").getChild(0).setFocus(true)
return true
function addRow(data, title, type_filter)
itemData = m.top.itemData
row = data.CreateChild("ContentNode")
row.title = title
for each item in itemData.SearchHints
if item.type = type_filter
child = row.createChild("SearchData")
child.full_data = item
end if
return false
end for
end function
]]>
</script>

View File

@ -9,7 +9,5 @@
id="overhang"
title="Search"
/>
<Rectangle id="footerBackdrop" />
<Pager id="pager" />
</children>
</component>

View File

@ -105,7 +105,10 @@ sub ShowLibrarySelect()
library.setFocus(true)
else if nodeEventQ(msg, "search_value")
query = msg.getRoSGNode().search_value
if query <> invalid or query <> ""
ShowSearchOptions(query)
end if
search.search_value = ""
else if nodeEventQ(msg, "itemSelected")
target = getMsgRowTarget(msg)
if target.libraryType = "movies"
@ -351,27 +354,10 @@ sub ShowSearchOptions(query)
options.observeField("itemSelected", port)
pager = scene.findNode("pager")
pager.currentPage = page_num
pager.maxPages = results.TotalRecordCount / page_size
if pager.maxPages = 0 then pager.maxPages = 1
pager.observeField("escape", port)
pager.observeField("pageSelected", port)
while true
msg = wait(0, port)
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed() then
return
else if nodeEventQ(msg, "escape") and msg.getNode() = "pager"
options.setFocus(true)
else if nodeEventQ(msg, "pageSelected") and pager.pageSelected <> invalid
pager.pageSelected = invalid
page_num = int(val(msg.getData().id))
pager.currentPage = page_num
results = SearchMedia(query)
options.itemData = results
options.setFocus(true)
else if nodeEventQ(msg, "itemSelected")
target = getMsgRowTarget(msg)
' TODO - swap this based on target.mediatype