feat(ui): add cardSide grid helper

Square-card grids reflow on rotation, and the arithmetic is the same in
every app that draws one.
This commit is contained in:
2026-08-03 18:18:02 -04:00
parent d53f9b77cd
commit 40f7a3e4ca
2 changed files with 23 additions and 0 deletions
+7
View File
@@ -187,4 +187,11 @@ assert(ui.getTheme() == "mono" and #invalidated == before + 1)
assert(cleared == ui.theme.background)
screen:draw()
-- 320x480 portrait: three columns, and the reserve comes off the height budget.
local side, columns = ui.cardSide(5, 12, 8)
assert(columns == 3 and side == 93, "width is the binding constraint in portrait")
-- Five cards are two rows, so a reserve that eats the height budget shrinks the card.
assert(select(1, ui.cardSide(5, 12, 8, 300)) == 74, "height binds once the reserve is large")
print("ok")