components_ui_labellist_JRLabelList.bs
' bsc-disable-file print-locations — legacy print() sites; migration to m.log.* tracked by tech-debt.md#legacy-print-statements
import "pkg:/source/utils/listTheme.bs"
import "pkg:/source/utils/misc.bs"
sub init()
constants = m.global.constants
globalUser = m.global.user
m.top.vertFocusAnimationStyle = "floatingFocus"
' Shared with every other list in the app — see source/utils/listTheme.bs
applyListFocusChrome(m.top)
m.top.font.size = constants.fontSizeMedium
m.top.color = constants.colorTextPrimary
m.top.focusedFont = "font:MediumSystemFont"
m.top.focusedFont.size = constants.fontSizeMedium
m.top.focusedColor = constants.colorTextPrimary
m.top.textHorizAlign = "center"
m.top.numRows = 10
m.top.itemSpacing = [0, 24] ' spacing between labels
if globalUser.settings.uiFontFallback = true
m.top.font.uri = "tmp:/font"
m.top.focusedFont.uri = "tmp:/font"
applyFallbackFontScale(globalUser.fontScaleFactor)
end if
end sub
sub applyFallbackFontScale(fontScaleFactor as float)
' Get the current font size if one is set, or use a default
currentSize = m.top.font.size
if currentSize <= 0
print "ERROR - JRLabelList applyFallbackFontScale: Invalid font size"
return
end if
' Apply the global scale factor
if isValid(fontScaleFactor) and fontScaleFactor > 0
scaledSize = currentSize * fontScaleFactor
m.top.font.size = scaledSize
m.top.focusedFont.size = scaledSize
else
print "ERROR - JRLabelList applyFallbackFontScale: Invalid font scale factor"
return
end if
end sub