From adb09a344c91de1362fbd04c11a75199cd86aed5 Mon Sep 17 00:00:00 2001 From: jim kolpack Date: Sat, 10 Oct 2026 14:52:37 -0400 Subject: [PATCH] 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. --- subwave_nowplaying.star | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/subwave_nowplaying.star b/subwave_nowplaying.star index 002a57e..771518b 100644 --- a/subwave_nowplaying.star +++ b/subwave_nowplaying.star @@ -245,8 +245,23 @@ def main(config): # scrolling it -- easy to mistake for "the centering didn't work"). time_temp_char_count = len(list(now["time_temp"].codepoints())) 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 = ( - 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 render.Marquee(width = text_width, child = time_temp_text) )