Files
ZacharyZhang-NYandClaude Opus 5.5 03e1f91706 Upgrade MyGo to v0.5.5
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>
2026-10-17 01:31:08 -04:00

68 lines
1.7 KiB
Go

package agent
import (
"math"
"github.com/egoist/mygo/ui"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
)
type ThinkingOrbOptions struct{}
var (
// Swirl arms run Lit at the heart, Info, then Magic.
swirl = []pixel.Slot{pixel.Lit, pixel.Info, pixel.Magic}
// mist is the glow's half width, row by row.
mist = func() map[int]int {
half := map[int]int{}
for _, d := range ring(15) {
half[d[1]] = max(half[d[1]], abs(d[0]))
}
return half
}()
)
// ThinkingOrb is a crystal ball that swirls while thinking.
func ThinkingOrb(c *ui.Context, text string, thinking bool, o ThinkingOrbOptions) ui.Element {
k := pixel.K(c)
word := k.Msg("idle")
if thinking {
word = k.Msg("thinking")
}
return ui.Box(c).Size(k.D(44), k.D(48)).Role(ui.RoleStatus).Label(text).Description(word).Draw(func(p *ui.Painter, r ui.Rect) {
g := k.Canvas(p, r)
g.Disc(22, 20, 19, pixel.Well)
// A busy sign: it swirls on under Reduce Motion.
if thinking {
for y, h := range mist {
g.Veil(22-h, 20+y, 2*h+1, 1, pixel.Magic, 4)
}
turn := float64(g.Busy(8)%12) * math.Pi / 6
for arm := range 3 {
px, py := 22, 20
for i := 1; i <= 16; i++ {
t := float64(i)*0.38 + turn + float64(arm)*2*math.Pi/3
x, y := 22+int(math.Round(float64(i)*math.Cos(t))), 20+int(math.Round(float64(i)*math.Sin(t)))
g.Line(px, py, x, y, swirl[(i-1)*3/16])
px, py = x, y
}
}
g.Disc(22, 20, 2, pixel.Lit)
}
g.Circle(22, 20, 19, pixel.Edge)
g.Rect(11, 8, 4, 2, pixel.Lit)
g.Rect(10, 10, 2, 2, pixel.Lit)
g.Rect(13, 38, 18, 3, pixel.Edge)
g.Rect(8, 41, 28, 6, pixel.Shade)
g.HLine(8, 41, 28, pixel.Edge)
})
}
func abs(n int) int {
if n < 0 {
return -n
}
return n
}