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
860 B
Go
36 lines
860 B
Go
package media
|
||
|
||
import (
|
||
"github.com/egoist/mygo/ui"
|
||
|
||
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
||
)
|
||
|
||
type FilmstripOptions struct {
|
||
// Scale is dots per sprite dot, 1–4; zero means 2.
|
||
Scale int
|
||
}
|
||
|
||
// Filmstrip lays a sprite's frames on film with sprocket holes.
|
||
func Filmstrip(c *ui.Context, text string, sp *pixel.Sprite, o FilmstripOptions) ui.Element {
|
||
k := pixel.K(c)
|
||
s := scale("Filmstrip", o.Scale, 2)
|
||
n := sp.Frames()
|
||
fw, fh := sp.W*s+4, sp.H*s+2
|
||
w, h := n*fw+4, fh+14
|
||
return art(c, k, text, w, h).Draw(func(p *ui.Painter, r ui.Rect) {
|
||
g := k.Canvas(p, r)
|
||
body, line := dark(k)
|
||
g.Rect(0, 0, w, h, body)
|
||
for x := 2; x+3 <= w; x += 6 {
|
||
g.Rect(x, 2, 3, 3, line)
|
||
g.Rect(x, h-5, 3, 3, line)
|
||
}
|
||
for i := range n {
|
||
x := 3 + i*fw
|
||
g.Rect(x, 7, fw-2, fh, pixel.Lit)
|
||
g.Sprite(x+1, 8, sp, i, pixel.Ink, s)
|
||
}
|
||
})
|
||
}
|