70 lines
1.5 KiB
Plaintext
70 lines
1.5 KiB
Plaintext
import "pkg:/source/utils/Logging.bs"
|
|
import "pkg:/source/utils/TimeUtils.bs"
|
|
import "pkg:/source/utils/Types.bs"
|
|
|
|
function Init()
|
|
m.durationRect = m.top.FindNode("durationRect")
|
|
m.durationLabel = m.top.FindNode("durationLabel")
|
|
end function
|
|
|
|
function OnContentSet() as void
|
|
content = m.top.itemContent
|
|
if content = invalid
|
|
return
|
|
end if
|
|
|
|
m.top.title = content.title
|
|
m.top.thumbnailUri = content.thumbnail
|
|
|
|
if ValidInt(content.lengthSeconds) <> 0
|
|
SetDurationText(content.lengthText)
|
|
m.top.durationRectVisible = true
|
|
else
|
|
m.top.durationRectVisible = false
|
|
end if
|
|
|
|
SetHighlight()
|
|
end function
|
|
|
|
function OnIndexSet() as void
|
|
SetHighlight()
|
|
end function
|
|
|
|
function SetDurationText(text as string) as void
|
|
m.top.duration = text
|
|
|
|
label = m.durationLabel
|
|
rect = m.durationRect
|
|
|
|
if label = invalid or rect = invalid
|
|
return
|
|
end if
|
|
|
|
rectParent = rect.getParent()
|
|
size = label.localBoundingRect()
|
|
|
|
rect.width = size.width + 16
|
|
rect.translation = [rectParent.width - rect.width, rect.translation[1]]
|
|
end function
|
|
|
|
function SetHighlight() as void
|
|
content = m.top.itemContent
|
|
if content = invalid
|
|
return
|
|
end if
|
|
|
|
contentIndex = content.queueIndex
|
|
index = m.top.index
|
|
|
|
highlighted = contentIndex = index
|
|
|
|
if highlighted
|
|
' bs:disable-next-line LINT3023
|
|
m.top.thumbnailBlendColor = "#FFFFFFFF"
|
|
else
|
|
m.top.thumbnailBlendColor = "#606060FF"
|
|
end if
|
|
|
|
m.top.highlightVisible = highlighted
|
|
end function
|