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>
33 lines
1.1 KiB
Go
33 lines
1.1 KiB
Go
package chat
|
|
|
|
import (
|
|
"github.com/egoist/mygo/ui"
|
|
|
|
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/display"
|
|
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
|
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/text"
|
|
)
|
|
|
|
type SpeechBubbleOptions struct {
|
|
// Width wraps the text; zero means 140.
|
|
Width int
|
|
}
|
|
|
|
// SpeechBubble shows who said what, when; tail their side.
|
|
func SpeechBubble(c *ui.Context, m Message, o SpeechBubbleOptions) ui.Element {
|
|
k := pixel.K(c)
|
|
w := pixel.Or("SpeechBubble Width", o.Width, 140)
|
|
// Yours sit right on Accent, written in AccentInk.
|
|
side, tail, fill, ink := ui.Start, display.Left, pixel.Lit, pixel.Ink
|
|
if m.Mine {
|
|
side, tail, fill, ink = ui.End, display.Right, pixel.Accent, pixel.AccentInk
|
|
}
|
|
return ui.Column(c).AlignSelf(side).AlignItems(side).Gap(k.D(1)).Children(func() {
|
|
pixel.Text(c, line(m.From, w), pixel.TextOptions{Slot: pixel.Faint})
|
|
display.Bubble(c, display.BubbleOptions{Tail: tail, At: 4, Fill: fill}, func() {
|
|
para(c, k, m.Text, w, 0, ink)
|
|
})
|
|
text.MicroText(c, clock(m.At), text.MicroTextOptions{Slot: pixel.Faint})
|
|
})
|
|
}
|