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>
This commit is contained in:
1 parent
1f3d38110e
commit
03e1f91706
532 files changed
+828
-735
No files matched your search
+1
-1
@@ -13,7 +13,7 @@ type AuroraOptions struct {
|
||||
}
|
||||
|
||||
// Aurora hangs curtains whose slots slide sideways.
|
||||
func Aurora(c *ui.Context, o AuroraOptions) *ui.Element {
|
||||
func Aurora(c *ui.Context, o AuroraOptions) ui.Element {
|
||||
k := pixel.K(c)
|
||||
w, h := size("Aurora", o.Width, o.Height, 160, 96)
|
||||
return box(c, k, o.Label, w, h).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ type CloudsOptions struct {
|
||||
}
|
||||
|
||||
// Clouds drift by: far ones slowly, near ones faster.
|
||||
func Clouds(c *ui.Context, o CloudsOptions) *ui.Element {
|
||||
func Clouds(c *ui.Context, o CloudsOptions) ui.Element {
|
||||
k := pixel.K(c)
|
||||
w, h := size("Clouds", o.Width, o.Height, 160, 96)
|
||||
return box(c, k, o.Label, w, h).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ type ConfettiOptions struct {
|
||||
var confettiSlots = []pixel.Slot{pixel.Accent, pixel.Good, pixel.Warn, pixel.Bad, pixel.Info, pixel.Magic}
|
||||
|
||||
// Confetti tumbles bits of every color down, turning.
|
||||
func Confetti(c *ui.Context, o ConfettiOptions) *ui.Element {
|
||||
func Confetti(c *ui.Context, o ConfettiOptions) ui.Element {
|
||||
k := pixel.K(c)
|
||||
w, h := size("Confetti", o.Width, o.Height, 160, 96)
|
||||
return box(c, k, o.Label, w, h).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ type DissolveOptions struct {
|
||||
}
|
||||
|
||||
// Dissolve switches content's dots to a slot in shuffled order.
|
||||
func Dissolve(c *ui.Context, covered bool, o DissolveOptions, content func()) *ui.Element {
|
||||
func Dissolve(c *ui.Context, covered bool, o DissolveOptions, content func()) ui.Element {
|
||||
k := pixel.K(c)
|
||||
s := slotOr(o.Slot, dark(k))
|
||||
e := ui.Column(c)
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ const blastSteps = 8
|
||||
var debrisSlots = []pixel.Slot{pixel.Warn, pixel.Bad, pixel.Faint}
|
||||
|
||||
// Explosion bursts, breaks into smoke and throws debris.
|
||||
func Explosion(c *ui.Context, o ExplosionOptions) *ui.Element {
|
||||
func Explosion(c *ui.Context, o ExplosionOptions) ui.Element {
|
||||
k := pixel.K(c)
|
||||
n := pixel.Or("Explosion Size", o.Size, 48)
|
||||
e := box(c, k, o.Label, n, n)
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ type FadeDitherOptions struct {
|
||||
}
|
||||
|
||||
// FadeDither covers content through Bayer levels, or uncovers it.
|
||||
func FadeDither(c *ui.Context, covered bool, o FadeDitherOptions, content func()) *ui.Element {
|
||||
func FadeDither(c *ui.Context, covered bool, o FadeDitherOptions, content func()) ui.Element {
|
||||
k := pixel.K(c)
|
||||
s := slotOr(o.Slot, dark(k))
|
||||
e := ui.Column(c)
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ s###........###s
|
||||
`)
|
||||
|
||||
// Fire burns a campfire: flicker frames, heat rising through it.
|
||||
func Fire(c *ui.Context, o FireOptions) *ui.Element {
|
||||
func Fire(c *ui.Context, o FireOptions) ui.Element {
|
||||
k := pixel.K(c)
|
||||
sc := scale("Fire", o.Scale, 2)
|
||||
return box(c, k, o.Label, 16*sc, 20*sc).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ type FirefliesOptions struct {
|
||||
}
|
||||
|
||||
// Fireflies wander and glow: bright, dim, then dark a while.
|
||||
func Fireflies(c *ui.Context, o FirefliesOptions) *ui.Element {
|
||||
func Fireflies(c *ui.Context, o FirefliesOptions) ui.Element {
|
||||
k := pixel.K(c)
|
||||
w, h := size("Fireflies", o.Width, o.Height, 160, 96)
|
||||
return box(c, k, o.Label, w, h).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ type FlashOptions struct {
|
||||
}
|
||||
|
||||
// Flash fills content with a slot one step, then half.
|
||||
func Flash(c *ui.Context, o FlashOptions, content func()) *ui.Element {
|
||||
func Flash(c *ui.Context, o FlashOptions, content func()) ui.Element {
|
||||
k := pixel.K(c)
|
||||
s := slotOr(o.Slot, pixel.Lit)
|
||||
e := ui.Column(c)
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
// box sizes an effect; a label makes it an image.
|
||||
func box(c *ui.Context, k pixel.Kit, label string, w, h int) *ui.Element {
|
||||
func box(c *ui.Context, k pixel.Kit, label string, w, h int) ui.Element {
|
||||
e := ui.Box(c).Size(k.D(w), k.D(h))
|
||||
if label != "" {
|
||||
return e.Label(label).Role(ui.RoleImage)
|
||||
@@ -87,7 +87,7 @@ func checkHour(name string, hour int) {
|
||||
}
|
||||
|
||||
// cover draws over e's content, clipped to e.
|
||||
func cover(k pixel.Kit, e *ui.Element, draw func(g pixel.Canvas), content func()) *ui.Element {
|
||||
func cover(k pixel.Kit, e ui.Element, draw func(g pixel.Canvas), content func()) ui.Element {
|
||||
return e.DrawOver(func(p *ui.Painter, r ui.Rect) {
|
||||
g := k.Canvas(p, r)
|
||||
g.Clip(0, 0, g.W, g.H, func() { draw(g) })
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ type GlitchOptions struct {
|
||||
const glitchSteps = 6
|
||||
|
||||
// Glitch shifts row bands and swaps two slots, briefly.
|
||||
func Glitch(c *ui.Context, sp *pixel.Sprite, o GlitchOptions) *ui.Element {
|
||||
func Glitch(c *ui.Context, sp *pixel.Sprite, o GlitchOptions) ui.Element {
|
||||
k := pixel.K(c)
|
||||
sc := scale("Glitch", o.Scale, 1)
|
||||
// Three dots either side hold the rows shifted out.
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ type IrisWipeOptions struct {
|
||||
}
|
||||
|
||||
// IrisWipe closes a circle on content's middle, or opens it.
|
||||
func IrisWipe(c *ui.Context, closed bool, o IrisWipeOptions, content func()) *ui.Element {
|
||||
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)
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ type LavaOptions struct {
|
||||
}
|
||||
|
||||
// Lava flows in cycling veins while bubbles swell and pop.
|
||||
func Lava(c *ui.Context, o LavaOptions) *ui.Element {
|
||||
func Lava(c *ui.Context, o LavaOptions) ui.Element {
|
||||
k := pixel.K(c)
|
||||
w, h := size("Lava", o.Width, o.Height, 160, 48)
|
||||
return box(c, k, o.Label, w, h).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ type LeavesOptions struct {
|
||||
var leafSlots = []pixel.Slot{pixel.Warn, pixel.Bad, pixel.Accent}
|
||||
|
||||
// Leaves swing down side to side, turning on their stems.
|
||||
func Leaves(c *ui.Context, o LeavesOptions) *ui.Element {
|
||||
func Leaves(c *ui.Context, o LeavesOptions) ui.Element {
|
||||
k := pixel.K(c)
|
||||
w, h := size("Leaves", o.Width, o.Height, 160, 96)
|
||||
return box(c, k, o.Label, w, h).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ type LightningOptions struct {
|
||||
const strikeSteps = 5
|
||||
|
||||
// Lightning flashes, then forks a bolt to the ground.
|
||||
func Lightning(c *ui.Context, o LightningOptions) *ui.Element {
|
||||
func Lightning(c *ui.Context, o LightningOptions) ui.Element {
|
||||
k := pixel.K(c)
|
||||
w, h := size("Lightning", o.Width, o.Height, 96, 96)
|
||||
e := box(c, k, o.Label, w, h)
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ type MosaicOptions struct {
|
||||
var blocks = [...]int{1, 2, 3, 4, 6, 8, 6, 4, 3, 2, 1}
|
||||
|
||||
// Mosaic pixelates sp in growing blocks, then sharpens it again.
|
||||
func Mosaic(c *ui.Context, sp *pixel.Sprite, o MosaicOptions) *ui.Element {
|
||||
func Mosaic(c *ui.Context, sp *pixel.Sprite, o MosaicOptions) ui.Element {
|
||||
k := pixel.K(c)
|
||||
sc := scale("Mosaic", o.Scale, 1)
|
||||
e := box(c, k, o.Label, sp.W*sc, sp.H*sc)
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ type MountainsOptions struct {
|
||||
}
|
||||
|
||||
// Mountains scroll three ridges: far ones slow, near ones quick.
|
||||
func Mountains(c *ui.Context, o MountainsOptions) *ui.Element {
|
||||
func Mountains(c *ui.Context, o MountainsOptions) ui.Element {
|
||||
k := pixel.K(c)
|
||||
w, h := size("Mountains", o.Width, o.Height, 160, 96)
|
||||
return box(c, k, o.Label, w, h).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ type OceanOptions struct {
|
||||
}
|
||||
|
||||
// Ocean rolls wave crests toward you by cycling their slots.
|
||||
func Ocean(c *ui.Context, o OceanOptions) *ui.Element {
|
||||
func Ocean(c *ui.Context, o OceanOptions) ui.Element {
|
||||
k := pixel.K(c)
|
||||
w, h := size("Ocean", o.Width, o.Height, 160, 64)
|
||||
return box(c, k, o.Label, w, h).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ type PaletteCycleOptions struct {
|
||||
}
|
||||
|
||||
// PaletteCycle draws sp, rotating band's slots one place a step.
|
||||
func PaletteCycle(c *ui.Context, sp *pixel.Sprite, band []pixel.Slot, o PaletteCycleOptions) *ui.Element {
|
||||
func PaletteCycle(c *ui.Context, sp *pixel.Sprite, band []pixel.Slot, o PaletteCycleOptions) ui.Element {
|
||||
k := pixel.K(c)
|
||||
fps, sc := pixel.Or("PaletteCycle FPS", o.FPS, 8), scale("PaletteCycle", o.Scale, 1)
|
||||
if len(band) < 2 {
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ type PetalsOptions struct {
|
||||
}
|
||||
|
||||
// Petals fall on a breeze, turning as they go.
|
||||
func Petals(c *ui.Context, o PetalsOptions) *ui.Element {
|
||||
func Petals(c *ui.Context, o PetalsOptions) ui.Element {
|
||||
k := pixel.K(c)
|
||||
w, h := size("Petals", o.Width, o.Height, 160, 96)
|
||||
return box(c, k, o.Label, w, h).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ type RainOptions struct {
|
||||
}
|
||||
|
||||
// Rain slants streaks down; each splashes as it lands.
|
||||
func Rain(c *ui.Context, o RainOptions) *ui.Element {
|
||||
func Rain(c *ui.Context, o RainOptions) ui.Element {
|
||||
k := pixel.K(c)
|
||||
w, h := size("Rain", o.Width, o.Height, 160, 96)
|
||||
return box(c, k, o.Label, w, h).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ type ScanlinesOptions struct {
|
||||
}
|
||||
|
||||
// Scanlines shades every other row of content at half strength.
|
||||
func Scanlines(c *ui.Context, o ScanlinesOptions, content func()) *ui.Element {
|
||||
func Scanlines(c *ui.Context, o ScanlinesOptions, content func()) ui.Element {
|
||||
k := pixel.K(c)
|
||||
s := slotOr(o.Slot, pixel.Shade)
|
||||
return cover(k, ui.Column(c), func(g pixel.Canvas) {
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ type ScreenShakeOptions struct {
|
||||
var quakes = [...][2]int{{3, -2}, {-3, 2}, {2, 3}, {-3, -2}, {2, 1}, {-1, -2}, {1, 1}, {-1, 0}, {0, 0}}
|
||||
|
||||
// ScreenShake jolts its content both ways, settling as it goes.
|
||||
func ScreenShake(c *ui.Context, o ScreenShakeOptions, content func()) *ui.Element {
|
||||
func ScreenShake(c *ui.Context, o ScreenShakeOptions, content func()) ui.Element {
|
||||
k := pixel.K(c)
|
||||
a := pixel.Or("ScreenShake Amount", o.Amount, 3)
|
||||
e := ui.Box(c)
|
||||
|
||||
+2
-2
@@ -15,14 +15,14 @@ type SeasonSceneOptions struct {
|
||||
}
|
||||
|
||||
// SeasonScene paints a season at an hour, in its palette.
|
||||
func SeasonScene(c *ui.Context, season pixel.Season, hour int, o SeasonSceneOptions) *ui.Element {
|
||||
func SeasonScene(c *ui.Context, season pixel.Season, hour int, o SeasonSceneOptions) ui.Element {
|
||||
checkHour("SeasonScene", hour)
|
||||
if season > pixel.Winter {
|
||||
panic(fmt.Sprintf("fx: SeasonScene season %d", season))
|
||||
}
|
||||
s := pixel.Current(c)
|
||||
s.Palette = pixel.Find(season, hour < 6 || hour >= 18)
|
||||
var e *ui.Element
|
||||
var e ui.Element
|
||||
pixel.Scope(c, s, func() {
|
||||
k := pixel.K(c)
|
||||
w, h := size("SeasonScene", o.Width, o.Height, 160, 96)
|
||||
|
||||
@@ -13,7 +13,7 @@ type SkyOptions struct {
|
||||
}
|
||||
|
||||
// Sky dithers down the palette's sky slots; night shows stars.
|
||||
func Sky(c *ui.Context, o SkyOptions) *ui.Element {
|
||||
func Sky(c *ui.Context, o SkyOptions) ui.Element {
|
||||
k := pixel.K(c)
|
||||
w, h := size("Sky", o.Width, o.Height, 160, 96)
|
||||
return box(c, k, o.Label, w, h).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ type SnowOptions struct {
|
||||
}
|
||||
|
||||
// Snow drifts flakes down, swaying; near ones are big, quick.
|
||||
func Snow(c *ui.Context, o SnowOptions) *ui.Element {
|
||||
func Snow(c *ui.Context, o SnowOptions) ui.Element {
|
||||
k := pixel.K(c)
|
||||
w, h := size("Snow", o.Width, o.Height, 160, 96)
|
||||
return box(c, k, o.Label, w, h).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ type SparkleOptions struct {
|
||||
var glints = [...]int{0, 1, 2, 1, 0, -1, -1, -1}
|
||||
|
||||
// Sparkle twinkles four stars around its middle, in turn.
|
||||
func Sparkle(c *ui.Context, o SparkleOptions) *ui.Element {
|
||||
func Sparkle(c *ui.Context, o SparkleOptions) ui.Element {
|
||||
k := pixel.K(c)
|
||||
n := pixel.Or("Sparkle Size", o.Size, 24)
|
||||
s := slotOr(o.Slot, pixel.Warn)
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ type StarfieldOptions struct {
|
||||
}
|
||||
|
||||
// Starfield scrolls three layers of stars, near ones fastest.
|
||||
func Starfield(c *ui.Context, o StarfieldOptions) *ui.Element {
|
||||
func Starfield(c *ui.Context, o StarfieldOptions) ui.Element {
|
||||
k := pixel.K(c)
|
||||
w, h := size("Starfield", o.Width, o.Height, 160, 96)
|
||||
return box(c, k, o.Label, w, h).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ type SunMoonOptions struct {
|
||||
}
|
||||
|
||||
// SunMoon arcs the sun by day, the moon by night.
|
||||
func SunMoon(c *ui.Context, hour int, o SunMoonOptions) *ui.Element {
|
||||
func SunMoon(c *ui.Context, hour int, o SunMoonOptions) ui.Element {
|
||||
checkHour("SunMoon", hour)
|
||||
k := pixel.K(c)
|
||||
w, h := size("SunMoon", o.Width, o.Height, 160, 96)
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ type VignetteOptions struct {
|
||||
}
|
||||
|
||||
// Vignette dithers a slot inward from edges; corners go solid.
|
||||
func Vignette(c *ui.Context, o VignetteOptions, content func()) *ui.Element {
|
||||
func Vignette(c *ui.Context, o VignetteOptions, content func()) ui.Element {
|
||||
k := pixel.K(c)
|
||||
s := slotOr(o.Slot, dark(k))
|
||||
return cover(k, ui.Column(c), func(g pixel.Canvas) { vignette(g, s) }, content)
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ type WaterfallOptions struct {
|
||||
}
|
||||
|
||||
// Waterfall pours between cliffs by cycling its water slots.
|
||||
func Waterfall(c *ui.Context, o WaterfallOptions) *ui.Element {
|
||||
func Waterfall(c *ui.Context, o WaterfallOptions) ui.Element {
|
||||
k := pixel.K(c)
|
||||
w, h := size("Waterfall", o.Width, o.Height, 64, 96)
|
||||
return box(c, k, o.Label, w, h).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
|
||||
Reference in new issue
Block a user