Add display components 041-065; move Icon into display; QR via rsc.io/qr

This commit is contained in:
ZacharyZhang-NY committed 2026-10-11 18:37:54 -04:00
1 parent 59fde4096d
commit 0247a130f5
41 files changed
+2152 -44

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
package display
import (
"github.com/egoist/mygo/ui"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
)
type SwatchOptions struct {
// Columns is zero for 4.
Columns int
}
// Swatch shows the active palette's sixteen slots with names.
func Swatch(c *ui.Context, o SwatchOptions) *ui.Element {
k := pixel.K(c)
cols := orDef("Swatch Columns", o.Columns, 4)
cell := 14 + pixel.Measure("AccentLit")
return ui.Row(c).Wrap().Width(k.D(cols * (cell + 4))).Gap(k.D(4)).Role(ui.RoleList).Label(k.Palette().Name).Children(func() {
for s := range pixel.Slot(pixel.Slots) {
ui.Box(c).Size(k.D(cell), k.D(pixel.LineHeight)).Role(ui.RoleListItem).Label(s.String()).Draw(func(p *ui.Painter, r ui.Rect) {
g := k.Canvas(p, r)
g.Frame(0, 2, 12, 12, pixel.Flat, s)
g.Text(14, 0, s.String(), pixel.Ink, 1)
})
}
})
}