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>
28 lines
766 B
Go
28 lines
766 B
Go
package chart
|
|
|
|
import (
|
|
"github.com/egoist/mygo/ui"
|
|
|
|
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
|
)
|
|
|
|
type PieChartOptions struct {
|
|
// Size is the pie's width in dots; zero means 64.
|
|
Size int
|
|
}
|
|
|
|
// PieChart rasterizes one sector per slice, dot by dot.
|
|
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)
|
|
return ui.Box(c).Size(k.D(n), k.D(n)).Role(ui.RoleImage).Label(text).Description(readSlices(slices)).Draw(func(p *ui.Painter, r ui.Rect) {
|
|
g := k.Canvas(p, r)
|
|
c, rad := n/2, n/2-1
|
|
for i, s := range slices {
|
|
sector(g, c, c, 0, rad, cuts[i], cuts[i+1], pick(s.Slot, i))
|
|
}
|
|
g.Circle(c, c, rad, pixel.Edge)
|
|
})
|
|
}
|