jf-roku/components/ItemGrid/GridItem.brs

102 lines
3.1 KiB
Plaintext
Raw Normal View History

sub init()
2021-07-09 20:08:32 +00:00
m.posterMask = m.top.findNode("posterMask")
m.itemPoster = m.top.findNode("itemPoster")
m.itemIcon = m.top.findNode("itemIcon")
m.posterText = m.top.findNode("posterText")
m.itemText = m.top.findNode("itemText")
m.backdrop = m.top.findNode("backdrop")
2021-07-09 20:08:32 +00:00
m.itemPoster.observeField("loadStatus", "onPosterLoadStatusChanged")
2021-07-09 20:08:32 +00:00
m.itemText.translation = [0, m.itemPoster.height + 7]
m.alwaysShowTitles = get_user_setting("itemgrid.alwaysShowTitles") = "true"
m.itemText.visible = m.alwaysShowTitles
' Add some padding space when Item Titles are always showing
if m.alwaysShowTitles then m.itemText.maxWidth = 250
2021-07-09 20:08:32 +00:00
'Parent is MarkupGrid and it's parent is the ItemGrid
topParent = m.top.GetParent().GetParent()
'Get the imageDisplayMode for these grid items
if topParent.imageDisplayMode <> invalid
m.itemPoster.loadDisplayMode = topParent.imageDisplayMode
end if
end sub
sub itemContentChanged()
2021-07-09 20:08:32 +00:00
' Set Random background colors from pallet
posterBackgrounds = m.global.constants.poster_bg_pallet
m.backdrop.blendColor = posterBackgrounds[rnd(posterBackgrounds.count()) - 1]
itemData = m.top.itemContent
if itemData = invalid then return
if itemData.type = "Movie"
m.itemPoster.uri = itemData.PosterUrl
m.itemText.text = itemData.Title
else if itemData.type = "Series"
m.itemPoster.uri = itemData.PosterUrl
m.itemText.text = itemData.Title
else if itemData.type = "Boxset"
m.itemPoster.uri = itemData.PosterUrl
m.itemText.text = itemData.Title
else if itemData.type = "TvChannel"
m.itemPoster.uri = itemData.PosterUrl
m.itemText.text = itemData.Title
else if itemData.type = "Folder"
m.itemPoster.uri = itemData.PosterUrl
m.itemIcon.uri = itemData.iconUrl
m.itemText.text = itemData.Title
else if itemData.type = "Video"
m.itemPoster.uri = itemData.PosterUrl
m.itemText.text = itemData.Title
2022-02-06 15:37:02 +00:00
else if itemData.type = "Photo"
m.itemPoster.uri = itemData.PosterUrl
m.itemText.text = itemData.Title
2021-07-09 20:08:32 +00:00
else
print "Unhandled Grid Item Type: " + itemData.type
2021-07-09 20:08:32 +00:00
end if
'If Poster not loaded, ensure "blue box" is shown until loaded
if m.itemPoster.loadStatus <> "ready"
m.backdrop.visible = true
m.posterText.visible = true
end if
m.posterText.text = m.itemText.text
end sub
'
2020-06-11 06:57:31 +00:00
'Use FocusPercent to animate scaling of Poser Image
sub focusChanging()
2021-07-09 20:08:32 +00:00
scaleFactor = 0.85 + (m.top.focusPercent * 0.15)
m.posterMask.scale = [scaleFactor, scaleFactor]
2020-06-11 06:57:31 +00:00
end sub
'
'Display or hide title Visibility on focus change
sub focusChanged()
2021-07-09 20:08:32 +00:00
if m.top.itemHasFocus = true
m.itemText.visible = true
m.itemText.repeatCount = -1
else
m.itemText.visible = m.alwaysShowTitles
2021-07-09 20:08:32 +00:00
m.itemText.repeatCount = 0
end if
end sub
'Hide backdrop and text when poster loaded
sub onPosterLoadStatusChanged()
2021-07-09 20:08:32 +00:00
if m.itemPoster.loadStatus = "ready"
m.backdrop.visible = false
m.posterText.visible = false
end if
end sub