Files
8bitMyGoUI/project/project.go
T
ZacharyZhang-NY c8d058799d Add project components 421-435; Checkbox turns only when on
Fifteen project components: QuestBoard, TaskItem, TaskList, Milestones,
Burndown, Pomodoro, Priority, AssigneePicker, LabelPicker, TimeTracker,
Roadmap, SprintPanel, IssueCard, Checklist and WorkloadBar.

QuestBoard is one base that draws TODO, DOING and DONE; arrows move,
Alt with an arrow carries a card, and a drag carries it live. Priority
draws 12x12 bars, and Critical is on fire. Pomodoro banks time on PAUSE
and the tomato sleeps through the rest. Extreme inputs fail fast or
saturate instead of wrapping.

MyGo's CheckboxBase turns its value before Disabled is set, so
input.Checkbox now hands it a copy and keeps only turns of an enabled
base. The home scene test checks the sky row, not one pixel that
falling snow can cover.
2026-10-12 10:25:07 -04:00

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)
})
}