components_ui_rowlist_JRRowList.bs

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

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

  m.top.showRowLabel = [true]
  m.top.showRowCounter = [true]
  m.top.rowFocusAnimationStyle = "fixedFocusWrap"
  m.top.vertFocusAnimationStyle = "fixedFocusWrap"
  m.top.focusBitmapBlendColor = colorConstants.primary ' color of the item selector
  m.top.itemSpacing = [0, 105] ' spacing between rows
  m.top.rowItemSpacing = [27, 0] ' spacing between items in a row

  m.top.focusXOffset = [96] ' align item selector with edge of "action" safe zone

  m.top.rowLabelOffset = [96, 21] ' align row label with edge of "action" safe zone
  m.top.rowLabelColor = colorConstants.text_primary
  m.top.rowLabelFont = "font:MediumSystemFont"
  m.top.rowLabelFont.size = m.global.constants.font_sizes.medium

  if m.global.session.user.settings["ui.font.fallback"] = true
    m.top.rowLabelFont.uri = "tmp:/font"
    applyFallbackFontScale()
  end if

end sub

sub applyFallbackFontScale()
  ' Get the current font size if one is set, or use a default
  currentSize = m.top.rowLabelFont.size
  if currentSize <= 0
    print "ERROR - JRRowList applyFallbackFontScale: Invalid font size"
    return
  end if

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