Files
ZacharyZhang-NYandClaude Opus 5.5 03e1f91706 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>
2026-10-17 01:31:08 -04:00

54 lines
1.4 KiB
Go

package chat
import (
"fmt"
"github.com/egoist/mygo/ui"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/display"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
)
// Member is a name and how present they are.
type Member struct {
Name string
Status display.Status
}
type MemberListOptions struct {
// Width is in dots; zero means 140.
Width int
}
// MemberList groups members online and offline, with status dots.
func MemberList(c *ui.Context, text string, members []Member, o MemberListOptions) ui.Element {
k := pixel.K(c)
w := pixel.Or("MemberList Width", o.Width, 140)
var on, off []Member
for _, m := range members {
if m.Status == display.Offline {
off = append(off, m)
} else {
on = append(on, m)
}
}
return ui.Column(c).Width(k.D(w)).Gap(k.D(2)).Role(ui.RoleList).Label(text).Children(func() {
for _, g := range []struct {
key string
ms []Member
ink pixel.Slot
}{{"online", on, pixel.Ink}, {"offline", off, pixel.Faint}} {
if len(g.ms) == 0 {
continue
}
pixel.Text(c, fmt.Sprintf("%s · %d", k.Msg(g.key), len(g.ms)), pixel.TextOptions{Slot: pixel.Faint})
for _, m := range g.ms {
ui.Row(c).Gap(k.D(4)).AlignItems(ui.Center).Padding(0, 0, 0, k.D(4)).Children(func() {
display.StatusDot(c, m.Status, display.StatusDotOptions{})
pixel.Text(c, line(m.Name, w-15), pixel.TextOptions{Slot: g.ink})
})
}
}
})
}