At 2x, show time/temp as static text instead of scrolling it
First experiment in using 2x's extra width for something other than just stretching the 1x layout: the time/temp line usually fits without scrolling once the text column doubles in width. Marquee is unneeded overhead for short, non-truncated text. Guarded by a length check (<=15 chars), not just scale==2: pixlet has no way to measure rendered text width from within Starlark, and tom-thumb is variable-width, so this is a heuristic rather than an exact fit check. Measured via the CLI: a realistic worst case like "12:59 pm · 100°F" (16 chars -- 2-digit hour, 3-digit temp) renders at 63px against a 64px budget, just 1px of margin -- too close to rely on. 15 chars keeps a real margin (59px measured) against overflowing into the art column. Falls back to Marquee past that length, and always at 1x regardless of length (tighter width there either way).
This commit is contained in:
1 parent
a4a8e37242
commit
fdb2a1038e
1 file changed
+18
-1
+18
-1
@@ -219,12 +219,29 @@ def main(config):
|
|||||||
if now["host"]:
|
if now["host"]:
|
||||||
show_host_row.append(render.Text(" " + now["host"], font = "tom-thumb", color = colors["accent"]))
|
show_host_row.append(render.Text(" " + now["host"], font = "tom-thumb", color = colors["accent"]))
|
||||||
|
|
||||||
|
time_temp_text = render.Text(now["time_temp"], font = "tom-thumb", color = colors["meta"])
|
||||||
|
|
||||||
|
# At 2x, the extra width usually fits e.g. "9:54 pm \xb7 65\xb0F" without
|
||||||
|
# scrolling -- tried as a first, contained experiment in using 2x's
|
||||||
|
# extra room rather than just stretching the same 1x layout. But
|
||||||
|
# tom-thumb is variable-width and pixlet has no way to measure
|
||||||
|
# rendered text width from within Starlark, so this is a length
|
||||||
|
# heuristic, not an exact fit check: measured via the CLI,
|
||||||
|
# "12:59 pm \xb7 100\xb0F" (16 chars, a realistic worst case -- 2-digit
|
||||||
|
# hour, 3-digit temp) comes out to 63px against a 64px budget, 1px of
|
||||||
|
# margin; "11:59 am \xb7 -5\xb0F" (15 chars) is a safer 59px. Capping at
|
||||||
|
# 15 chars keeps a real margin against overflowing into the art
|
||||||
|
# column instead of relying on a 1px coincidence. Always Marquee at
|
||||||
|
# 1x, where the available width is tighter regardless of length.
|
||||||
|
time_temp_fits = scale == 2 and len(now["time_temp"]) <= 15
|
||||||
|
time_temp_line = time_temp_text if time_temp_fits else render.Marquee(width = text_width, child = time_temp_text)
|
||||||
|
|
||||||
top_lines = [
|
top_lines = [
|
||||||
render.Marquee(width = text_width, child = render.Text(now["title"], font = "tb-8", color = colors["text"])),
|
render.Marquee(width = text_width, child = render.Text(now["title"], font = "tb-8", color = colors["text"])),
|
||||||
render.Marquee(width = text_width, child = render.Text(now["artist"], font = "tb-8", color = colors["text"])),
|
render.Marquee(width = text_width, child = render.Text(now["artist"], font = "tb-8", color = colors["text"])),
|
||||||
render.Box(width = text_width, height = scale, color = colors["separator"]),
|
render.Box(width = text_width, height = scale, color = colors["separator"]),
|
||||||
render.Marquee(width = text_width, child = render.Row(children = show_host_row)),
|
render.Marquee(width = text_width, child = render.Row(children = show_host_row)),
|
||||||
render.Marquee(width = text_width, child = render.Text(now["time_temp"], font = "tom-thumb", color = colors["meta"])),
|
time_temp_line,
|
||||||
]
|
]
|
||||||
|
|
||||||
children = [render.Column(children = top_lines)]
|
children = [render.Column(children = top_lines)]
|
||||||
|
|||||||