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:
198 files changed
+2708
-422
No files matched your search
+13
-5
@@ -24,21 +24,26 @@ type MultiSelectResult struct {
|
||||
|
||||
type multiKey struct{}
|
||||
|
||||
// popup is open, and held the focus last frame.
|
||||
type popup struct{ open, held bool }
|
||||
|
||||
// MultiSelect checks many options in a popup; tags show them.
|
||||
func MultiSelect(c *ui.Context, text string, chosen *[]string, options []string, o MultiSelectOptions) MultiSelectResult {
|
||||
k := pixel.K(c)
|
||||
shell, base, st := pixel.Shell(c, func() *ui.Element {
|
||||
return ui.ButtonBase(c).Role(ui.RolePopUpButton).Label(text).Description(strings.Join(*chosen, ", ")).Disabled(o.Disabled)
|
||||
})
|
||||
open := ui.Local(base, multiKey{}, func() bool { return false })
|
||||
pop := ui.Local(base, multiKey{}, func() popup { return popup{} })
|
||||
open := &pop.open
|
||||
if o.Disabled || pixel.Current(c).Inert {
|
||||
// Closing on disable must not return focus to it.
|
||||
if *open {
|
||||
c.Root().Focus()
|
||||
// A focus in the closing popup parks on the field.
|
||||
if *open && pop.held {
|
||||
base.Focus()
|
||||
pixel.Park(c, base, true)
|
||||
}
|
||||
*open = false
|
||||
}
|
||||
if base.Clicked() || !*open && base.Shortcut(0, ui.KeyDown) {
|
||||
if base.Clicked() || !*open && pixel.Shortcut(base, 0, ui.KeyDown) {
|
||||
*open = !*open
|
||||
}
|
||||
shell.Size(k.D(pixel.Or("MultiSelect Width", o.Width, 160)), k.D(pixel.LineHeight+4)).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
@@ -52,6 +57,7 @@ func MultiSelect(c *ui.Context, text string, chosen *[]string, options []string,
|
||||
g.Finish(st)
|
||||
})
|
||||
res := MultiSelectResult{Element: shell}
|
||||
pop.held = false
|
||||
ui.PopoverBase(c, base, open, func(panel *ui.Element) {
|
||||
menu(c, panel, func() {
|
||||
col := ui.Column(c).Gap(k.D(1)).FocusGroup(ui.Vertical)
|
||||
@@ -62,6 +68,8 @@ func MultiSelect(c *ui.Context, text string, chosen *[]string, options []string,
|
||||
if i == 0 {
|
||||
cb.AutoFocus()
|
||||
}
|
||||
// Focused, not FocusWithin: MyGo links parents after frames.
|
||||
pop.held = pop.held || cb.Focused()
|
||||
if cb.Changed() {
|
||||
res.Changed = true
|
||||
if on {
|
||||
|
||||
Reference in new issue
Block a user