components_ui_timegrid_JRTimeGrid.bs

import "pkg:/source/utils/misc.bs"

sub init()
  colorConstants = m.global.constants.colors

  m.top.automaticLoadingDataFeedback = false
  m.top.showLoadingDataFeedback = true
  m.top.showPastTimeScreen = true
  m.top.focusBitmapUri = "pkg:/images/white-focus.9.png"
  m.top.focusBitmapBlendColor = colorConstants.primary
  m.top.iconFocusedColor = "#ff0000"

  m.top.pastTimeScreenBlendColor = colorConstants.text_disabled
  m.top.currentTimeIndicatorColor = colorConstants.primary

  m.top.nowBarWidth = 12
  m.top.timeLabelColor = colorConstants.text_secondary
  m.top.nowBarBlendColor = colorConstants.secondary
  m.top.channelInfoTextColor = colorConstants.text_secondary
  m.top.programTitleColor = colorConstants.text_primary
  m.top.programTitleFocusedColor = colorConstants.text_primary

  ' disable gradient overlay
  overlayPoster = m.top.getChild(2)
  if isValid(overlayPoster) then overlayPoster.visible = false

  if m.global.session.user.settings["ui.font.fallback"] = true
    applyFallbackFont(m.top.timeLabelFont)
    applyFallbackFont(m.top.programTitleFont)
    applyFallbackFont(m.top.channelInfoFont)
  end if
end sub

sub applyFallbackFont(fontNode as object)
  if not isValid(fontNode) then return

  fontNode.uri = "tmp:/font"
  currentSize = fontNode.size

  ' Apply the global scale factor
  fontScaleFactor = m.global.session.user.fontScaleFactor
  if isValid(fontScaleFactor) and fontScaleFactor > 0
    scaledSize = currentSize * fontScaleFactor
    fontNode.size = scaledSize
  else
    print "ERROR - JRTimeGrid applyFallbackFont: Invalid font scale factor"
    return
  end if
end sub