jf-roku/components/JFMessageDialog.bs

74 lines
2.0 KiB
Plaintext
Raw Normal View History

2019-10-13 19:33:14 +00:00
sub init()
2021-07-09 20:08:32 +00:00
options = m.top.findNode("optionList")
options.focusBitmapBlendColor = "0x0cb0e8"
options.color = "0xffffff"
options.focusedColor = "0xffffff"
options.setFocus(true)
2019-10-13 19:33:14 +00:00
end sub
function onKeyEvent(key as string, press as boolean) as boolean
2021-07-09 20:08:32 +00:00
if key = "back"
m.top.backPressed = true
return true
end if
return false
2019-10-13 19:33:14 +00:00
end function
2019-10-14 16:56:22 +00:00
2020-03-04 02:46:26 +00:00
sub updateOptions()
2021-07-09 20:08:32 +00:00
for each item in m.top.options
row = CreateObject("roSGNode", "ContentNode")
row.title = item
m.top.findNode("content").appendChild(row)
end for
redraw()
2020-03-04 02:46:26 +00:00
end sub
sub updateMessage()
2021-07-09 20:08:32 +00:00
message = m.top.findNode("messageText")
message.text = m.top.message
redraw()
2020-03-04 02:46:26 +00:00
end sub
sub redraw()
2021-07-09 20:08:32 +00:00
boxWidth = 900
border = 40
itemSpacing = 40
optionHeight = 60
maxRows = 9
2020-03-04 02:46:26 +00:00
2021-07-09 20:08:32 +00:00
bg = m.top.findNode("dialogBackground")
text = m.top.findNode("messageText")
options = m.top.findNode("optionList")
fontHeight = m.top.fontHeight
fontWidth = m.top.fontWidth
2020-03-04 02:46:26 +00:00
2021-07-09 20:08:32 +00:00
if text.text.len() > 0
textWidth = boxWidth - (border * 2)
text.width = textWidth
text.numLines = int(fontWidth / textWidth) + 1
text.translation = [border, border]
textHeight = (fontHeight * text.numLines)
else
textHeight = 0
itemSpacing = border
end if
2020-03-04 02:46:26 +00:00
2021-07-09 20:08:32 +00:00
options.translation = [border * 2, textHeight + itemSpacing]
options.itemSize = [boxWidth - (border * 4), optionHeight]
options.itemSpacing = "[0,20]"
2020-03-04 02:46:26 +00:00
2021-07-09 20:08:32 +00:00
options.numRows = m.top.options.count()
if options.numRows > maxRows
options.numRows = maxRows
options.wrapDividerHeight = 0
options.vertFocusAnimationStyle = "fixedFocusWrap"
end if
2021-07-09 20:08:32 +00:00
boxHeight = options.translation[1] + (options.itemSize[1] * options.numRows) + (options.itemSpacing[1] * (options.NumRows - 1)) + border
2020-03-04 02:46:26 +00:00
2021-07-09 20:08:32 +00:00
bg.width = boxWidth
bg.height = boxHeight
2020-03-04 02:46:26 +00:00
2021-07-09 20:08:32 +00:00
m.top.translation = [(1920 - boxWidth) / 2, (1080 - boxHeight) / 2]
2020-03-04 02:46:26 +00:00
end sub