Upgrade MyGo to v0.5.5
MyGo v0.5.5 returns ui.Element as a checked value handle instead of a
pointer. Migrated with `mygo migrate-ui`, then fixed what the codemod
leaves to review:
- Element nil checks become .Valid(); absent elements are ui.Element{}.
- Input handlers and paint callbacks run outside the build pass, where
elements expire and Context methods are inert: read IsDisabled into a
local during the build, keep a ui.Handle for Focus, use c.Services()
for clipboard access, create ui.Local state during the build.
- Add core.AutoFocus: v0.5.5 records an overlay's opener after its
content builds, so same-frame autofocus lost focus restore on close.
It focuses one frame later; cascader rows defer their focus likewise.
- core.OverlayLayer identifies build passes by the root element, not
c.Now(), which repeats across passes and under the Tester clock.
- Context menus survive the opening press counted as PressedOutside;
split button tooltip no longer reorders its open menu; disabled
menubar rows pass presses to the panel; Form defers blur-started
async checks so the growing message no longer moves Submit away
from the release; Combobox drops its disabled copy now that MyGo
blocks typing under a disabled wrapper (canary flipped to a guard).
- The Tester clock is virtual: tests use Advance/Now instead of
time.Sleep/time.Now and read element state inside the view. The web
mirror advances the clock to wall time before each frame and input.
- AGENTS.md and docs describe the value Element API and the new pin.
Snapshot goldens are darwin-only and were not re-verified here.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
bc716d27be
commit
bcce34cda1
603 files changed
+1366
-1277
No files matched your search
@@ -79,14 +79,14 @@ func (g *gallery) settingsGeneral(c *ui.Context, log func(string)) {
|
||||
settingsPanel(c, func() {
|
||||
bad := g.workspaceError(d.workspace)
|
||||
input.FormField(c, g.t("Workspace name", "工作区名称"), input.FormFieldOptions{Required: true, Error: bad,
|
||||
Description: g.t("Shown in the title bar.", "显示在标题栏中。")}, func() *ui.Element {
|
||||
Description: g.t("Shown in the title bar.", "显示在标题栏中。")}, func() ui.Element {
|
||||
r := input.TextInput(c, &d.workspace, input.TextInputOptions{Error: bad})
|
||||
if r.Changed() {
|
||||
log(fmt.Sprintf("workspace %q", d.workspace))
|
||||
}
|
||||
return r.Input
|
||||
})
|
||||
input.FormField(c, g.t("Language", "语言"), input.FormFieldOptions{}, func() *ui.Element {
|
||||
input.FormField(c, g.t("Language", "语言"), input.FormFieldOptions{}, func() ui.Element {
|
||||
r := input.Select(c, &d.language, []input.SelectOption[string]{
|
||||
{Value: "en", Label: "English"}, {Value: "zh", Label: "简体中文"}, {Value: "ja", Label: "日本語"},
|
||||
}, input.SelectOptions{})
|
||||
@@ -95,7 +95,7 @@ func (g *gallery) settingsGeneral(c *ui.Context, log func(string)) {
|
||||
}
|
||||
return r.Element
|
||||
})
|
||||
input.FormField(c, g.t("On startup", "启动时"), input.FormFieldOptions{}, func() *ui.Element {
|
||||
input.FormField(c, g.t("On startup", "启动时"), input.FormFieldOptions{}, func() ui.Element {
|
||||
r := input.RadioGroup(c, &d.startPage, []input.RadioItem[string]{
|
||||
{Value: "blank", Label: g.t("Open a blank page", "打开空白页")},
|
||||
{Value: "last", Label: g.t("Reopen the last session", "恢复上次会话")},
|
||||
@@ -106,7 +106,7 @@ func (g *gallery) settingsGeneral(c *ui.Context, log func(string)) {
|
||||
}
|
||||
return r.Element
|
||||
})
|
||||
input.FormField(c, g.t("Login item", "登录项"), input.FormFieldOptions{}, func() *ui.Element {
|
||||
input.FormField(c, g.t("Login item", "登录项"), input.FormFieldOptions{}, func() ui.Element {
|
||||
e := input.Switch(c, &d.launch, g.t("Launch at login", "登录时启动"), input.SwitchOptions{})
|
||||
if e.Changed() {
|
||||
log(fmt.Sprintf("launch at login %v", d.launch))
|
||||
@@ -119,7 +119,7 @@ func (g *gallery) settingsGeneral(c *ui.Context, log func(string)) {
|
||||
func (g *gallery) settingsAppearance(c *ui.Context, log func(string)) {
|
||||
d := &g.cSettings.draft
|
||||
settingsPanel(c, func() {
|
||||
input.FormField(c, g.t("Theme", "主题"), input.FormFieldOptions{}, func() *ui.Element {
|
||||
input.FormField(c, g.t("Theme", "主题"), input.FormFieldOptions{}, func() ui.Element {
|
||||
r := input.RadioGroup(c, &d.theme, []input.RadioItem[string]{
|
||||
{Value: "system", Label: g.t("System", "跟随系统")}, {Value: "light", Label: g.t("Light", "浅色")}, {Value: "dark", Label: g.t("Dark", "深色")},
|
||||
}, input.RadioGroupOptions{Horizontal: true})
|
||||
@@ -128,7 +128,7 @@ func (g *gallery) settingsAppearance(c *ui.Context, log func(string)) {
|
||||
}
|
||||
return r.Element
|
||||
})
|
||||
input.FormField(c, g.t("Text size", "文字大小"), input.FormFieldOptions{}, func() *ui.Element {
|
||||
input.FormField(c, g.t("Text size", "文字大小"), input.FormFieldOptions{}, func() ui.Element {
|
||||
r := input.Slider(c, &d.fontSize, input.SliderOptions{Min: 12, Max: 20, Step: 1, ShowValue: true,
|
||||
Marks: []input.SliderMark{{Value: 12, Label: "12"}, {Value: 16, Label: "16"}, {Value: 20, Label: "20"}},
|
||||
Format: func(v float64) string { return fmt.Sprintf("%.0f pt", v) }})
|
||||
@@ -137,14 +137,14 @@ func (g *gallery) settingsAppearance(c *ui.Context, log func(string)) {
|
||||
}
|
||||
return r.Element
|
||||
})
|
||||
input.FormField(c, g.t("Sidebar width", "侧栏宽度"), input.FormFieldOptions{Description: g.t("In DIPs, from 180 to 360.", "单位 DIP,180 至 360。")}, func() *ui.Element {
|
||||
input.FormField(c, g.t("Sidebar width", "侧栏宽度"), input.FormFieldOptions{Description: g.t("In DIPs, from 180 to 360.", "单位 DIP,180 至 360。")}, func() ui.Element {
|
||||
r := input.NumberInput(c, &d.sidebar, input.NumberInputOptions{Min: 180, Max: 360, Step: 10})
|
||||
if r.Changed() {
|
||||
log(fmt.Sprintf("sidebar width %.0f", d.sidebar))
|
||||
}
|
||||
return r.Input
|
||||
})
|
||||
input.FormField(c, g.t("Motion", "动效"), input.FormFieldOptions{}, func() *ui.Element {
|
||||
input.FormField(c, g.t("Motion", "动效"), input.FormFieldOptions{}, func() ui.Element {
|
||||
e := input.Switch(c, &d.reduce, g.t("Reduce motion", "减少动效"), input.SwitchOptions{})
|
||||
if e.Changed() {
|
||||
log(fmt.Sprintf("reduce motion %v", d.reduce))
|
||||
@@ -157,28 +157,28 @@ func (g *gallery) settingsAppearance(c *ui.Context, log func(string)) {
|
||||
func (g *gallery) settingsPrivacy(c *ui.Context, log func(string)) {
|
||||
d := &g.cSettings.draft
|
||||
settingsPanel(c, func() {
|
||||
input.FormField(c, g.t("Usage data", "使用数据"), input.FormFieldOptions{Description: g.t("Nothing leaves this demo.", "本示例不会发送任何数据。")}, func() *ui.Element {
|
||||
input.FormField(c, g.t("Usage data", "使用数据"), input.FormFieldOptions{Description: g.t("Nothing leaves this demo.", "本示例不会发送任何数据。")}, func() ui.Element {
|
||||
e := input.Switch(c, &d.telemetry, g.t("Share anonymous usage data", "共享匿名使用数据"), input.SwitchOptions{})
|
||||
if e.Changed() {
|
||||
log(fmt.Sprintf("usage data %v", d.telemetry))
|
||||
}
|
||||
return e
|
||||
})
|
||||
input.FormField(c, g.t("Crash reports", "崩溃报告"), input.FormFieldOptions{}, func() *ui.Element {
|
||||
input.FormField(c, g.t("Crash reports", "崩溃报告"), input.FormFieldOptions{}, func() ui.Element {
|
||||
e := input.Switch(c, &d.crashes, g.t("Send crash reports", "发送崩溃报告"), input.SwitchOptions{})
|
||||
if e.Changed() {
|
||||
log(fmt.Sprintf("crash reports %v", d.crashes))
|
||||
}
|
||||
return e
|
||||
})
|
||||
input.FormField(c, g.t("Keep history", "保留历史"), input.FormFieldOptions{Description: g.t("Days, from 0 to 365; 0 keeps none.", "天数,0 至 365;0 表示不保留。")}, func() *ui.Element {
|
||||
input.FormField(c, g.t("Keep history", "保留历史"), input.FormFieldOptions{Description: g.t("Days, from 0 to 365; 0 keeps none.", "天数,0 至 365;0 表示不保留。")}, func() ui.Element {
|
||||
r := input.NumberInput(c, &d.history, input.NumberInputOptions{Min: 0, Max: 365, Step: 1})
|
||||
if r.Changed() {
|
||||
log(fmt.Sprintf("history %.0f days", d.history))
|
||||
}
|
||||
return r.Input
|
||||
})
|
||||
input.FormField(c, g.t("Lock after", "自动锁定"), input.FormFieldOptions{}, func() *ui.Element {
|
||||
input.FormField(c, g.t("Lock after", "自动锁定"), input.FormFieldOptions{}, func() ui.Element {
|
||||
r := input.Select(c, &d.lock, []input.SelectOption[string]{
|
||||
{Value: "never", Label: g.t("Never", "从不")}, {Value: "5", Label: g.t("5 minutes", "5 分钟")},
|
||||
{Value: "15", Label: g.t("15 minutes", "15 分钟")}, {Value: "60", Label: g.t("1 hour", "1 小时")},
|
||||
|
||||
Reference in new issue
Block a user