diff --git a/subwave_nowplaying.star b/subwave_nowplaying.star index 939d8d3..2f52eaf 100644 --- a/subwave_nowplaying.star +++ b/subwave_nowplaying.star @@ -219,6 +219,26 @@ def main(config): if now["host"]: show_host_row.append(render.Text(" " + now["host"], font = "tom-thumb", color = colors["accent"])) + # At 2x only (there's no spare vertical row for this at 1x): split + # show and host onto their own lines instead of sharing one. Show + # names can run up to ~60 characters -- nowhere near fitting even at + # 2x's doubled width, so that line stays a Marquee regardless. Host + # (DJ) names are assumed short enough to just fit, so that line is + # centered static text instead -- but guarded with the same + # codepoints()-based length check and Marquee fallback used for + # time_temp (see its own comment for why a bare len() would be + # wrong), rather than trusting "always fits" outright. + host_text = render.Text(now["host"], font = "tom-thumb", color = colors["accent"]) if now["host"] else None + host_char_count = len(list(now["host"].codepoints())) if now["host"] else 0 + host_fits = host_char_count <= 15 + if host_text == None: + host_line = render.Box(width = text_width, height = 6) # empty placeholder -- keeps the row count/position fixed even with no host credited + elif host_fits: + host_pad_left = max(0, (text_width - int(host_char_count * 3.9)) // 2) + host_line = render.Padding(pad = (host_pad_left, 0, 0, 0), child = host_text) + else: + host_line = render.Marquee(width = text_width, child = host_text) + 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 @@ -274,13 +294,20 @@ def main(config): # as before). title_font = "terminus-16" if scale == 2 else "tb-8" + show_lines = ( + [ + render.Marquee(width = text_width, child = render.Text(now["show"], font = "tom-thumb", color = colors["text"])), + host_line, + ] + if scale == 2 else + [render.Marquee(width = text_width, child = render.Row(children = show_host_row))] + ) + top_lines = [ render.Marquee(width = text_width, child = render.Text(now["title"], font = title_font, 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.Marquee(width = text_width, child = render.Row(children = show_host_row)), - time_temp_line, - ] + ] + show_lines + [time_temp_line] children = [render.Column(children = top_lines)] if progress != None: