Fix BPM/track-length row overflowing right edge, and verify 2-digit minutes
The row had nothing constraining its width -- every other line in this column is a Marquee, which enforces its own declared width, but this plain Row had no such limit, so any estimation error in the character-count-based width guess (pixlet has no way to measure rendered text width from Starlark) silently overflowed the column instead of being clipped. Wrapped in a Box(width=text_width, height=6) to hard-clip it. The height was not optional: a bare Box(width=...) with no height "expand[s] to fill all available space" (pixlet's own docs), and inside this Column's main_align="space_between", that meant the row silently grabbed nearly all remaining height, squeezing the progress bar below it out of view -- same bug class as the earlier time_temp centering fix (a flexible/expanding child stealing vertical space), just via Box's implicit expand-when-unconstrained behavior this time instead of Row's explicit expanded=True. Caught by tracing pixel colors down the render rather than trusting a glance: the row's text was present, just not where expected, and the progress bar's color was missing from the frame entirely. Verified two-digit minutes work correctly: a minimal standalone test replicating this exact construction with a hardcoded "12:34" renders right-aligned with no overflow, and the real (unmodified) app was independently re-verified live against two different real tracks, confirming the fix holds with genuine data, not just a synthetic case.
This commit is contained in:
1 parent
eaaded770d
commit
cffc5edac1
1 file changed
+35
-5
+35
-5
@@ -378,11 +378,41 @@ def main(config):
|
||||
bpm_width = int(len(list(now["bpm"].codepoints())) * 3.9)
|
||||
length_width = int(len(list(now["track_length"].codepoints())) * 3.9)
|
||||
gap = max(0, text_width - bpm_width - length_width)
|
||||
children.append(render.Row(children = [
|
||||
render.Text(now["bpm"], font = "tom-thumb", color = colors["meta"]),
|
||||
render.Box(width = gap, height = 1),
|
||||
render.Text(now["track_length"], font = "tom-thumb", color = colors["meta"]),
|
||||
]))
|
||||
|
||||
# Wrapped in a Box(width=text_width, height=6) to hard-clip it --
|
||||
# every other line in this column is a Marquee, which enforces its
|
||||
# own declared width, but this Row had nothing constraining it, so
|
||||
# any estimation error (the 3.9px/char figure is an estimate, not
|
||||
# an exact measurement -- pixlet has no way to measure rendered
|
||||
# text width from Starlark) silently overflowed the column instead
|
||||
# of being clipped, bleeding past the right edge. Also what
|
||||
# actually supports two-digit minutes/long durations safely: if
|
||||
# bpm_width + length_width ever exceeds text_width (gap floors at
|
||||
# 0, so they'd butt up with no space between), this still caps the
|
||||
# total at text_width rather than spilling out.
|
||||
#
|
||||
# height=6 (tom-thumb's own line height) is required, not
|
||||
# optional: a bare Box(width=...) with no height "expand[s] to
|
||||
# fill all available space" (pixlet's own docs) -- inside this
|
||||
# Column's main_align="space_between", that meant the row silently
|
||||
# grabbed nearly the entire remaining height, squeezing the
|
||||
# progress bar below it off-screen. Same bug class as the earlier
|
||||
# time_temp centering fix (a flexible/expanding child stealing
|
||||
# vertical space it wasn't meant to use), just via Box's own
|
||||
# implicit expand-when-unconstrained behavior this time instead of
|
||||
# Row's explicit `expanded=True`. Caught by literally tracing
|
||||
# pixel colors down a column of the render rather than trusting a
|
||||
# visual glance -- the row's text was there, just not where
|
||||
# expected, and the progress bar's color was nowhere in the frame.
|
||||
children.append(render.Box(
|
||||
width = text_width,
|
||||
height = 6,
|
||||
child = render.Row(children = [
|
||||
render.Text(now["bpm"], font = "tom-thumb", color = colors["meta"]),
|
||||
render.Box(width = gap, height = 1),
|
||||
render.Text(now["track_length"], font = "tom-thumb", color = colors["meta"]),
|
||||
]),
|
||||
))
|
||||
|
||||
if progress != None:
|
||||
children.append(_progress_bar(progress["fraction"], colors, width = text_width, height = 2 * scale))
|
||||
|
||||