Make search work from sidebar

This commit is contained in:
Nick Bisby 2019-10-13 15:52:34 -05:00
parent 0ec2872093
commit 3ed9846e42
5 changed files with 57 additions and 44 deletions

View File

@ -1,9 +1,10 @@
sub init()
m.top.layoutDirection = "vert"
dimensions = m.top.getScene().currentDesignResolution
m.top.translation = [dimensions.width / 2, 880]
m.top.horizAlignment = "center"
m.top.vertAlignment = "top"
m.top.visible = false
show_dialog()
end sub
function onKeyEvent(key as string, press as boolean) as boolean
@ -13,10 +14,6 @@ function onKeyEvent(key as string, press as boolean) as boolean
' Make a Keyboard Dialog here
show_dialog()
return true
else if key = "up"
m.top.findNode("search-input").active = false
m.top.escape = true
return true
end if
return false
@ -50,5 +47,4 @@ end sub
sub dismiss_dialog()
m.top.getScene().dialog.close = true
end sub

View File

@ -5,7 +5,6 @@
<TextEditBox id="search-input" width="800" maxTextLength="75" />
</children>
<interface>
<field id="escape" type="boolean" alwaysNotify="true" />
<field id="search_value" type="string" alwaysNotify="true" />
</interface>
<script type="text/brightscript" uri="SearchBox.brs" />

View File

@ -1,8 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="SearchResults" extends="Scene">
<component name="SearchResults" extends="JFGroup">
<children>
<SearchRow id="SearchSelect" visible="true" />
<Overhang id="overhang" title="Search" />
<SearchBox id="SearchBox" visible="true" translation="[960, 145]" />
<SearchRow id="SearchSelect" visible="false" />
</children>
<interface>
<field id="query" type="string" alwaysNotify="true" />
</interface>
<script type="text/brightscript" uri="scene.brs" />
</component>

View File

@ -90,6 +90,29 @@ sub Main()
group = CreateMovieDetailsGroup(node)
m.scene.appendChild(group)
m.overhang.title = group.overhangTitle
else if isNodeEvent(msg, "search_value")
query = msg.getRoSGNode().search_value
group.findNode("SearchBox").visible = false
options = group.findNode("SearchSelect")
options.visible = true
options.setFocus(true)
results = SearchMedia(query)
options.itemData = results
options.query = query
else if isNodeEvent(msg, "itemSelected")
' Search item selected
node = getMsgPicker(msg)
group.lastFocus = group.focusedChild
group.setFocus(false)
group.visible = false
' TODO - swap this based on target.mediatype
' types: [ Episode, Movie, Audio, Person, Studio, MusicArtist ]
group = CreateMovieDetailsGroup(node)
m.scene.appendChild(group)
m.overhang.title = group.overhangTitle
else if isNodeEvent(msg, "buttonSelected")
' If a button is selected, we have some determining to do
btn = getButton(msg)
@ -109,7 +132,22 @@ sub Main()
else if isNodeEvent(msg, "optionSelected")
button = msg.getRoSGNode()
if button.id = "goto_search"
print "Search goes here"
' Exit out of the side panel
panel.visible = false
if group.lastFocus <> invalid
group.lastFocus.setFocus(true)
else
group.setFocus(true)
end if
group.lastFocus = group.focusedChild
group.setFocus(false)
group.visible = false
group = CreateSearchPage()
m.scene.appendChild(group)
m.overhang.title = group.overhangTitle
group.findNode("SearchBox").findNode("search-input").setFocus(true)
group.findNode("SearchBox").findNode("search-input").active = true
else if button.id = "change_server"
unset_setting("server")
unset_setting("port")

View File

@ -506,41 +506,18 @@ sub ShowCollections(library)
end while
end sub
sub ShowSearchOptions(query)
' Search Results Page
port = m.port
screen = m.screen
scene = screen.CreateScene("SearchResults")
function CreateSearchPage()
' Search + Results Page
group = CreateObject("roSGNode", "SearchResults")
themeScene(scene)
search = group.findNode("SearchBox")
search.observeField("search_value", m.port)
options = scene.findNode("SearchSelect")
options = group.findNode("SearchSelect")
options.observeField("itemSelected", m.port)
sort_order = get_user_setting("search_sort_order", "Ascending")
sort_field = get_user_setting("search_sort_field", "SortName")
results = SearchMedia(query)
options.itemData = results
options.query = query
options.observeField("itemSelected", port)
while true
msg = wait(0, port)
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed() then
return
else if nodeEventQ(msg, "itemSelected")
target = getMsgRowTarget(msg)
' TODO - swap this based on target.mediatype
' types: [ Episode, Movie, Audio, Person, Studio, MusicArtist ]
ShowMovieDetails(target)
else
print msg
print msg.getField()
print msg.getData()
end if
end while
end sub
return group
end function
function CreateSidePanel(buttons, options)
group = CreateObject("roSGNode", "OptionsSlider")