diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-18 15:14:06 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-18 15:14:06 +0200 |
| commit | 1ed34aa44879296eef34bb0509e8b96533217f15 (patch) | |
| tree | 9c0f6e6fbc6afbca26a1dd949cc615610db4bc06 /lib/card.lua | |
| parent | 403c76a77ff66dac9f84fa9a49d415a8e2442cee (diff) | |
| download | conky-theme-udt-1ed34aa44879296eef34bb0509e8b96533217f15.tar.gz conky-theme-udt-1ed34aa44879296eef34bb0509e8b96533217f15.zip | |
feat(details): the wind compass takes the big value's place
card.standard() accepts a function as spec.big and calls it with the
big slot's right edge, top and size, so a card can put a graphic where
the big number goes. details draws its compass there, 1.2x the slot,
and the band under the rows is gone: the card drops to 4.25 rows and
sky moves up to take the space.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'lib/card.lua')
| -rw-r--r-- | lib/card.lua | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/card.lua b/lib/card.lua index 34c1c0b..4163aae 100644 --- a/lib/card.lua +++ b/lib/card.lua @@ -322,7 +322,8 @@ end -- -- spec.icon, spec.title the title run, as M.title draws it; no title draws -- the icon alone at the big value's size --- spec.big the big value; nil drops it (a band carries the value) +-- spec.big the big value; nil drops it (a band carries the value); +-- a function(cr, right, top, size) draws a graphic there -- spec.big_color defaults to colors.body -- spec.big_font defaults to FONT_HEAVY; FONT_MONO for a glyph -- spec.rows { {label, value, color}, ... }, color defaults to colors.value @@ -334,12 +335,14 @@ end function M.standard(cr, inner, colors, spec) local LABEL_F, BIG_F, ROW_F = 0.30, 1.0, 0.32 local rows = spec.rows or {} - local big = spec.big and tostring(spec.big) + local big = spec.big + local graphic = type(big) == 'function' + if big and not graphic then big = tostring(big) end local big_font = spec.big_font or M.FONT_HEAVY -- No title: the icon stands in for it at the big value's size (DESIGN.md). local head = { spec.title and { M.title_str(spec.icon, spec.title), M.FONT_MONO, LABEL_F } or { spec.icon, M.FONT_MONO, BIG_F } } - if big then head[2] = { big, big_font, BIG_F } end + if big and not graphic then head[2] = { big, big_font, BIG_F } end local groups = { head } for _, r in ipairs(rows) do groups[#groups + 1] = { { r[1], M.FONT_MONO, ROW_F }, @@ -352,7 +355,9 @@ function M.standard(cr, inner, colors, spec) M.fit_unit(cr, inner.w * 0.96, groups, 100)), 10, 72) local label_size, row_size = S * LABEL_F, S * ROW_F - if big then + if graphic then + big(cr, inner.x + inner.w, inner.y, S * BIG_F) + elseif big then M.font(cr, big_font, S * BIG_F, false) M.rgba(cr, spec.big_color or colors.body) M.text_right(cr, inner.x + inner.w, inner.y + S * BIG_F, big) |
