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>
36 lines
855 B
Go
36 lines
855 B
Go
package display
|
|
|
|
import (
|
|
"github.com/egoist/mygo/ui"
|
|
|
|
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
|
)
|
|
|
|
type FlagOptions struct {
|
|
// Slot is the cloth; zero means Bad.
|
|
Slot pixel.Slot
|
|
Scale int
|
|
Label string
|
|
}
|
|
|
|
// Flag waves on its pole, stepped at 6 fps.
|
|
func Flag(c *ui.Context, o FlagOptions) ui.Element {
|
|
k, sc := pixel.K(c), scale(o.Scale)
|
|
cloth := slotOr(o.Slot, pixel.Bad)
|
|
return art(c, k, o.Label, 20*sc, 26*sc, func(g pixel.Canvas) {
|
|
step := g.Step(6)
|
|
g.Rect(sc, 2*sc, sc, 24*sc, pixel.Edge)
|
|
g.Rect(0, 0, 3*sc, 2*sc, pixel.Warn)
|
|
for col := range 16 {
|
|
dy := [4]int{0, 1, 1, 0}[(step+col/4)%4]
|
|
x, y := (2+col)*sc, (3+dy)*sc
|
|
g.Rect(x, y, sc, 10*sc, cloth)
|
|
if (step+col/4)%4 == 2 {
|
|
g.Rect(x, y, sc, 10*sc, pixel.Shade)
|
|
g.Veil(x, y, sc, 10*sc, cloth, 8)
|
|
}
|
|
g.Rect(x, y, sc, sc, pixel.Lit)
|
|
}
|
|
})
|
|
}
|