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:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-17 01:31:08 -04:00
1 parent 1f3d38110e
commit 03e1f91706
532 files changed
+828 -735

No files matched your search

+1 -1
View File
@@ -15,7 +15,7 @@ type AreaChartOptions struct {
}
// AreaChart draws a line with the area below it dithered.
func AreaChart(c *ui.Context, text string, labels []string, values []float64, o AreaChartOptions) *ui.Element {
func AreaChart(c *ui.Context, text string, labels []string, values []float64, o AreaChartOptions) ui.Element {
k := pixel.K(c)
w, h := size("AreaChart", o.Width, o.Height, 160, 80)
if len(values) != len(labels) || len(values) < 2 {
+1 -1
View File
@@ -77,7 +77,7 @@ type AxisOptions struct {
}
// Axis draws ticks and micro labels, for any chart.
func Axis(c *ui.Context, o AxisOptions) *ui.Element {
func Axis(c *ui.Context, o AxisOptions) ui.Element {
k := pixel.K(c)
n := pixel.Or("Axis Length", o.Length, 120)
marks := o.Labels
+1 -1
View File
@@ -17,7 +17,7 @@ type BarChartOptions struct {
}
// BarChart stands bars on micro-font axes; hover reads a value.
func BarChart(c *ui.Context, text string, labels []string, values []float64, o BarChartOptions) *ui.Element {
func BarChart(c *ui.Context, text string, labels []string, values []float64, o BarChartOptions) ui.Element {
k := pixel.K(c)
if len(labels) != len(values) || len(values) == 0 {
panic(fmt.Sprintf("chart: BarChart has %d labels for %d values", len(labels), len(values)))
+1 -1
View File
@@ -27,7 +27,7 @@ func quartile(sorted []float64, q float64) float64 {
}
// BoxPlot boxes each group's quartiles; whiskers reach its ends.
func BoxPlot(c *ui.Context, text string, groups []Series, o BoxPlotOptions) *ui.Element {
func BoxPlot(c *ui.Context, text string, groups []Series, o BoxPlotOptions) ui.Element {
k := pixel.K(c)
if len(groups) == 0 {
panic("chart: BoxPlot has no groups")
+1 -1
View File
@@ -16,7 +16,7 @@ type BubbleChartOptions struct {
}
// BubbleChart draws points as discs, area by Size.
func BubbleChart(c *ui.Context, text string, points []Point, o BubbleChartOptions) *ui.Element {
func BubbleChart(c *ui.Context, text string, points []Point, o BubbleChartOptions) ui.Element {
k := pixel.K(c)
w, h := size("BubbleChart", o.Width, o.Height, 160, 80)
f := fitPoints(points, w, h, 8)
+1 -1
View File
@@ -14,7 +14,7 @@ type BulletChartOptions struct {
}
// BulletChart lays a bar on rising ranges and a target.
func BulletChart(c *ui.Context, text string, value, target float64, ranges []float64, o BulletChartOptions) *ui.Element {
func BulletChart(c *ui.Context, text string, value, target float64, ranges []float64, o BulletChartOptions) ui.Element {
k := pixel.K(c)
if len(ranges) == 0 {
panic("chart: BulletChart needs ranges")
+1 -1
View File
@@ -20,7 +20,7 @@ type CalendarHeatmapOptions struct {
const day = 5
// CalendarHeatmap rates a year's UTC days 0–4, week by week.
func CalendarHeatmap(c *ui.Context, text string, year int, level func(d time.Time) int, o CalendarHeatmapOptions) *ui.Element {
func CalendarHeatmap(c *ui.Context, text string, year int, level func(d time.Time) int, o CalendarHeatmapOptions) ui.Element {
k := pixel.K(c)
ink := o.Slot
if ink == 0 {
+1 -1
View File
@@ -21,7 +21,7 @@ type CandlestickOptions struct {
}
// Candlestick draws wicks and bodies: up Good, down Bad.
func Candlestick(c *ui.Context, text string, candles []Candle, o CandlestickOptions) *ui.Element {
func Candlestick(c *ui.Context, text string, candles []Candle, o CandlestickOptions) ui.Element {
k := pixel.K(c)
if len(candles) == 0 {
panic("chart: Candlestick has no candles")
+1 -1
View File
@@ -12,7 +12,7 @@ type CrosshairOptions struct {
}
// Crosshair is a line chart; hover crosses the nearest point.
func Crosshair(c *ui.Context, text string, labels []string, series []Series, o CrosshairOptions) *ui.Element {
func Crosshair(c *ui.Context, text string, labels []string, series []Series, o CrosshairOptions) ui.Element {
k := pixel.K(c)
w, h := size("Crosshair", o.Width, o.Height, 160, 80)
p := fitSeries(labels, series, w, h)
+1 -1
View File
@@ -12,7 +12,7 @@ type DonutChartOptions struct {
}
// DonutChart is a pie with a hole holding the total.
func DonutChart(c *ui.Context, text string, slices []Slice, o DonutChartOptions) *ui.Element {
func DonutChart(c *ui.Context, text string, slices []Slice, o DonutChartOptions) ui.Element {
k := pixel.K(c)
n := pixel.Or("DonutChart Size", o.Size, 64)
total, cuts := shares(slices)
+1 -1
View File
@@ -14,7 +14,7 @@ type FunnelOptions struct {
}
// Funnel narrows stage by stage, each bar with its count.
func Funnel(c *ui.Context, text string, stages []Slice, o FunnelOptions) *ui.Element {
func Funnel(c *ui.Context, text string, stages []Slice, o FunnelOptions) ui.Element {
k := pixel.K(c)
if len(stages) == 0 {
panic("chart: Funnel has no stages")
+1 -1
View File
@@ -17,7 +17,7 @@ type GaugeOptions struct {
}
// Gauge needles a half dial and prints the value.
func Gauge(c *ui.Context, text string, value float64, o GaugeOptions) *ui.Element {
func Gauge(c *ui.Context, text string, value float64, o GaugeOptions) ui.Element {
k := pixel.K(c)
span([]float64{o.Min, o.Max, value})
lo, hi := o.Min, o.Max
+1 -1
View File
@@ -16,7 +16,7 @@ type HeatmapOptions struct {
}
// Heatmap shades cells by dither level between two slots.
func Heatmap(c *ui.Context, text string, rows, cols []string, values [][]float64, o HeatmapOptions) *ui.Element {
func Heatmap(c *ui.Context, text string, rows, cols []string, values [][]float64, o HeatmapOptions) ui.Element {
k := pixel.K(c)
if len(values) != len(rows) {
panic(fmt.Sprintf("chart: Heatmap has %d rows of values for %d rows", len(values), len(rows)))
+1 -1
View File
@@ -17,7 +17,7 @@ type HistogramOptions struct {
}
// Histogram counts values into bins, side by side.
func Histogram(c *ui.Context, text string, values []float64, o HistogramOptions) *ui.Element {
func Histogram(c *ui.Context, text string, values []float64, o HistogramOptions) ui.Element {
k := pixel.K(c)
n := pixel.Or("Histogram Bins", o.Bins, 8)
w, h := size("Histogram", o.Width, o.Height, 160, 80)
+1 -1
View File
@@ -16,7 +16,7 @@ type HorizontalBarOptions struct {
}
// HorizontalBar lays labeled bars across, longest to the edge.
func HorizontalBar(c *ui.Context, text string, labels []string, values []float64, o HorizontalBarOptions) *ui.Element {
func HorizontalBar(c *ui.Context, text string, labels []string, values []float64, o HorizontalBarOptions) ui.Element {
k := pixel.K(c)
if len(labels) != len(values) || len(values) == 0 {
panic(fmt.Sprintf("chart: HorizontalBar has %d labels for %d values", len(labels), len(values)))
+2 -2
View File
@@ -14,7 +14,7 @@ type LegendOptions struct {
}
type LegendResult struct {
Element *ui.Element
Element ui.Element
Changed bool
}
@@ -29,7 +29,7 @@ func Legend(c *ui.Context, text string, series []Series, hidden []bool, o Legend
row.Children(func() {
for i, s := range series {
shown := !hidden[i]
shell, base, st := pixel.Shell(c, func() *ui.Element { return ui.ToggleBase(c, &shown).Label(s.Name).Disabled(o.Disabled) })
shell, base, st := pixel.Shell(c, func() ui.Element { return ui.ToggleBase(c, &shown).Label(s.Name).Disabled(o.Disabled) })
// The base turns before it learns it is off.
if base.Changed() && !base.IsDisabled() {
hidden[i], res.Changed = !shown, true
+1 -1
View File
@@ -14,7 +14,7 @@ type LineChartOptions struct {
}
// LineChart draws series as Bresenham lines with square markers.
func LineChart(c *ui.Context, text string, labels []string, series []Series, o LineChartOptions) *ui.Element {
func LineChart(c *ui.Context, text string, labels []string, series []Series, o LineChartOptions) ui.Element {
k := pixel.K(c)
w, h := size("LineChart", o.Width, o.Height, 160, 80)
p := fitSeries(labels, series, w, h)
+1 -1
View File
@@ -12,7 +12,7 @@ type PieChartOptions struct {
}
// PieChart rasterizes one sector per slice, dot by dot.
func PieChart(c *ui.Context, text string, slices []Slice, o PieChartOptions) *ui.Element {
func PieChart(c *ui.Context, text string, slices []Slice, o PieChartOptions) ui.Element {
k := pixel.K(c)
n := pixel.Or("PieChart Size", o.Size, 64)
_, cuts := shares(slices)
+1 -1
View File
@@ -12,7 +12,7 @@ type PolarAreaOptions struct {
}
// PolarArea gives slices equal turns, reaching out by value.
func PolarArea(c *ui.Context, text string, slices []Slice, o PolarAreaOptions) *ui.Element {
func PolarArea(c *ui.Context, text string, slices []Slice, o PolarAreaOptions) ui.Element {
k := pixel.K(c)
n := pixel.Or("PolarArea Size", o.Size, 64)
shares(slices)
+1 -1
View File
@@ -16,7 +16,7 @@ type ProgressRingOptions struct {
}
// ProgressRing fills a ring clockwise from twelve, in pixel arcs.
func ProgressRing(c *ui.Context, text string, value float64, o ProgressRingOptions) *ui.Element {
func ProgressRing(c *ui.Context, text string, value float64, o ProgressRingOptions) ui.Element {
k := pixel.K(c)
if !(value >= 0 && value <= 1) {
panic(fmt.Sprintf("chart: ProgressRing value %v outside 0–1", value))
+1 -1
View File
@@ -14,7 +14,7 @@ type PyramidOptions struct {
}
// Pyramid sets two series back to back by group.
func Pyramid(c *ui.Context, text string, groups []string, left, right Series, o PyramidOptions) *ui.Element {
func Pyramid(c *ui.Context, text string, groups []string, left, right Series, o PyramidOptions) ui.Element {
k := pixel.K(c)
if len(left.Values) != len(groups) || len(right.Values) != len(groups) {
panic(fmt.Sprintf("chart: Pyramid has %d groups for %d and %d values", len(groups), len(left.Values), len(right.Values)))
+1 -1
View File
@@ -18,7 +18,7 @@ type RadarChartOptions struct {
}
// RadarChart draws a stat polygon on a web of axes.
func RadarChart(c *ui.Context, text string, axes []string, values []float64, o RadarChartOptions) *ui.Element {
func RadarChart(c *ui.Context, text string, axes []string, values []float64, o RadarChartOptions) ui.Element {
k := pixel.K(c)
if len(axes) != len(values) || len(axes) < 3 {
panic(fmt.Sprintf("chart: RadarChart has %d axes for %d values", len(axes), len(values)))
+1 -1
View File
@@ -13,7 +13,7 @@ type ScatterPlotOptions struct {
}
// ScatterPlot puts each point as a 2×2 square.
func ScatterPlot(c *ui.Context, text string, points []Point, o ScatterPlotOptions) *ui.Element {
func ScatterPlot(c *ui.Context, text string, points []Point, o ScatterPlotOptions) ui.Element {
k := pixel.K(c)
w, h := size("ScatterPlot", o.Width, o.Height, 160, 80)
f := fitPoints(points, w, h, 2)
+1 -1
View File
@@ -13,7 +13,7 @@ type SparklineOptions struct {
}
// Sparkline is a line one text line high, end marked.
func Sparkline(c *ui.Context, text string, values []float64, o SparklineOptions) *ui.Element {
func Sparkline(c *ui.Context, text string, values []float64, o SparklineOptions) ui.Element {
k := pixel.K(c)
w := pixel.Or("Sparkline Width", o.Width, 48)
if len(values) < 2 {
+1 -1
View File
@@ -24,7 +24,7 @@ type peaks struct {
}
// SpectrumBars lights segmented bars; peak dots fall behind them.
func SpectrumBars(c *ui.Context, text string, levels []float64, o SpectrumBarsOptions) *ui.Element {
func SpectrumBars(c *ui.Context, text string, levels []float64, o SpectrumBarsOptions) ui.Element {
k := pixel.K(c)
n := pixel.Or("SpectrumBars Segments", o.Segments, 10)
for _, l := range levels {
+1 -1
View File
@@ -14,7 +14,7 @@ type StackedBarOptions struct {
}
// StackedBar stacks each category's series, one slot per series.
func StackedBar(c *ui.Context, text string, labels []string, series []Series, o StackedBarOptions) *ui.Element {
func StackedBar(c *ui.Context, text string, labels []string, series []Series, o StackedBarOptions) ui.Element {
k := pixel.K(c)
if len(labels) == 0 {
panic("chart: StackedBar has no labels")
+1 -1
View File
@@ -13,7 +13,7 @@ type StepChartOptions struct {
}
// StepChart holds each value flat, then steps to the next.
func StepChart(c *ui.Context, text string, labels []string, values []float64, o StepChartOptions) *ui.Element {
func StepChart(c *ui.Context, text string, labels []string, values []float64, o StepChartOptions) ui.Element {
k := pixel.K(c)
w, h := size("StepChart", o.Width, o.Height, 160, 80)
p := fitSeries(labels, []Series{{Name: text, Values: values}}, w, h)
+1 -1
View File
@@ -17,7 +17,7 @@ type TreemapOptions struct {
type box struct{ x, y, w, h int }
// Treemap tiles slices by value in squarified rectangles.
func Treemap(c *ui.Context, text string, slices []Slice, o TreemapOptions) *ui.Element {
func Treemap(c *ui.Context, text string, slices []Slice, o TreemapOptions) ui.Element {
k := pixel.K(c)
w, h := size("Treemap", o.Width, o.Height, 160, 80)
total, _ := shares(slices)
+1 -1
View File
@@ -14,7 +14,7 @@ type WaterfallOptions struct {
}
// Waterfall walks a running total: Good up, Bad down.
func Waterfall(c *ui.Context, text string, labels []string, deltas []float64, o WaterfallOptions) *ui.Element {
func Waterfall(c *ui.Context, text string, labels []string, deltas []float64, o WaterfallOptions) ui.Element {
k := pixel.K(c)
if len(labels) != len(deltas) || len(deltas) == 0 {
panic(fmt.Sprintf("chart: Waterfall has %d labels for %d steps", len(labels), len(deltas)))
+1 -1
View File
@@ -11,7 +11,7 @@ import (
type WinLossOptions struct{}
// WinLoss rows blocks: wins up, losses down, draws dashed.
func WinLoss(c *ui.Context, text string, results []int, o WinLossOptions) *ui.Element {
func WinLoss(c *ui.Context, text string, results []int, o WinLossOptions) ui.Element {
k := pixel.K(c)
return ui.Box(c).Size(k.D(len(results)*5), k.D(pixel.LineHeight)).Role(ui.RoleImage).Label(text).
Description(record(results)).Draw(func(p *ui.Painter, r ui.Rect) {