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>
52 lines
1.5 KiB
Go
52 lines
1.5 KiB
Go
package account
|
||
|
||
import (
|
||
"fmt"
|
||
"log/slog"
|
||
|
||
"github.com/egoist/mygo/ui"
|
||
|
||
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/input"
|
||
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
||
)
|
||
|
||
// Access is how a player wants motion and dots.
|
||
type Access struct {
|
||
// Reduce goes to pixel.Settings.Reduce, Dot to Settings.Dot.
|
||
Reduce bool
|
||
Dot int
|
||
}
|
||
|
||
type AccessibilityOptionsOptions struct {
|
||
Disabled bool
|
||
}
|
||
|
||
type AccessibilityOptionsResult struct {
|
||
Element ui.Element
|
||
Changed bool
|
||
}
|
||
|
||
// AccessibilityOptions sets Reduce Motion and the dot size, 1–4.
|
||
func AccessibilityOptions(c *ui.Context, text string, a *Access, o AccessibilityOptionsOptions) AccessibilityOptionsResult {
|
||
k := pixel.K(c)
|
||
if a.Dot < 1 || a.Dot > 4 {
|
||
panic(fmt.Sprintf("account: AccessibilityOptions dot %d outside 1–4", a.Dot))
|
||
}
|
||
var res AccessibilityOptionsResult
|
||
res.Element = ui.Column(c).Gap(k.D(6)).Role(ui.RoleGroup).Label(text).Children(func() {
|
||
reduce := input.Switch(c, k.Msg("reduce_motion"), &a.Reduce, input.SwitchOptions{Disabled: o.Disabled}).Changed
|
||
dot, sized := a.Dot-1, false
|
||
ui.Row(c).Gap(k.D(6)).AlignItems(ui.Center).Children(func() {
|
||
mark(c, k, k.Msg("dot_size"), pixel.Ink, 0)
|
||
if input.Segmented(c, k.Msg("dot_size"), []string{"1", "2", "3", "4"}, &dot, input.SegmentedOptions{Disabled: o.Disabled}).Changed {
|
||
a.Dot, sized = dot+1, true
|
||
}
|
||
})
|
||
res.Changed = reduce || sized
|
||
})
|
||
if res.Changed {
|
||
slog.Debug("8bit: accessibility options", "label", text, "reduce", a.Reduce, "dot", a.Dot)
|
||
}
|
||
return res
|
||
}
|