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>
56 lines
1.4 KiB
Go
56 lines
1.4 KiB
Go
package project
|
|
|
|
import (
|
|
"log/slog"
|
|
|
|
"github.com/egoist/mygo/ui"
|
|
|
|
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/display"
|
|
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/input"
|
|
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
|
)
|
|
|
|
// Task is a thing to do.
|
|
type Task struct {
|
|
Title string
|
|
Done bool
|
|
Priority Level
|
|
// Assignee is a party member's name; empty is nobody.
|
|
Assignee string
|
|
}
|
|
|
|
type TaskItemOptions struct {
|
|
Disabled bool
|
|
}
|
|
|
|
type TaskItemResult struct {
|
|
Element ui.Element
|
|
Changed bool
|
|
}
|
|
|
|
// TaskItem is a checkbox, title, priority and assignee.
|
|
func TaskItem(c *ui.Context, t *Task, o TaskItemOptions) TaskItemResult {
|
|
k := pixel.K(c)
|
|
if t.Title == "" {
|
|
panic("project: TaskItem has no title")
|
|
}
|
|
var res TaskItemResult
|
|
res.Element = ui.Row(c).FillWidth().Gap(k.D(6)).AlignItems(ui.Center).Children(func() {
|
|
res.Changed = input.Checkbox(c, t.Title, &t.Done, input.CheckboxOptions{Disabled: o.Disabled}).Changed
|
|
ui.Box(c).Grow(1)
|
|
Priority(c, t.Priority, PriorityOptions{})
|
|
// Nobody shows as an empty dotted seat.
|
|
if t.Assignee == "" {
|
|
ui.Box(c).Size(k.D(16), k.D(16)).Role(ui.RoleImage).Label(k.Msg("nobody")).Draw(func(p *ui.Painter, r ui.Rect) {
|
|
k.Canvas(p, r).Veil(0, 0, 16, 16, pixel.Shade, 8)
|
|
})
|
|
return
|
|
}
|
|
display.Avatar(c, t.Assignee, display.AvatarOptions{})
|
|
})
|
|
if res.Changed {
|
|
slog.Debug("8bit: task", "done", t.Done)
|
|
}
|
|
return res
|
|
}
|