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>
38 lines
1.0 KiB
Go
38 lines
1.0 KiB
Go
package game
|
||
|
||
import (
|
||
"fmt"
|
||
|
||
"github.com/egoist/mygo/ui"
|
||
|
||
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
||
)
|
||
|
||
type EndingCardOptions struct {
|
||
// Width and Height are dots; zeros mean 200 by 80.
|
||
Width, Height int
|
||
// Cue fades it in again each time it changes.
|
||
Cue int
|
||
}
|
||
|
||
// EndingCard dithers THE END in, step by step.
|
||
func EndingCard(c *ui.Context, o EndingCardOptions) ui.Element {
|
||
k := pixel.K(c)
|
||
w, h := pixel.Or("EndingCard Width", o.Width, 200), pixel.Or("EndingCard Height", o.Height, 80)
|
||
s := k.Msg("the_end")
|
||
if w < 3*pixel.Measure(s) || h < 3*pixel.LineHeight {
|
||
panic(fmt.Sprintf("game: EndingCard %d×%d is too small for %q", w, h, s))
|
||
}
|
||
e := ui.Box(c).Role(ui.RoleText).Label(s).Size(k.D(w), k.D(h))
|
||
level := 16
|
||
// It fades in over 2 s; reduced, at once.
|
||
if !k.Reduce() {
|
||
level = k.Since(c, start(k, e, o.Cue).at, 8, 16)
|
||
}
|
||
return e.Draw(func(p *ui.Painter, r ui.Rect) {
|
||
g := k.Canvas(p, r)
|
||
g.Rect(0, 0, w, h, pixel.Ink)
|
||
g.TextVeil((w-3*pixel.Measure(s))/2, (h-3*pixel.LineHeight)/2, s, pixel.Back, level, 3)
|
||
})
|
||
}
|