Skip to content

Commit 479b2a8

Browse files
committed
Update code docs
1 parent 4434e95 commit 479b2a8

4 files changed

Lines changed: 63 additions & 21 deletions

File tree

docs/components_home_HomeItem.bs.html

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
initItemIcon()
1515
initItemTextExtra()
1616
m.itemPoster.observeField("loadStatus", "onPosterLoadStatusChanged")
17+
m.itemIcon.observeField("loadStatus", "onIconLoadStatusChanged")
1718
initBackdrop()
1819
end sub
1920

@@ -361,25 +362,66 @@
361362
end if
362363
else
363364
m.backdrop.visible = true
364-
if m.itemIcon.uri <> ""
365-
m.itemIcon.visible = true
366-
end if
367365
backdropText = m.top.findNode("backdropText")
368366
if isValid(backdropText)
369-
' reposition backdroptext and itemIcon so they don't overlap
370-
m.itemIcon.translation = [(m.backdrop.width - m.itemIcon.width) / 2, ((m.backdrop.height - m.itemIcon.height) / 2) / 2]
371-
372-
backdropText.height = 0
373-
backdropText.translation = [backdropText.translation[0], ((m.backdrop.height - m.itemIcon.height) / 2) + m.itemIcon.height]
374-
fontSizeConstants = m.global.constants.font_sizes
375-
if len(backdropText.text) > 12
376-
backdropText.font.size = fontSizeConstants.large
377-
else if len(backdropText.text) > 35
378-
backdropText.font.size = fontSizeConstants.medium
379-
else if len(backdropText.text) > 65
380-
backdropText.font.size = fontSizeConstants.small
381-
end if
382367
backdropText.visible = true
368+
' Reset backdrop text to original position when poster fails to load
369+
resetBackdropTextPosition()
370+
end if
371+
end if
372+
end sub
373+
374+
'Handle icon image load status changes
375+
sub onIconLoadStatusChanged()
376+
if m.itemIcon.loadStatus = "ready" and m.itemIcon.uri <> ""
377+
' Icon loaded successfully
378+
m.itemIcon.visible = true
379+
' Only rearrange if backdrop is visible (poster didn't load)
380+
if m.backdrop.visible
381+
arrangeIconAndBackdropText()
382+
end if
383+
else
384+
' Icon failed to load or no URI set
385+
m.itemIcon.visible = false
386+
' Reset backdrop text position if backdrop is visible
387+
if m.backdrop.visible
388+
resetBackdropTextPosition()
389+
end if
390+
end if
391+
end sub
392+
393+
'Arrange icon and backdrop text when both are visible
394+
sub arrangeIconAndBackdropText()
395+
backdropText = m.top.findNode("backdropText")
396+
if isValid(backdropText)
397+
' reposition backdroptext and itemIcon so they don't overlap
398+
m.itemIcon.translation = [(m.backdrop.width - m.itemIcon.width) / 2, ((m.backdrop.height - m.itemIcon.height) / 2) / 2]
399+
400+
backdropText.height = 0
401+
backdropText.translation = [backdropText.translation[0], ((m.backdrop.height - m.itemIcon.height) / 2) + m.itemIcon.height]
402+
403+
' Set font size based on text length
404+
fontSizeConstants = m.global.constants.font_sizes
405+
if len(backdropText.text) > 12
406+
backdropText.font.size = fontSizeConstants.large
407+
else if len(backdropText.text) > 35
408+
backdropText.font.size = fontSizeConstants.medium
409+
else if len(backdropText.text) > 65
410+
backdropText.font.size = fontSizeConstants.small
411+
end if
412+
end if
413+
end sub
414+
415+
'Reset backdrop text to original position
416+
sub resetBackdropTextPosition()
417+
backdropText = m.top.findNode("backdropText")
418+
if isValid(backdropText)
419+
backdropText.height = 231
420+
backdropText.translation = [9, 9]
421+
' Reset font size to original
422+
fontSizeConstants = m.global.constants.font_sizes
423+
if isValid(fontSizeConstants)
424+
backdropText.font.size = fontSizeConstants.large ' or whatever the original size should be
383425
end if
384426
end if
385427
end sub

docs/components_ui_button_TextButton.bs.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@
9494
' Use font size for height to avoid stale localBoundingRect() issues
9595
textHeight = fontSize
9696

97-
print "[TextButton] text='"; m.buttonText.text; "', length="; textLength; ", charWidth="; charWidth; ", textWidth="; textWidth; ", textHeight="; textHeight
97+
' print "[TextButton] text='"; m.buttonText.text; "', length="; textLength; ", charWidth="; charWidth; ", textWidth="; textWidth; ", textHeight="; textHeight
9898

9999
' Calculate button dimensions with padding
100100
buttonWidth = textWidth + (m.top.padding * 2)
101101
buttonHeight = textHeight + (m.top.padding * 2)
102102

103-
print "[TextButton] size with padding: width=", buttonWidth, ", height=", buttonHeight
103+
' print "[TextButton] size with padding: width=", buttonWidth, ", height=", buttonHeight
104104

105105
' Ensure minimum dimensions (this is the ONLY place minWidth should be enforced)
106106
if buttonWidth < m.top.minWidth
@@ -110,7 +110,7 @@
110110
buttonHeight = m.top.minHeight
111111
end if
112112

113-
print "[TextButton] ACTUAL size (using minWidth): width=", buttonWidth, ", height=", buttonHeight
113+
' print "[TextButton] ACTUAL size (using minWidth): width=", buttonWidth, ", height=", buttonHeight
114114

115115
' Set background size
116116
m.buttonBackground.width = buttonWidth

docs/data/search.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/module-HomeItem.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)