Enable title scrolling on ItemGrid (#214)
* Enable title scrolling on ItemGrid * Added duplicate "Static" text title To stop appearance of ScrollingLabel when it stops scrolling
This commit is contained in:
parent
3a4b4a0845
commit
8e15423185
|
@ -1,21 +1,13 @@
|
|||
sub init()
|
||||
m.title = m.top.findNode("title")
|
||||
m.title.translation = [2, 0]
|
||||
|
||||
m.staticTitle = m.top.findNode("staticTitle")
|
||||
m.poster = m.top.findNode("poster")
|
||||
m.poster.translation = [2, 0]
|
||||
|
||||
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")
|
||||
|
||||
image = invalid
|
||||
if m.top.itemContent <> invalid and m.top.itemContent.image <> invalid
|
||||
|
@ -32,12 +24,14 @@ sub updateSize()
|
|||
maxSize = m.top.getParent().itemSize
|
||||
|
||||
' Always reserve the bottom for the Poster Title
|
||||
m.title.wrap = true
|
||||
m.title.maxLines = 2
|
||||
m.title.width = maxSize[0]
|
||||
m.title.maxWidth = maxSize[0]
|
||||
m.title.height = 80
|
||||
m.title.translation = [0, int(maxSize[1]) - m.title.height]
|
||||
|
||||
m.staticTitle.width = maxSize[0]
|
||||
m.staticTitle.height = 80
|
||||
m.staticTitle.translation = [0, int(maxSize[1]) - m.title.height]
|
||||
|
||||
ratio = 1.5
|
||||
if image <> invalid and image.width <> 0 and image.height <> 0
|
||||
ratio = image.height / image.width
|
||||
|
@ -61,15 +55,32 @@ sub updateSize()
|
|||
end sub
|
||||
|
||||
function itemContentChanged() as void
|
||||
|
||||
m.title = m.top.findNode("title")
|
||||
m.poster = m.top.findNode("poster")
|
||||
itemData = m.top.itemContent
|
||||
m.title.text = itemData.title
|
||||
if itemData.json.lookup("Type") = "Episode" and itemData.json.IndexNumber <> invalid
|
||||
m.title.text = StrI(itemData.json.IndexNumber) + ". " + m.title.text
|
||||
end if
|
||||
m.staticTitle.text = m.title.text
|
||||
|
||||
m.poster.uri = itemData.posterUrl
|
||||
|
||||
updateSize()
|
||||
end function
|
||||
|
||||
'
|
||||
' Enable title scrolling based on item Focus
|
||||
sub focusChanged()
|
||||
|
||||
if m.top.itemHasFocus = true then
|
||||
m.title.repeatCount = -1
|
||||
m.staticTitle.visible = false
|
||||
m.title.visible = true
|
||||
|
||||
else
|
||||
m.title.repeatCount = 0
|
||||
m.staticTitle.visible = true
|
||||
m.title.visible = false
|
||||
end if
|
||||
|
||||
end sub
|
||||
|
|
|
@ -2,15 +2,23 @@
|
|||
<component name="ListPoster" extends="Group">
|
||||
<children>
|
||||
<Rectangle id="backdrop" />
|
||||
<Poster id="poster" />
|
||||
<Label id="title"
|
||||
<Poster id="poster" translation="[2, 0]" />
|
||||
<ScrollingLabel id="title"
|
||||
horizAlign="center"
|
||||
font="font:SmallSystemFont"
|
||||
repeatCount="0"
|
||||
visible="false"
|
||||
/>
|
||||
<Label id="staticTitle"
|
||||
horizAlign="center"
|
||||
font="font:SmallSystemFont"
|
||||
wrap="false"
|
||||
/>
|
||||
</children>
|
||||
<interface>
|
||||
<field id="itemContent" type="node" onChange="itemContentChanged"/>
|
||||
<field id="itemWidth" type="integer" />
|
||||
<field id="itemHasFocus" type="boolean" onChange="focusChanged" />
|
||||
<!-- mediatype -->
|
||||
</interface>
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user