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>
52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
package display
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/egoist/mygo/ui"
|
|
|
|
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
|
)
|
|
|
|
var cup = pixel.MustSprite(`
|
|
..eeeeeeeeeee..
|
|
eeeyyyyyyyyyeee
|
|
e.eyllyyyyyye.e
|
|
e.eylyyyyyyye.e
|
|
.eeyyyyyyyyyee.
|
|
...eyyyyyyye...
|
|
....eyyyyye....
|
|
.....eyyye.....
|
|
......eye......
|
|
......eye......
|
|
.....eyyye.....
|
|
...eesssssee...
|
|
...esssssssse..
|
|
`)
|
|
|
|
type TrophyOptions struct {
|
|
Scale int
|
|
}
|
|
|
|
// Trophy is a gold cup over an engraved plaque.
|
|
func Trophy(c *ui.Context, plaque string, o TrophyOptions) ui.Element {
|
|
k, sc := pixel.K(c), scale(o.Scale)
|
|
up := strings.ToUpper(plaque)
|
|
micro := pixel.MicroOK(up)
|
|
tw, th := pixel.Measure(plaque), pixel.LineHeight
|
|
if micro {
|
|
tw, th = pixel.MicroWidth(up), pixel.MicroHeight
|
|
}
|
|
pw, ph := tw+6, th+4
|
|
w := max(cup.W*sc, pw)
|
|
return art(c, k, plaque, w, cup.H*sc+1+ph, func(g pixel.Canvas) {
|
|
g.Sprite((w-cup.W*sc)/2, 0, cup, 0, pixel.Ink, sc)
|
|
g.Frame((w-pw)/2, cup.H*sc+1, pw, ph, pixel.Raised, pixel.Shade)
|
|
if micro {
|
|
g.Micro((w-pw)/2+3, cup.H*sc+3, up, pixel.Ink, 1)
|
|
} else {
|
|
g.Text((w-pw)/2+3, cup.H*sc+3, plaque, pixel.Ink, 1)
|
|
}
|
|
})
|
|
}
|