Add an options side panel

This commit is contained in:
Nick Bisby 2019-03-17 18:07:57 -05:00
parent 04fc7e71be
commit 3658f0b77f
No known key found for this signature in database
GPG Key ID: F6E0C4E6D0B5EB36
4 changed files with 93 additions and 0 deletions

View File

@ -94,6 +94,14 @@
if key = "down" and (m.top.itemFocused + 1) = m.top.content.getChildCount() if key = "down" and (m.top.itemFocused + 1) = m.top.content.getChildCount()
m.top.getScene().findNode("pager").setFocus(true) m.top.getScene().findNode("pager").setFocus(true)
m.top.getScene().findNode("pager").getChild(0).setFocus(true) m.top.getScene().findNode("pager").getChild(0).setFocus(true)
return true
else if key = "options"
options = m.top.getScene().findNode("options")
list = options.findNode("panelList")
options.visible = true
list.setFocus(true)
return true return true
end if end if

View File

@ -11,5 +11,8 @@
/> />
<Rectangle id="footerBackdrop" /> <Rectangle id="footerBackdrop" />
<Pager id="pager" /> <Pager id="pager" />
<OptionsSlider id="options" />
</children> </children>
</component> </component>

61
components/options.xml Normal file
View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="OptionsSlider" extends="PanelSet">
<children>
<ListPanel id="panel">
<Rectangle id="backdrop" />
<LabelList id="panelList">
<ContentNode id="fieldList" role="content" />
</LabelList>
</ListPanel>
</children>
<interface>
<field id="options" type="nodearray" onChange="setFields" />
<field id="escape" type="boolean" alwaysNotify="true" />
</interface>
<script type="text/brightscript">
<![CDATA[
sub init()
m.top.visible = false
panel = m.top.findNode("panel")
panel.panelSize = "small"
panel.leftPosition = 0
panel.focusable = true
panel.hasNextPanel = false
panel.leftOnly = true
list = m.top.findNode("panelList")
panel.list = list
bd = m.top.findNode("backdrop")
bd.color = "#101010DD"
bd.translation = [0, 0]
dimensions = m.top.getScene().currentDesignResolution
bd.width = 575
bd.height = dimensions.height
end sub
sub setFields()
options = m.top.options
row = m.top.findNode("fieldList")
row.removeChildren(row.getChildren(-1, 0))
row.appendChildren(options)
end sub
function onKeyEvent(key as string, press as boolean) as boolean
if not press then return false
if key = "options"
m.top.visible = false
m.top.escape = true
return true
end if
return false
end function
]]>
</script>
</component>

View File

@ -168,12 +168,33 @@ sub ShowMovieOptions(library)
pager.observeField("escape", port) pager.observeField("escape", port)
pager.observeField("pageSelected", port) pager.observeField("pageSelected", port)
sidepanel = scene.findNode("options")
movie_options = [
{"title": "Sort Field",
"key": "movie_sort_field",
"values": ["blah", "this", "that"]},
{"title": "Sort Order",
"key": "movie_sort_order",
"values": ["blah", "this", "that"]}
]
new_options = []
for each opt in movie_options
o = CreateObject("roSGNode", "ContentNode")
o.title = opt.title
new_options.append([o])
end for
sidepanel.options = new_options
sidepanel.observeField("escape", port)
while true while true
msg = wait(0, port) msg = wait(0, port)
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed() then if type(msg) = "roSGScreenEvent" and msg.isScreenClosed() then
return return
else if nodeEventQ(msg, "escape") and msg.getNode() = "pager" else if nodeEventQ(msg, "escape") and msg.getNode() = "pager"
options.setFocus(true) options.setFocus(true)
else if nodeEventQ(msg, "escape") and msg.getNode() = "options"
options.setFocus(true)
else if nodeEventQ(msg, "pageSelected") and pager.pageSelected <> invalid else if nodeEventQ(msg, "pageSelected") and pager.pageSelected <> invalid
pager.pageSelected = invalid pager.pageSelected = invalid
page_num = int(val(msg.getData().id)) page_num = int(val(msg.getData().id))