diff options
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -100,6 +100,33 @@ bug here: ink width ignores leading and trailing spaces, so `' / '` measures 6px of ink against a 14px advance, and stepping a cursor by the ink width renders the date as `16 /SEP /2026`. +### Widgets are fluid + +A widget is handed a rectangle and must fill it, whatever shape the grid makes +it. That is what lets you retune `COLS`/`ROWS` or move a card without touching +widget code. Three rules, all learned by getting them wrong: + +**Derive every size and offset from the rect.** No fixed pixel drops between +elements. A fixed `+34` under a numeral that scales leaves a dead band in a tall +cell and overlaps in a short one. + +**Scale type off the WIDTH, not the height.** Height is what changes when you +add a row to the grid, and a card that shrinks its text every time its cell gets +shorter reads as broken beside its neighbours. Width is also usually what +constrains the text, since rows run edge to edge. Clamp it: `math.max(lo, +math.min(hi, inner.w * k))`. + +**Decide where the slack goes, and let one element absorb it.** The clock pins +its date block to the bottom and gives the numerals everything above. The +weather card stacks from the top and lets the arc take the remainder. Either is +fine; what fails is leaving the slack wherever it lands. + +An element that cannot shrink below some size should drop out rather than +overlap. The weather arc does this: below 70px it is not drawn at all, because a +curve crossing the stat rows is worse than no curve. Check a widget at several +spans before believing it is fluid, which the offscreen renderer above makes +cheap. + ## Development Run it in the foreground to see Lua output, which is the only debugging channel: |
