From 8e1baa72813fd93fc103b6d2d69753f952a24e3f Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Thu, 17 Sep 2026 13:15:31 +0200 Subject: feat: put every card's big number in the same place Mirror the weather header so the glyph sits large on the left and the temperature, city and condition run against the right edge, and move the system card's CPU percentage onto its header line, right-aligned. All big values now render at the card's right edge. --- widgets/system.lua | 15 ++++++++------- widgets/weather.lua | 18 ++++++++++-------- 2 files changed, 18 insertions(+), 15 deletions(-) (limited to 'widgets') diff --git a/widgets/system.lua b/widgets/system.lua index 231192c..1db3c45 100644 --- a/widgets/system.lua +++ b/widgets/system.lua @@ -53,7 +53,7 @@ function M.draw(cr, rect, colors) end -- Height the non-equaliser content needs, in units of S, plus a reserve for -- the equaliser band. The smaller of that budget and the width fit is S. - local fixed_units = 1.30 + 1.13 + temp_n * ROW_F * 1.8 + 0.10 + local fixed_units = 1.00 + 1.13 + temp_n * ROW_F * 1.8 + 0.10 local S = clamp(math.min(inner.h * 0.96 / (fixed_units + 1.7), card.fit_unit(cr, inner.w * 0.96, groups, 100)), 10, 72) local label_size = S * LABEL_F @@ -62,19 +62,20 @@ function M.draw(cr, rect, colors) local y = inner.y - -- Aggregate load, the headline number. + -- Aggregate load, the headline number. It takes the header line, right + -- aligned like the big value on every other card, with the label top-left. + card.font(cr, card.FONT_HEAVY, big_size, false) + card.rgba(cr, load and card.threshold(load, 25, 75, colors) or colors.label) + card.text_right(cr, inner.x + inner.w, y + big_size, load_txt) + card.font(cr, card.FONT_MONO, label_size, false) card.rgba(cr, colors.label) card.text(cr, inner.x, y + label_size, 'CPU') - card.font(cr, card.FONT_HEAVY, big_size, false) - card.rgba(cr, load and card.threshold(load, 25, 75, colors) or colors.label) - card.text(cr, inner.x, y + label_size + big_size, load_txt) - -- The equaliser: one bar per core, rising from a common baseline. It takes -- the room left between the header and the RAM/temperature block, so it is -- the card's slack absorber. - local eq_top = y + label_size + big_size + S * 0.30 + local eq_top = y + big_size + S * 0.30 local bar_h = S * 0.18 local step = row_size * 1.8 local eh = clamp((inner.y + inner.h) - eq_top - (S * 1.13 + temp_n * step), diff --git a/widgets/weather.lua b/widgets/weather.lua index cd3e074..f50c6f1 100644 --- a/widgets/weather.lua +++ b/widgets/weather.lua @@ -123,23 +123,25 @@ function M.draw(cr, rect, colors) -- anyway, since the stat rows run edge to edge. local function clamp(v, lo, hi) return math.max(lo, math.min(hi, v)) end local temp_size = clamp(inner.w * 0.135, 40, 84) - local glyph_size = clamp(temp_size * 0.74, 30, 60) + local glyph_size = clamp(temp_size * 0.95, 38, 78) local label_size = clamp(inner.w * 0.030, 12, 19) local desc_size = clamp(inner.w * 0.038, 15, 24) local row_size = clamp(inner.w * 0.032, 13, 20) local row_step = row_size * 2.0 - -- 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. + -- Header, mirrored to match the other cards: the condition glyph large on + -- the left, the big temperature and the rest of the text against the right + -- edge. 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) - card.text_right(cr, inner.x + inner.w, y + glyph_size * 0.95, glyph) + card.text(cr, inner.x, y + glyph_size * 0.95, glyph) card.font(cr, card.FONT_HEAVY, temp_size, false) card.rgba(cr, colors.body) - card.text(cr, inner.x, y + temp_size * 0.86, string.format('%d\u{00B0}', math.floor(w.temp + 0.5))) + card.text_right(cr, inner.x + inner.w, 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 +149,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, inner.x, y + temp_size * 1.28, city) + card.text_right(cr, inner.x + inner.w, y + temp_size * 1.28, city) -- Condition, in OWM's own words, first letter capitalised. card.font(cr, card.FONT_UI, desc_size, false) @@ -155,7 +157,7 @@ function M.draw(cr, rect, colors) local desc = w.description or '' desc = desc:sub(1, 1):upper() .. desc:sub(2) local dy = y + temp_size * 1.95 - card.text(cr, inner.x, dy, desc) + card.text_right(cr, inner.x + inner.w, dy, desc) -- Rule. local ry = dy + desc_size * 1.4 -- cgit v1.2.3