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>
43 lines
1006 B
Go
43 lines
1006 B
Go
package fx
|
|
|
|
import (
|
|
"math"
|
|
|
|
"github.com/egoist/mygo/ui"
|
|
|
|
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
|
)
|
|
|
|
type IrisWipeOptions struct {
|
|
// Slot fills outside the iris; zero means the darkest slot.
|
|
Slot pixel.Slot
|
|
}
|
|
|
|
// IrisWipe closes a circle on content's middle, or opens it.
|
|
func IrisWipe(c *ui.Context, closed bool, o IrisWipeOptions, content func()) ui.Element {
|
|
k := pixel.K(c)
|
|
s := slotOr(o.Slot, dark(k))
|
|
e := ui.Column(c)
|
|
step := k.Toward(c, e, closed, 12, 8)
|
|
return cover(k, e, func(g pixel.Canvas) { iris(g, s, step) }, content)
|
|
}
|
|
|
|
// iris fills outside a circle, gone by step 8.
|
|
func iris(g pixel.Canvas, s pixel.Slot, step int) {
|
|
if step == 0 {
|
|
return
|
|
}
|
|
cx, cy := g.W/2, g.H/2
|
|
r := int(math.Ceil(math.Hypot(float64(g.W)/2, float64(g.H)/2))) * (8 - step) / 8
|
|
for y := range g.H {
|
|
dy := y - cy
|
|
if dy*dy >= r*r {
|
|
g.HLine(0, y, g.W, s)
|
|
continue
|
|
}
|
|
dx := int(math.Sqrt(float64(r*r - dy*dy)))
|
|
g.HLine(0, y, cx-dx, s)
|
|
g.HLine(cx+dx, y, g.W-cx-dx, s)
|
|
}
|
|
}
|