aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-18 18:41:31 +0200
committerDanilo M. <danix@danix.xyz>2026-09-18 18:41:31 +0200
commit7fddddcd39bb250cd2653e130c8f7899d2d3f19c (patch)
treeca427df07676563853fb7f25f6ce4eb14e63a25b /lib
parent37cabe2fea2f86d481516aae6ddaeb14bac2e64f (diff)
downloadconky-theme-udt-7fddddcd39bb250cd2653e130c8f7899d2d3f19c.tar.gz
conky-theme-udt-7fddddcd39bb250cd2653e130c8f7899d2d3f19c.zip
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/card.lua28
1 files changed, 24 insertions, 4 deletions
diff --git a/lib/card.lua b/lib/card.lua
index 337347e..3c520b9 100644
--- a/lib/card.lua
+++ b/lib/card.lua
@@ -5,6 +5,8 @@
local M = {}
+local function clamp(v, lo, hi) return math.max(lo, math.min(hi, v)) end
+
-- Cairo's font API tops out at CAIRO_FONT_WEIGHT_BOLD, so a Black face cannot
-- be requested by weight. Passing the family name that fontconfig registers for
-- it ("Noto Sans Black") with NORMAL weight does select it: measured at size
@@ -116,11 +118,29 @@ function M.card(cr, rect, colors, pad)
w = rect.w - pad * 2, h = rect.h - pad * 2 }
end
--- A small-caps section label, as used across both mockups.
-function M.label(cr, x, y, s, colors)
- M.font(cr, M.FONT_MONO, 13, false)
+-- The no-data face: the card chrome with a named message in it.
+--
+-- Every cached card draws this when its sampler has not run, so the board keeps
+-- its shape instead of showing an empty cell, which is indistinguishable from a
+-- crashed widget. One helper rather than a copy per card: the same three lines
+-- at the same ratios in the same colours is what makes the no-data face read the
+-- same everywhere, and the fit_unit pass sizes all three off the rect exactly as
+-- a populated card would.
+function M.notice(cr, inner, colors, title, note, hint)
+ local LABEL_F, NOTE_F, HINT_F = 0.30, 0.36, 0.32
+ local S = clamp(inner.h * 0.94 / (1.78 + 2 * 0.72), 10, 72)
+ S = math.min(S, M.fit_unit(cr, inner.w * 0.96, {
+ { { title, M.FONT_MONO, LABEL_F } },
+ { { note, M.FONT_UI, NOTE_F } },
+ { { hint, M.FONT_MONO, HINT_F } },
+ }, 100))
+ M.font(cr, M.FONT_MONO, S * LABEL_F, false)
M.rgba(cr, colors.label)
- M.text(cr, x, y, s:upper())
+ M.text(cr, inner.x, inner.y + S * LABEL_F, title)
+ M.font(cr, M.FONT_UI, S * NOTE_F, true)
+ M.text(cr, inner.x, inner.y + S + S * LABEL_F * 2.6, note)
+ M.font(cr, M.FONT_MONO, S * HINT_F, false)
+ M.text(cr, inner.x, inner.y + S + S * LABEL_F * 2.6 + S * 0.72, hint)
end
-- Colour for a value against two thresholds.