Files
8bitMyGoUI/data/cardgrid.go
T
ZacharyZhang-NY 03680980da Add data components 151-175; clear MyGo row highlights
Lists, tables, trees, grids, inventories and records in data/.
Outline and GridView build on ui.List: ui.Outline strokes its arrows
and ui.GridView spaces and tints items. The pixel theme keeps MyGo's
row highlights clear so scrolled rows stay on whole dots; off lists
take a veil against the wheel. Adds Canvas.Silhouette, SwitchOptions
Label and exports Rarity.Slot.
2026-10-11 22:29:07 -04:00

24 lines
695 B
Go

package data
import (
"github.com/egoist/mygo/ui"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/layout"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
)
type CardGridOptions struct {
// MinWidth is a card's least dots; zero means 96.
MinWidth int
}
// CardGrid fits as many card columns as width allows.
func CardGrid(c *ui.Context, n int, o CardGridOptions, card func(i int)) *ui.Element {
mw := pixel.Or("CardGrid MinWidth", o.MinWidth, 96)
box := ui.Box(c).FillWidth()
w, check := pixel.WrapWidth(c, box)
return box.Draw(func(p *ui.Painter, r ui.Rect) { check(r) }).Children(func() {
layout.Grid(c, n, layout.GridOptions{Columns: max(1, w/mw), Pad: 2}, card)
})
}