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>
61 lines
1.4 KiB
Go
61 lines
1.4 KiB
Go
// Package project holds task, planning and team components.
|
|
package project
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/egoist/mygo/ui"
|
|
|
|
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
|
)
|
|
|
|
// Level is how urgent a task is.
|
|
type Level int
|
|
|
|
const (
|
|
Low Level = iota
|
|
Medium
|
|
High
|
|
Critical
|
|
)
|
|
|
|
var levels = [...]string{"low", "medium", "high", "critical"}
|
|
|
|
// word is a level in the locale; unknown ones panic.
|
|
func (l Level) word(k pixel.Kit) string {
|
|
if l < Low || l > Critical {
|
|
panic(fmt.Sprintf("project: unknown level %d", l))
|
|
}
|
|
return k.Msg(levels[l])
|
|
}
|
|
|
|
// Label is a named tag in a palette slot.
|
|
type Label struct {
|
|
Name string
|
|
Slot pixel.Slot
|
|
}
|
|
|
|
// month is a month's short name in the frame's locale.
|
|
func month(k pixel.Kit, m time.Month) string {
|
|
return strings.Fields(k.Msg("months"))[m-1]
|
|
}
|
|
|
|
// hms prints d as H:MM:SS, or MM:SS under an hour.
|
|
func hms(d time.Duration) string {
|
|
d = d.Truncate(time.Second)
|
|
h, m, s := int(d.Hours()), int(d.Minutes())%60, int(d.Seconds())%60
|
|
if h > 0 {
|
|
return fmt.Sprintf("%d:%02d:%02d", h, m, s)
|
|
}
|
|
return fmt.Sprintf("%02d:%02d", m, s)
|
|
}
|
|
|
|
// show draws s unnamed, beside an element that names it.
|
|
func show(c *ui.Context, k pixel.Kit, s string, slot pixel.Slot, w int) ui.Element {
|
|
return ui.Box(c).Size(k.D(w), k.D(pixel.LineHeight)).Draw(func(p *ui.Painter, r ui.Rect) {
|
|
k.Canvas(p, r).Text(0, 0, pixel.Wrap(s, w, 1)[0], slot, 1)
|
|
})
|
|
}
|