jf-roku/components/JFMessageDialog.brs

74 lines
1.8 KiB
Plaintext
Raw Normal View History

2019-10-13 19:33:14 +00:00
sub init()
2020-03-04 02:53:44 +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
2020-03-04 02:46:26 +00:00
if key = "back"
m.top.backPressed = true
2019-10-13 19:33:14 +00:00
return true
end if
return false
end function
2019-10-14 16:56:22 +00:00
2020-03-04 02:46:26 +00:00
sub updateOptions()
for each item in m.top.options
row = CreateObject("roSGNode", "ContentNode")
row.title = item
m.top.findNode("content").appendChild(row)
end for
redraw()
end sub
sub updateMessage()
message = m.top.findNode("messageText")
message.text = m.top.message
redraw()
end sub
sub redraw()
boxWidth = 900
border = 40
itemSpacing = 40
optionHeight = 60
maxRows = 9
2020-03-04 02:46:26 +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
if text.text.len() > 0
2020-03-04 02:46:26 +00:00
textWidth = boxWidth - ( border * 2 )
text.width = textWidth
text.numLines = int(fontWidth / textWidth) + 1
text.translation = [ border , border ]
2020-03-04 02:53:44 +00:00
textHeight = (fontHeight * text.numLines)
2020-03-04 02:46:26 +00:00
else
textHeight = 0
itemSpacing = border
end if
options.translation = [ border * 2, textHeight + itemSpacing]
options.itemSize = [ boxWidth - ( border * 4 ), optionHeight ]
2020-03-04 02:53:44 +00:00
options.itemSpacing = "[0,20]"
2020-03-04 02:46:26 +00:00
options.numRows = m.top.options.count()
if options.numRows > maxRows
options.numRows = maxRows
options.wrapDividerHeight = 0
options.vertFocusAnimationStyle= "fixedFocusWrap"
end if
2020-03-04 02:46:26 +00:00
boxHeight = options.translation[1] + (options.itemSize[1] * options.numRows ) + (options.itemSpacing[1] * (options.NumRows - 1)) + border
bg.width = boxWidth
bg.height = boxHeight
m.top.translation = [(1920 - boxWidth)/2 , (1080 - boxHeight)/2]
end sub