jf-roku/components/JFOverhang.brs

172 lines
4.4 KiB
Plaintext
Raw Normal View History

sub init()
2021-07-09 20:08:32 +00:00
m.top.id = "overhang"
' hide seperators till they're needed
leftSeperator = m.top.findNode("overlayLeftSeperator")
leftSeperator.visible = "false"
2022-07-16 02:28:59 +00:00
m.rightSeperator = m.top.findNode("overlayRightSeperator")
m.hideClock = get_user_setting("ui.design.hideclock") = "true"
2021-07-09 20:08:32 +00:00
' set font sizes
optionText = m.top.findNode("overlayOptionsText")
optionText.font.size = 20
optionStar = m.top.findNode("overlayOptionsStar")
optionStar.font.size = 58
overlayMeridian = m.top.findNode("overlayMeridian")
overlayMeridian.font.size = 20
2022-07-16 02:28:59 +00:00
m.overlayRightGroup = m.top.findNode("overlayRightGroup")
m.overlayTimeGroup = m.top.findNode("overlayTimeGroup")
2022-09-19 23:34:36 +00:00
m.slideDownAnimation = m.top.findNode("slideDown")
m.slideUpAnimation = m.top.findNode("slideUp")
2022-07-16 02:28:59 +00:00
if not m.hideClock
' get system preference clock format (12/24hr)
di = CreateObject("roDeviceInfo")
m.clockFormat = di.GetClockFormat()
' grab current time
currentTime = CreateObject("roDateTime")
currentTime.ToLocalTime()
m.currentHours = currentTime.GetHours()
m.currentMinutes = currentTime.GetMinutes()
' start timer
m.currentTimeTimer = m.top.findNode("currentTimeTimer")
m.currentTimeTimer.control = "start"
m.currentTimeTimer.ObserveField("fire", "updateTime")
updateTimeDisplay()
end if
setClockVisibility()
end sub
2020-02-26 22:55:47 +00:00
2022-09-19 23:34:36 +00:00
sub onVisibleChange()
if m.top.disableMoveAnimation
m.top.translation = [0, 0]
return
end if
if m.top.isVisible
m.slideDownAnimation.control = "start"
return
end if
m.slideUpAnimation.control = "start"
end sub
sub updateTitle()
2021-07-09 20:08:32 +00:00
leftSeperator = m.top.findNode("overlayLeftSeperator")
if m.top.title <> ""
leftSeperator.visible = "true"
else
leftSeperator.visible = "false"
end if
title = m.top.findNode("overlayTitle")
title.text = m.top.title
2022-07-16 02:28:59 +00:00
if not m.hideClock
resetTime()
end if
end sub
2020-02-26 22:55:47 +00:00
2022-07-16 02:28:59 +00:00
sub setClockVisibility()
if m.hideClock
m.overlayRightGroup.removeChild(m.overlayTimeGroup)
end if
end sub
sub setRightSeperatorVisibility()
if m.hideClock
m.top.removeChild(m.rightSeperator)
return
end if
2021-07-09 20:08:32 +00:00
if m.top.currentUser <> ""
2022-07-16 02:28:59 +00:00
m.rightSeperator.visible = "true"
2021-07-09 20:08:32 +00:00
else
2022-07-16 02:28:59 +00:00
m.rightSeperator.visible = "false"
2021-07-09 20:08:32 +00:00
end if
2022-07-16 02:28:59 +00:00
end sub
sub updateUser()
setRightSeperatorVisibility()
2021-07-09 20:08:32 +00:00
user = m.top.findNode("overlayCurrentUser")
user.text = m.top.currentUser
end sub
2020-02-26 22:55:47 +00:00
sub updateTime()
2021-07-09 20:08:32 +00:00
if (m.currentMinutes + 1) > 59
m.currentHours = m.currentHours + 1
m.currentMinutes = 0
else
m.currentMinutes = m.currentMinutes + 1
end if
2020-02-26 22:55:47 +00:00
2021-07-09 20:08:32 +00:00
updateTimeDisplay()
end sub
2020-02-26 22:55:47 +00:00
sub resetTime()
2021-07-09 20:08:32 +00:00
m.currentTimeTimer.control = "stop"
2020-02-26 22:55:47 +00:00
2021-07-09 20:08:32 +00:00
currentTime = CreateObject("roDateTime")
m.currentTimeTimer.control = "start"
2020-02-26 22:55:47 +00:00
2021-07-09 20:08:32 +00:00
currentTime.ToLocalTime()
2020-02-26 22:55:47 +00:00
2021-07-09 20:08:32 +00:00
m.currentHours = currentTime.GetHours()
m.currentMinutes = currentTime.GetMinutes()
2020-02-26 22:55:47 +00:00
2021-07-09 20:08:32 +00:00
updateTimeDisplay()
end sub
2020-02-26 22:55:47 +00:00
sub updateTimeDisplay()
2021-07-09 20:08:32 +00:00
overlayHours = m.top.findNode("overlayHours")
overlayMinutes = m.top.findNode("overlayMinutes")
overlayMeridian = m.top.findNode("overlayMeridian")
if m.clockFormat = "24h"
overlayMeridian.text = ""
if m.currentHours < 10
overlayHours.text = "0" + StrI(m.currentHours).trim()
else
overlayHours.text = m.currentHours
end if
2020-02-26 22:55:47 +00:00
else
2021-07-09 20:08:32 +00:00
if m.currentHours < 12
overlayMeridian.text = "AM"
if m.currentHours = 0
overlayHours.text = "12"
else
overlayHours.text = m.currentHours
end if
else
overlayMeridian.text = "PM"
if m.currentHours = 12
overlayHours.text = "12"
else
overlayHours.text = m.currentHours - 12
end if
end if
2020-02-26 22:55:47 +00:00
end if
2021-07-09 20:08:32 +00:00
if m.currentMinutes < 10
overlayMinutes.text = "0" + StrI(m.currentMinutes).trim()
2020-02-26 22:55:47 +00:00
else
2021-07-09 20:08:32 +00:00
overlayMinutes.text = m.currentMinutes
2020-02-26 22:55:47 +00:00
end if
end sub
2020-02-26 22:55:47 +00:00
sub updateOptions()
2021-07-09 20:08:32 +00:00
optionText = m.top.findNode("overlayOptionsText")
optionStar = m.top.findNode("overlayOptionsStar")
if m.top.showOptions = true
optionText.visible = true
optionStar.visible = true
else
optionText.visible = false
optionStar.visible = false
end if
2022-05-30 12:57:40 +00:00
end sub