Elements are now pass-scoped value handles: tests that read bounds after a frame bind a ui.Handle. pixel tells frames apart by the build pass's root, since the Tester clock no longer moves on its own. Fix the regressions the upgrade brought: - Clipboard reads in input handlers go through c.Services(). - MyGo notes an overlay's opener after building it, so AutoFocus inside lost it; pixel.AutoFocus focuses through a Handle, and archtest bans the raw call. Dialogs hand the focus back again. - Elements around a press stay hovered: Tooltip tells a press-given focus by focus arriving under the pointer. - The web host moves the Tester clock with real time, at most 500 ms a call, and gives components the real clock. The gallery's source index also accepts CRLF checkouts. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
29 lines
840 B
Go
29 lines
840 B
Go
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 := pixel.Or("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)
|
|
})
|
|
}
|
|
})
|
|
}
|