Fix centering adding vertical space and displacing the progress bar

render.Row(expanded=True, main_align="center") correctly centered the
time/temp text horizontally, but `expanded` also grabbed extra
*vertical* space from the enclosing Column (main_align="space_between"),
which pushed the progress bar further down than intended.

Replaced with a computed left Padding instead -- only nudges this one
line horizontally, so it can't affect the Column's vertical
distribution the way a flexible/expanding child can. tom-thumb is
variable-width, so the padding amount is an estimate (~3.9px/char,
measured via the CLI against several real time/temp strings) rather
than pixel-exact, but close enough not to look off-center for strings
in the length range this branch allows.

Separately verified (pixel-sampled, not just eyeballed) that the
progress bar was never actually missing -- confirmed present with the
exact "bar_empty" color at every recent commit, including before this
fix. It's just low-contrast at 0% progress (dark purple on near-black),
which is what a one-shot `pixlet render` always shows (empty cache ->
elapsed=0 -> fraction=0.0), not a regression.
This commit is contained in:
poprhythm committed 2026-10-10 14:52:37 -04:00
1 parent fc5bb11152
commit adb09a344c
1 file changed
+16 -1
+16 -1
View File
@@ -245,8 +245,23 @@ def main(config):
# scrolling it -- easy to mistake for "the centering didn't work"). # scrolling it -- easy to mistake for "the centering didn't work").
time_temp_char_count = len(list(now["time_temp"].codepoints())) time_temp_char_count = len(list(now["time_temp"].codepoints()))
time_temp_fits = scale == 2 and time_temp_char_count <= 15 time_temp_fits = scale == 2 and time_temp_char_count <= 15
# Centered via a computed left Padding, not render.Row(expanded=True,
# main_align="center") -- that version centered the text correctly,
# but Row's `expanded` also grabbed extra *vertical* space from the
# enclosing Column (main_align="space_between"), which pushed the
# progress bar below it out of view. Padding only nudges this one
# line horizontally, so it can't affect the Column's vertical
# distribution the way a flexible/expanding child can.
#
# tom-thumb is variable-width, so this is an estimate (~3.9px/char,
# measured via the CLI against several real time/temp strings), not
# pixel-exact centering -- close enough that it isn't visibly
# off-center for strings in the length range this branch allows.
estimated_text_width = int(time_temp_char_count * 3.9)
pad_left = max(0, (text_width - estimated_text_width) // 2)
time_temp_line = ( time_temp_line = (
render.Box(width = text_width, child = render.Row(main_align = "center", expanded = True, children = [time_temp_text])) render.Padding(pad = (pad_left, 0, 0, 0), child = time_temp_text)
if time_temp_fits else if time_temp_fits else
render.Marquee(width = text_width, child = time_temp_text) render.Marquee(width = text_width, child = time_temp_text)
) )
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.