jf-roku/components/ListPoster.xml

72 lines
1.7 KiB
XML

<?xml version="1.0" encoding="utf-8" ?>
<component name="ListPoster" extends="Group">
<children>
<Rectangle id="backdrop"
translation="[2, 0]"
/>
<Poster id="poster"
translation="[2, 0]"
/>
<Label id="title"
horizAlign="center"
font="font:SmallSystemFont"
/>
</children>
<interface>
<field id="itemContent" type="node" onChange="itemContentChanged"/>
<field id="itemWidth" type="integer" />
<!-- mediatype -->
</interface>
<script type="text/brightscript">
<![CDATA[
sub init()
m.title = m.top.findNode("title")
m.poster = m.top.findNode("poster")
m.backdrop = m.top.findNode("backdrop")
m.backdrop.color = "#404040FF"
updateSize()
end sub
sub updateSize()
m.title = m.top.findNode("title")
m.poster = m.top.findNode("poster")
m.backdrop = m.top.findNode("backdrop")
' TODO - abstract this in case the parent doesnt have itemSize
maxSize = m.top.getParent().itemSize
m.poster.width = int(maxSize[0]) - 4
m.poster.height = m.poster.width * 1.5
m.backdrop.width = m.poster.width
m.backdrop.height = m.poster.height
m.title.width = m.poster.width
m.title.height = int(maxSize[1]) - m.poster.height
m.title.translation = [0, m.poster.height]
end sub
function itemContentChanged() as void
updateSize()
m.title = m.top.findNode("title")
m.poster = m.top.findNode("poster")
itemData = m.top.itemContent
m.title.text = itemData.title
m.poster.uri = itemData.posterUrl
if itemData.mediaType = "Episode"
m.poster.height = m.poster.width * 9/16
m.poster.translation = [2, m.poster.width / 2]
end if
end function
]]>
</script>
</component>