Audit keyboard, focus, veils, motion and clocks across all 500

A cross-cutting pass, each fix with a test that failed first.

Veils: MyGo still hands a key to a base that turned off this frame,
so every element key now goes through pixel.Shortcut, which an
archtest enforces. Input handlers record and the build applies them
only while enabled; the editor turns away a veil-frame letter or
copy; value bases get a copy and keep only enabled turns. Popups
give a held focus back to their opener when the veil lifts.

Motion: S5 is enforced at the clock. Every Tick, Since, Step,
Toward and Shot runs at 4-15 fps; blinks keep 1 Hz on 4 fps steps,
fast animations step at 15, and drawn time is quantized to frames.

Clocks stepping back: Since holds at zero without overflow, and
k.Elapsed moves a stored start to now, so nothing goes negative,
runs backward or indexes out of range.

Also: logs count typed text instead of holding it, gallery names
use glyphs the font has, removable rows are keyed, components take
their own Options (archtest), and sweeps over all 508 demos check
veiled keys, clicks, wheels, the clock stepping back and names.
This commit is contained in:
ZacharyZhang-NY committed 2026-10-12 16:03:04 -04:00
1 parent 81003b21ee
commit b4b4d67b92
198 files changed
+2708 -422

No files matched your search

+1 -1
View File
@@ -77,7 +77,7 @@ func AppWindow(c *ui.Context, title string, x, y *int, o AppWindowOptions, conte
key ui.Key
dx, dy int
}{{ui.KeyLeft, -4, 0}, {ui.KeyRight, 4, 0}, {ui.KeyUp, 0, -4}, {ui.KeyDown, 0, 4}} {
if base.Shortcut(0, m.key) {
if pixel.Shortcut(base, 0, m.key) {
*x, *y = *x+m.dx, *y+m.dy
}
}
+2 -2
View File
@@ -54,12 +54,12 @@ func Calculator(c *ui.Context, text string, o CalculatorOptions) CalculatorResul
// Digits and signs typed on the keyboard press their keys.
if picked < 0 && !base.IsDisabled() && !pixel.Typing(c) {
for i := range 10 {
if base.Shortcut(0, ui.Key0+ui.Key(i)) {
if pixel.Shortcut(base, 0, ui.Key0+ui.Key(i)) {
picked = indexOf(strconv.Itoa(i))
}
}
for _, s := range signs {
if base.Shortcut(s.mods, s.key) {
if pixel.Shortcut(base, s.mods, s.key) {
picked = indexOf(s.sign)
}
}
+1 -1
View File
@@ -34,7 +34,7 @@ func DesktopIcon(c *ui.Context, label string, icon *pixel.Sprite, o DesktopIconO
})
res := DesktopIconResult{Element: shell}
if !base.IsDisabled() {
res.Opened = base.Shortcut(0, ui.KeyEnter) || base.DoubleClicked()
res.Opened = pixel.Shortcut(base, 0, ui.KeyEnter) || base.DoubleClicked()
res.Clicked = base.Clicked()
}
if res.Clicked || res.Opened {
+1 -1
View File
@@ -79,7 +79,7 @@ func Minesweeper(c *ui.Context, label string, o MinesweeperOptions) MinesweeperR
})
shell, base, st, picked := pixel.Pad(c, k.Msg("minefield"), cols, cols*rows, mcell, mcell, &f.cur, o.Disabled)
if !base.IsDisabled() && !f.over {
if !pixel.Typing(c) && base.Shortcut(0, ui.KeyF) {
if !pixel.Typing(c) && pixel.Shortcut(base, 0, ui.KeyF) {
res.Flagged = f.toggle(f.cur)
}
if base.RightClicked() {
+1 -1
View File
@@ -70,7 +70,7 @@ func RunDialog(c *ui.Context, text string, value *string, o RunDialogOptions) Ru
})
})
// Escape quits from anywhere inside, as CANCEL does.
if !o.Disabled && !pixel.Current(c).Inert && win.Shortcut(0, ui.KeyEscape) {
if !o.Disabled && !pixel.Current(c).Inert && pixel.Shortcut(win, 0, ui.KeyEscape) {
res.Canceled = true
}
res.Element = win
+2 -2
View File
@@ -61,13 +61,13 @@ func Snake(c *ui.Context, text string, o SnakeOptions) SnakeResult {
d [2]int
}{{ui.KeyUp, [2]int{0, -1}}, {ui.KeyDown, [2]int{0, 1}}, {ui.KeyLeft, [2]int{-1, 0}}, {ui.KeyRight, [2]int{1, 0}}} {
// A turn back onto its own neck is ignored.
if base.Shortcut(0, m.key) && m.d != [2]int{-s.dir[0], -s.dir[1]} && !s.dead {
if pixel.Shortcut(base, 0, m.key) && m.d != [2]int{-s.dir[0], -s.dir[1]} && !s.dead {
res.Started = res.Started || !s.playing
s.next, s.playing = m.d, true
}
}
// Enter, Space or a click starts it, or CONTINUEs.
enter, space := base.Shortcut(0, ui.KeyEnter), base.Shortcut(0, ui.KeySpace)
enter, space := pixel.Shortcut(base, 0, ui.KeyEnter), pixel.Shortcut(base, 0, ui.KeySpace)
if enter || space || base.Clicked() {
if s.dead {
s.reset(cols, rows, o.Seed, uint64(k.Now().UnixNano()))
+2 -5
View File
@@ -48,11 +48,8 @@ func StartMenu(c *ui.Context, text string, programs []Program, o StartMenuOption
off := o.Disabled || pixel.Current(c).Inert
b := input.Button(c, k.Msg("start"), input.ButtonOptions{Icon: icon.Gamepad, Label: text, Disabled: o.Disabled})
m := ui.Local(b.Element, startKey{}, func() start { return start{} })
// START keeps the focus and parks it while off.
if off {
// Closing on disable must not return focus to it.
if m.open {
c.Root().Focus()
}
m.open = false
}
res := StartMenuResult{Element: b.Element}
@@ -60,7 +57,7 @@ func StartMenu(c *ui.Context, text string, programs []Program, o StartMenuOption
switch {
case b.Clicked && m.open:
m.open = false
case b.Clicked, !m.open && !off && b.Element.Shortcut(0, ui.KeyUp):
case b.Clicked, !m.open && !off && pixel.Shortcut(b.Element, 0, ui.KeyUp):
m.open, m.path = true, []int{0}
}
if m.open {
+29
View File
@@ -0,0 +1,29 @@
package desk_test
import (
"testing"
"github.com/egoist/mygo/ui"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/desk"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/icon"
)
func TestStartMenuGetsFocusBackAfterAVeil(t *testing.T) {
wd := newWorld()
programs := []desk.Program{{Name: "Paint", Icon: icon.File}, {Name: "Notes", Icon: icon.File}}
tt := view(400, 300, wd, func(c *ui.Context) { desk.StartMenu(c, "Start", programs, desk.StartMenuOptions{}) })
tt.Key(0, ui.KeyTab)
tt.Key(0, ui.KeyUp)
if !tt.HasText("Notes") {
t.Fatalf("the menu did not open: %q", tt.Texts())
}
wd.inert = true
tt.Frame()
wd.inert = false
tt.Frame()
tt.Key(0, ui.KeyUp)
if !tt.HasText("Notes") {
t.Fatal("START did not get its focus back after the veil")
}
}