From 182f36b81e408569ec20d109ec558d2432403264 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Thu, 17 Sep 2026 09:52:12 +0200 Subject: feat: right-align the condition glyph Temperature and city stay against the left edge; the glyph moves to the right edge, so the header reads as a value on one side and its icon on the other rather than one run of text. text_right takes the right edge as its x and measures ink, which is what aligning to an edge wants, as against advance() for stepping a cursor. Co-Authored-By: Claude Opus 5 --- widgets/weather.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'widgets') diff --git a/widgets/weather.lua b/widgets/weather.lua index 50d0e10..cd3e074 100644 --- a/widgets/weather.lua +++ b/widgets/weather.lua @@ -129,17 +129,17 @@ function M.draw(cr, rect, colors) local row_size = clamp(inner.w * 0.032, 13, 20) local row_step = row_size * 2.0 - -- Header: condition glyph, then the temperature with the city beneath it. + -- Header: temperature and city against the left edge, condition glyph + -- against the right. text_right takes the RIGHT edge as its x, and measures + -- ink rather than advance, which is what you want for aligning to an edge. local glyph = weather.icon(w.id, now, w.sunrise, w.sunset) card.font(cr, card.FONT_MONO, glyph_size, false) card.rgba(cr, colors.highlight) - local gy = y + glyph_size * 0.95 - card.text(cr, inner.x, gy, glyph) - local gx = inner.x + card.advance(cr, glyph) + glyph_size * 0.4 + card.text_right(cr, inner.x + inner.w, y + glyph_size * 0.95, glyph) card.font(cr, card.FONT_HEAVY, temp_size, false) card.rgba(cr, colors.body) - card.text(cr, gx, y + temp_size * 0.86, string.format('%d\u{00B0}', math.floor(w.temp + 0.5))) + card.text(cr, inner.x, y + temp_size * 0.86, string.format('%d\u{00B0}', math.floor(w.temp + 0.5))) card.font(cr, card.FONT_MONO, label_size, false) card.rgba(cr, colors.label) @@ -147,7 +147,7 @@ function M.draw(cr, rect, colors) if weather.is_stale(w.dt, now) then city = city .. ' stale ' .. weather.age_str(w.dt, now) end - card.text(cr, gx, y + temp_size * 1.28, city) + card.text(cr, inner.x, y + temp_size * 1.28, city) -- Condition, in OWM's own words, first letter capitalised. card.font(cr, card.FONT_UI, desc_size, false) -- cgit v1.2.3