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>
40 lines
932 B
Go
40 lines
932 B
Go
package tabletop
|
||
|
||
import (
|
||
"fmt"
|
||
|
||
"github.com/egoist/mygo/ui"
|
||
|
||
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
||
)
|
||
|
||
type DominoOptions struct {
|
||
// Vertical stands the tile on end.
|
||
Vertical bool
|
||
}
|
||
|
||
// Domino is a tile of two halves of 0–6 pips.
|
||
func Domino(c *ui.Context, a, b int, o DominoOptions) ui.Element {
|
||
k := pixel.K(c)
|
||
if a < 0 || a > 6 || b < 0 || b > 6 {
|
||
panic(fmt.Sprintf("tabletop: Domino %d|%d", a, b))
|
||
}
|
||
w, h := 39, 20
|
||
if o.Vertical {
|
||
w, h = h, w
|
||
}
|
||
return ui.Box(c).Size(k.D(w), k.D(h)).Role(ui.RoleImage).Label(fmt.Sprintf("%d | %d", a, b)).Draw(func(p *ui.Painter, r ui.Rect) {
|
||
g := k.Canvas(p, r)
|
||
g.Frame(0, 0, w, h, pixel.Raised, pixel.Lit)
|
||
if o.Vertical {
|
||
g.HLine(3, 19, 14, pixel.Edge)
|
||
pips(g, 1, 1, 18, a, pixel.Ink)
|
||
pips(g, 1, 20, 18, b, pixel.Ink)
|
||
return
|
||
}
|
||
g.VLine(19, 3, 14, pixel.Edge)
|
||
pips(g, 1, 1, 18, a, pixel.Ink)
|
||
pips(g, 20, 1, 18, b, pixel.Ink)
|
||
})
|
||
}
|