From 7fddddcd39bb250cd2653e130c8f7899d2d3f19c Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 18 Sep 2026 18:41:31 +0200 Subject: refactor: unify card no-data face and fluid sizing Extract card.notice so every cached card's no-data state is one fluid, theme-consistent face instead of a copy per widget, and delete the fixed-size card.label it replaces. Derive weather's arc geometry from its band (pad, curve room, sun dot, time labels) instead of fixed pixels, and cap the arc at a proportion of the card's width rather than 240px. Derive disks' bar-fallback height and its address type from the card's own label scale. Standardise the big-value factor to 1.0 across the fit_unit cards and document the big-value colour rule and the disks headline exception. --- widgets/calendar.lua | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) (limited to 'widgets/calendar.lua') diff --git a/widgets/calendar.lua b/widgets/calendar.lua index 6194447..b31e3b2 100644 --- a/widgets/calendar.lua +++ b/widgets/calendar.lua @@ -52,24 +52,6 @@ local function when(e) return string.format('%02d/%02d %s', e.d, e.m, e.start or 'all day') end --- The failure face: the sampler has not run. Named, as the other cached cards --- do, rather than a blank cell that cannot be told from a crashed widget. -local function draw_empty(cr, inner, colors, label_f, note, hint) - local S = clamp(inner.h * 0.94 / (1.78 + 2 * 0.72), 10, 72) - S = math.min(S, card.fit_unit(cr, inner.w * 0.96, { - { { 'CALENDAR', card.FONT_MONO, label_f } }, - { { note, card.FONT_UI, 0.36 } }, - { { hint, card.FONT_MONO, 0.32 } }, - }, 100)) - card.font(cr, card.FONT_MONO, S * label_f, false) - card.rgba(cr, colors.label) - card.text(cr, inner.x, inner.y + S * label_f, 'CALENDAR') - card.font(cr, card.FONT_UI, S * 0.36, true) - card.text(cr, inner.x, inner.y + S + S * label_f * 2.6, note) - card.font(cr, card.FONT_MONO, S * 0.32, false) - card.text(cr, inner.x, inner.y + S + S * label_f * 2.6 + S * 0.72, hint) -end - -- The legend: one coloured dot and name per calendar, along the card's bottom. -- Wraps to a second line when the names do not fit, and drops any that still -- do not: a legend spilling off the card is worse than a short one, since the @@ -103,7 +85,7 @@ function M.draw(cr, rect, colors) local cal = data.calendar_parse(data.slurp(CACHE) or '') if not cal then - draw_empty(cr, inner, colors, LABEL_F, 'no calendar data', + card.notice(cr, inner, colors, 'CALENDAR', 'no calendar data', 'bin/calendar-sample.sh') return end -- cgit v1.2.3