diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/card.lua | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/card.lua b/lib/card.lua index 3c520b9..e3cb11e 100644 --- a/lib/card.lua +++ b/lib/card.lua @@ -118,6 +118,40 @@ function M.card(cr, rect, colors, pad) w = rect.w - pad * 2, h = rect.h - pad * 2 } end +-- Card title glyphs, all present in FONT_MONO (Inconsolata Nerd Font). +-- +-- Verified by rendering a contact sheet and looking at each one, not by +-- fontconfig alone: a missing glyph draws as an invisible blank and a wrong +-- codepoint as a plausible neighbour, so neither fails visibly. +M.ICON = { + system = '\u{F0EE0}', -- cpu-64-bit + gpu = '\u{F083E}', -- video-4k-box (no GPU glyph exists) + disks = '\u{F02CA}', -- harddisk + cache = '\u{F0ABA}', -- folder-clock + network = '\u{F0317}', -- lan + slackware = '\u{F318}', -- linux-slackware + breaktimer = '\u{F13AB}', -- timer + calendar = '\u{F0E17}', -- calendar-month +} + +-- The gap between a title's icon and its text. One constant so the measured +-- width and the drawn width cannot drift apart. +local TITLE_GAP = ' ' + +-- The full run a title occupies, for fit_unit to measure. Colour does not +-- affect width, so measuring icon and text as one string is exact. +function M.title_str(icon, text) return icon .. TITLE_GAP .. text end + +-- Draw a card title: the icon in `highlight`, the text in `label`, both at the +-- caller's current font. x is the left edge, y the baseline. +function M.title(cr, x, y, icon, text, colors) + M.rgba(cr, colors.highlight) + M.text(cr, x, y, icon) + x = x + M.advance(cr, icon .. TITLE_GAP) + M.rgba(cr, colors.label) + M.text(cr, x, y, text) +end + -- 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 |
