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
917 B
Go
43 lines
917 B
Go
package chat
|
||
|
||
import (
|
||
"fmt"
|
||
|
||
"github.com/egoist/mygo/ui"
|
||
|
||
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
||
)
|
||
|
||
type ReadReceiptOptions struct {
|
||
// Scale is 1–4; zero means 1.
|
||
Scale int
|
||
}
|
||
|
||
var check = pixel.MustSprite(`
|
||
....#
|
||
...##
|
||
#.##.
|
||
###..
|
||
.#...
|
||
`)
|
||
|
||
// ReadReceipt shows one check once sent, two once read.
|
||
func ReadReceipt(c *ui.Context, read bool, o ReadReceiptOptions) ui.Element {
|
||
k := pixel.K(c)
|
||
sc := pixel.Or("ReadReceipt Scale", o.Scale, 1)
|
||
if sc > 4 {
|
||
panic(fmt.Sprintf("chat: ReadReceipt Scale %d outside 1–4", sc))
|
||
}
|
||
label, ink, w := k.Msg("sent"), pixel.Faint, check.W
|
||
if read {
|
||
label, ink, w = k.Msg("seen"), pixel.Info, check.W+3
|
||
}
|
||
return ui.Box(c).Role(ui.RoleImage).Label(label).Size(k.D(w*sc), k.D(check.H*sc)).Draw(func(p *ui.Painter, r ui.Rect) {
|
||
g := k.Canvas(p, r)
|
||
g.Sprite(0, 0, check, 0, ink, sc)
|
||
if read {
|
||
g.Sprite(3*sc, 0, check, 0, ink, sc)
|
||
}
|
||
})
|
||
}
|