diff options
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) |
