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:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-17 01:37:54 -04:00
1 parent bc716d27be
commit bcce34cda1
603 files changed
+1366 -1277

No files matched your search

+7 -6
View File
@@ -29,7 +29,7 @@ type AccountSwitcherOptions struct {
// AccountSwitcherResult reports account changes and addition requests.
type AccountSwitcherResult struct {
Element *ui.Element
Element ui.Element
changed bool
add bool
}
@@ -75,7 +75,7 @@ func AccountSwitcher(c *ui.Context, current *string, accounts []Account, opts Ac
if a.Email != "" {
label += " · " + a.Email
}
ui.Column(c).Key(a.ID).Shrink(0).Children(func() {
ui.Column(c.Key(a.ID)).Shrink(0).Children(func() {
if m.Check(label, &on, overlay.PopupMenuItemOptions{}) && a.ID != *current && !b.IsDisabled() {
*current, r.changed = a.ID, true
slog.Debug("mujica: account_switcher switched")
@@ -92,7 +92,7 @@ func AccountSwitcher(c *ui.Context, current *string, accounts []Account, opts Ac
return r
}
func accountSwitcherLarge(c *ui.Context, b *ui.Element, open *bool, current *string, accounts []Account, r *AccountSwitcherResult) {
func accountSwitcherLarge(c *ui.Context, b ui.Element, open *bool, current *string, accounts []Account, r *AccountSwitcherResult) {
overlay.Popover(c, b, open, overlay.PopoverOptions{Label: core.Msg(c, "account_switcher.accounts"), Width: 320}, func() {
cursor := ui.Local(b, "cursor", func() int { return -1 })
rows := ui.Local(b, "list", func() ui.ListState { return ui.ListState{} })
@@ -100,7 +100,7 @@ func accountSwitcherLarge(c *ui.Context, b *ui.Element, open *bool, current *str
rows.Label = func(i int) string { return accounts[i].Name }
rows.Selected = cursor
restore := data.DataSelectTheme(c, 0)
list := ui.List(c, rows, len(accounts), func(i int) {
list := core.AutoFocus(c, ui.List(c, rows, len(accounts), func(i int) {
a := accounts[i]
row := workspaceRow(c, Workspace{ID: a.ID, Name: a.Name, Detail: a.Email}, a.ID == *current, i == *cursor)
if row.Focused() && !b.IsDisabled() {
@@ -109,7 +109,8 @@ func accountSwitcherLarge(c *ui.Context, b *ui.Element, open *bool, current *str
if row.Clicked() && !row.IsDisabled() && !b.IsDisabled() {
r.changed, *current, *open = a.ID != *current, a.ID, false
}
}).Height(280).MinHeight(0).AutoFocus()
}).Height(280).MinHeight(0))
restore()
internal.Ring(list, core.Tokens(c).Focus, theme.ControlRadius)
if list.Changed() && !b.IsDisabled() {
@@ -129,7 +130,7 @@ func accountSwitcherLarge(c *ui.Context, b *ui.Element, open *bool, current *str
}
// accountTrigger displays an avatar, name and detail.
func accountTrigger(c *ui.Context, name, detail string, avatar *ui.Bitmap, disabled bool) *ui.Element {
func accountTrigger(c *ui.Context, name, detail string, avatar *ui.Bitmap, disabled bool) ui.Element {
k := core.Tokens(c)
d := core.Density(c)
b := ui.ButtonBase(c).Role(ui.RoleMenuButton).MinHeight(d.ControlHeight()+d.Unit()*2).Padding(d.Unit(), d.Unit()*3, d.Unit(), d.Unit()*2).
+3 -3
View File
@@ -57,7 +57,7 @@ type ApiKeyManagerOptions struct {
// ApiKeyManagerResult reports creation and revocation requests.
type ApiKeyManagerResult struct {
Element *ui.Element
Element ui.Element
create, revoke string
}
@@ -102,7 +102,7 @@ func ApiKeyManager(c *ui.Context, s *ApiKeyManagerState, keys []APIKey, opts Api
}
accountRows(c, len(keys), func(i int) any { return keys[i].ID }, func(i int) {
key := keys[i]
ui.Row(c).Key(key.ID).MinHeight(d.ControlHeight()+d.Unit()*4).Gap(d.Unit()*3).AlignItems(ui.Center).
ui.Row(c.Key(key.ID)).MinHeight(d.ControlHeight()+d.Unit()*4).Gap(d.Unit()*3).AlignItems(ui.Center).
BorderWidth(0, 0, theme.BorderWidth, 0).BorderColor(k.Border).Children(func() {
ui.Column(c).Grow(1).MinWidth(0).Gap(2).Children(func() {
ui.Text(c, key.Name).FontWeight(600).SingleLine()
@@ -191,7 +191,7 @@ func apiKeyCreateDialog(c *ui.Context, s *ApiKeyManagerState, disabled bool) (st
}
res := input.TextInput(c, &s.name, input.TextInputOptions{Label: core.Msg(c, "api_key_manager.name"), Placeholder: core.Msg(c, "api_key_manager.name"),
Disabled: s.pending, Error: s.err})
res.Input.AutoFocus()
core.AutoFocus(c, res.Input)
if res.Submitted() && strings.TrimSpace(s.name) != "" && !s.pending {
asked = true
}
+4 -4
View File
@@ -14,13 +14,13 @@ import (
// CoachmarkStep uses an anchor built in the current frame.
type CoachmarkStep struct {
Anchor *ui.Element
Anchor ui.Element
Title, Body string
}
// CoachmarkResult reports tour completion or dismissal.
type CoachmarkResult struct {
Element *ui.Element
Element ui.Element
finished, dismissed bool
}
@@ -40,7 +40,7 @@ func Coachmark(c *ui.Context, open *bool, step *int, steps []CoachmarkStep) Coac
return r
}
cur := steps[*step]
if cur.Anchor == nil || cur.Title == "" {
if !cur.Anchor.Valid() || cur.Title == "" {
panic("mujica: CoachmarkStep needs an Anchor and a Title")
}
if cur.Anchor.IsDisabled() {
@@ -76,7 +76,7 @@ func Coachmark(c *ui.Context, open *bool, step *int, steps []CoachmarkStep) Coac
if last {
next = core.Msg(c, "coachmark.done")
}
if input.Button(c, next, input.ButtonOptions{}).AutoFocus().Clicked() {
if core.AutoFocus(c, input.Button(c, next, input.ButtonOptions{})).Clicked() {
if last {
*open, r.finished = false, true
} else {
+1 -1
View File
@@ -9,7 +9,7 @@ import (
)
func coachmarkView(c *ui.Context, open *bool, step *int, r *CoachmarkResult) {
var a, b *ui.Element
var a, b ui.Element
ui.Row(c).Gap(40).Padding(20).Children(func() {
a = input.Button(c, "Compose", input.ButtonOptions{})
b = input.Button(c, "Archive", input.ButtonOptions{Variant: input.Secondary})
+1 -1
View File
@@ -19,7 +19,7 @@ func ExampleSettingsLayout() {
core.Use(c, core.Settings{})
account.SettingsLayout(c, &page, pages, account.SettingsLayoutOptions{}, func(id string) {
account.SettingsSection(c, "Notifications", func() {
account.SettingsRow(c, "Sound", account.SettingsRowOptions{ID: "sound"}, func() *ui.Element {
account.SettingsRow(c, "Sound", account.SettingsRowOptions{ID: "sound"}, func() ui.Element {
return input.Switch(c, &sound, "", input.SwitchOptions{})
})
})
+2 -2
View File
@@ -53,7 +53,7 @@ type FeedbackWidgetOptions struct {
// FeedbackWidgetResult carries the submitted feedback.
type FeedbackWidgetResult struct {
Element *ui.Element
Element ui.Element
feedback Feedback
submitted bool
}
@@ -106,7 +106,7 @@ func FeedbackWidget(c *ui.Context, s *FeedbackWidgetState, opts FeedbackWidgetOp
return fmt.Sprintf(core.Msg(c, "feedback_widget.short"), minLen)
}
return ""
}}, func() *ui.Element {
}}, func() ui.Element {
return input.TextArea(c, &s.Draft.Text, input.TextAreaOptions{MinHeight: 96, MaxLength: 2000, Disabled: locked}).Input
})
if opts.Attachments != nil {
+3 -3
View File
@@ -35,7 +35,7 @@ type shortcutsListState struct {
}
// KeyboardShortcutsList displays searchable, grouped shortcuts using visible rows.
func KeyboardShortcutsList(c *ui.Context, query *string, groups []ShortcutGroup, opts KeyboardShortcutsListOptions) *ui.Element {
func KeyboardShortcutsList(c *ui.Context, query *string, groups []ShortcutGroup, opts KeyboardShortcutsListOptions) ui.Element {
k := core.Tokens(c)
d := core.Density(c)
label := opts.Label
@@ -96,11 +96,11 @@ func shortcutsListPlan(st *shortcutsListState, groups []ShortcutGroup, q string)
}
}
func accountRows(c *ui.Context, n int, key func(int) any, row func(int)) *ui.Element {
func accountRows(c *ui.Context, n int, key func(int) any, row func(int)) ui.Element {
if n <= 8 {
return ui.Column(c).Children(func() {
for i := range n {
ui.Column(c).Key(key(i)).Children(func() { row(i) })
ui.Column(c.Key(key(i))).Children(func() { row(i) })
}
})
}
+3 -3
View File
@@ -40,7 +40,7 @@ type LoginFormOptions struct {
}
// LoginForm collects credentials; it never checks or stores them.
func LoginForm(c *ui.Context, s *LoginFormState, opts LoginFormOptions) *ui.Element {
func LoginForm(c *ui.Context, s *LoginFormState, opts LoginFormOptions) ui.Element {
if opts.OnSubmit == nil {
panic("mujica: LoginForm needs OnSubmit")
}
@@ -61,11 +61,11 @@ func LoginForm(c *ui.Context, s *LoginFormState, opts LoginFormOptions) *ui.Elem
submit := false
var acc, pw input.InputResult
e.Children(func() {
input.FormField(c, accountLabel, input.FormFieldOptions{Required: true}, func() *ui.Element {
input.FormField(c, accountLabel, input.FormFieldOptions{Required: true}, func() ui.Element {
acc = input.TextInput(c, &s.Account, input.TextInputOptions{Disabled: disabled || s.submitting, Error: missing(s.Account)})
return acc.Input
})
input.FormField(c, core.Msg(c, "login_form.password"), input.FormFieldOptions{Required: true}, func() *ui.Element {
input.FormField(c, core.Msg(c, "login_form.password"), input.FormFieldOptions{Required: true}, func() ui.Element {
pw = input.PasswordInput(c, &s.password, input.PasswordInputOptions{Disabled: disabled || s.submitting, Error: missing(s.password)})
return pw.Input
})
+2 -2
View File
@@ -25,7 +25,7 @@ type OAuthButtonsOptions struct {
// OAuthButtonsResult carries the selected provider.
type OAuthButtonsResult struct {
Element *ui.Element
Element ui.Element
chosen string
}
@@ -47,7 +47,7 @@ func OAuthButtons(c *ui.Context, providers []OAuthProvider, opts OAuthButtonsOpt
panic("mujica: OAuthProvider needs an ID and a Name")
}
label := fmt.Sprintf(core.Msg(c, "oauth_buttons.continue"), p.Name)
ui.Column(c).Key(p.ID).AlignItems(ui.Stretch).Children(func() {
ui.Column(c.Key(p.ID)).AlignItems(ui.Stretch).Children(func() {
b := input.Button(c, label, input.ButtonOptions{Variant: input.Secondary, Icon: p.Icon, Loading: opts.Pending == p.ID,
Disabled: opts.Pending != "" && opts.Pending != p.ID})
if b.Clicked() && !disabled && opts.Pending == "" {
+3 -3
View File
@@ -28,7 +28,7 @@ type OnboardingWizardOptions struct {
// OnboardingWizardResult reports completion or skipping.
type OnboardingWizardResult struct {
Element *ui.Element
Element ui.Element
finished, skipped bool
}
@@ -60,7 +60,7 @@ func OnboardingWizard(c *ui.Context, step *int, steps []WizardStep, opts Onboard
at := *step
navigation.Steps(c, &at, head, navigation.StepsOptions{Label: core.Msg(c, "onboarding_wizard.progress")})
cur := steps[*step]
ui.Column(c).Key(*step).Gap(d.Unit() * 3).Children(func() {
ui.Column(c.Key(*step)).Gap(d.Unit() * 3).Children(func() {
ui.Text(c, fmt.Sprintf(core.Msg(c, "onboarding_wizard.count"), *step+1, len(steps))).TextColor(k.TextMuted).FontSize(core.FontSize(c, theme.CaptionSize))
ui.Text(c, cur.Title).Font(theme.SerifFont).FontSize(core.FontSize(c, theme.H2Size)).FontWeight(600)
if cur.Description != "" {
@@ -84,7 +84,7 @@ func OnboardingWizard(c *ui.Context, step *int, steps []WizardStep, opts Onboard
if last {
next = core.Msg(c, "onboarding_wizard.finish")
}
if input.Button(c, next, input.ButtonOptions{Disabled: !ready}).AutoFocus().Clicked() && ready {
if core.AutoFocus(c, input.Button(c, next, input.ButtonOptions{Disabled: !ready})).Clicked() && ready {
if last {
r.finished = true
} else {
+3 -3
View File
@@ -34,7 +34,7 @@ type ProfileEditorOptions struct {
// ProfileEditorResult reports save, avatar and discard requests.
type ProfileEditorResult struct {
Element *ui.Element
Element ui.Element
save, avatar, reset bool
}
@@ -73,10 +73,10 @@ func ProfileEditor(c *ui.Context, p *Profile, opts ProfileEditorOptions) Profile
r.avatar = true
}
})
input.FormField(c, core.Msg(c, "profile_editor.name"), input.FormFieldOptions{Required: true}, func() *ui.Element {
input.FormField(c, core.Msg(c, "profile_editor.name"), input.FormFieldOptions{Required: true}, func() ui.Element {
return input.TextInput(c, &p.Name, input.TextInputOptions{Disabled: locked, Error: nameErr}).Input
})
input.FormField(c, core.Msg(c, "profile_editor.bio"), input.FormFieldOptions{}, func() *ui.Element {
input.FormField(c, core.Msg(c, "profile_editor.bio"), input.FormFieldOptions{}, func() ui.Element {
return input.TextArea(c, &p.Bio, input.TextAreaOptions{MaxLength: limit, Disabled: locked}).Input
})
ui.Row(c).Gap(d.Unit() * 3).AlignItems(ui.Center).Children(func() {
+2 -2
View File
@@ -30,7 +30,7 @@ type SessionListOptions struct {
// SessionListResult reports individual and bulk sign-out requests.
type SessionListResult struct {
Element *ui.Element
Element ui.Element
revoke string
others bool
}
@@ -74,7 +74,7 @@ func SessionList(c *ui.Context, sessions []Session, opts SessionListOptions) Ses
ui.Column(c).Role(ui.RoleList).Label(core.Msg(c, "session_list.label")).Children(func() {
accountRows(c, len(sessions), func(i int) any { return sessions[i].ID }, func(i int) {
s := sessions[i]
ui.Row(c).Key(s.ID).MinHeight(d.ControlHeight()+d.Unit()*4).Gap(d.Unit()*3).AlignItems(ui.Center).
ui.Row(c.Key(s.ID)).MinHeight(d.ControlHeight()+d.Unit()*4).Gap(d.Unit()*3).AlignItems(ui.Center).
BorderWidth(0, 0, theme.BorderWidth, 0).BorderColor(k.Border).Role(ui.RoleListItem).Children(func() {
ui.Column(c).Grow(1).MinWidth(0).Gap(2).Children(func() {
ui.Row(c).Gap(d.Unit() * 2).AlignItems(ui.Center).Children(func() {
+5 -5
View File
@@ -58,14 +58,14 @@ func SettingsLayout(c *ui.Context, page *string, pages []SettingsPage, opts Sett
slog.Debug("mujica: settings_layout page", "page", *page)
}
ui.Scroll(c).Grow(1).MinWidth(0).Padding(d.Unit()*6, d.Unit()*8).Children(func() {
ui.Column(c).Key(*page).MaxWidth(720).Gap(d.Unit() * 8).Children(func() { content(*page) })
ui.Column(c.Key(*page)).MaxWidth(720).Gap(d.Unit() * 8).Children(func() { content(*page) })
})
})
return r
}
// SettingsSection groups rows under a serif heading.
func SettingsSection(c *ui.Context, title string, rows func()) *ui.Element {
func SettingsSection(c *ui.Context, title string, rows func()) ui.Element {
k := core.Tokens(c)
d := core.Density(c)
e := ui.Column(c).Gap(d.Unit() * 2).Role(ui.RoleGroup).Label(title)
@@ -94,7 +94,7 @@ func settingsReveal(c *ui.Context, id string) {
type settingsRowState struct{ at time.Time }
// SettingsRow associates a label and description with its control.
func SettingsRow(c *ui.Context, label string, opts SettingsRowOptions, control func() *ui.Element) *ui.Element {
func SettingsRow(c *ui.Context, label string, opts SettingsRowOptions, control func() ui.Element) ui.Element {
if label == "" || control == nil {
panic("mujica: SettingsRow needs a label and a control")
}
@@ -106,7 +106,7 @@ func SettingsRow(c *ui.Context, label string, opts SettingsRowOptions, control f
}
st := ui.Local(row, "reveal", func() settingsRowState { return settingsRowState{} })
reveal := ui.Local(c.Root(), settingsRevealKey{}, func() string { return "" })
var ctrl, text *ui.Element
var ctrl, text ui.Element
row.Children(func() {
text = ui.Column(c).Grow(1).MinWidth(0).Gap(d.Unit())
text.Children(func() {
@@ -117,7 +117,7 @@ func SettingsRow(c *ui.Context, label string, opts SettingsRowOptions, control f
})
ui.Row(c).Shrink(0).Children(func() { ctrl = control() })
})
if ctrl == nil {
if !ctrl.Valid() {
panic("mujica: SettingsRow " + label + ": control returned nil")
}
ctrl.Label(label).Description(opts.Description)
+2 -2
View File
@@ -24,13 +24,13 @@ func settingsView(c *ui.Context, page *string, sound, track *bool, changes *int)
switch id {
case "general":
SettingsSection(c, "Notifications", func() {
SettingsRow(c, "Sound", SettingsRowOptions{ID: "sound", Description: "Chime on new messages."}, func() *ui.Element {
SettingsRow(c, "Sound", SettingsRowOptions{ID: "sound", Description: "Chime on new messages."}, func() ui.Element {
return input.Switch(c, sound, "", input.SwitchOptions{})
})
})
case "privacy":
SettingsSection(c, "Data", func() {
SettingsRow(c, "Usage reports", SettingsRowOptions{ID: "track"}, func() *ui.Element {
SettingsRow(c, "Usage reports", SettingsRowOptions{ID: "track"}, func() ui.Element {
return input.Switch(c, track, "", input.SwitchOptions{})
})
})
+2 -2
View File
@@ -32,7 +32,7 @@ type SettingsSearchOptions struct {
// SettingsSearchResult carries the selected destination.
type SettingsSearchResult struct {
Element *ui.Element
Element ui.Element
chosen *SettingEntry
}
@@ -135,7 +135,7 @@ func settingsSearchPlan(st *settingsSearchState, entries []SettingEntry, q strin
func settingsSearchHit(c *ui.Context, e SettingEntry, q string, current bool) bool {
k := core.Tokens(c)
d := core.Density(c)
b := ui.ButtonBase(c).Key(e.ID).MinHeight(d.ControlHeight()).Padding(d.Unit(), d.Unit()*3).Justify(ui.Start).
b := ui.ButtonBase(c.Key(e.ID)).MinHeight(d.ControlHeight()).Padding(d.Unit(), d.Unit()*3).Justify(ui.Start).
Radius(theme.ControlRadius).Role(ui.RoleListItem).Label(e.Label).Description(e.Description).Selected(current).Gap(d.Unit() * 2)
internal.Ring(b, k.Focus, theme.ControlRadius)
switch {
+2 -2
View File
@@ -145,7 +145,7 @@ func ShortcutRecorder(c *ui.Context, value *Shortcut, opts ShortcutRecorderOptio
}
if st.recording {
b.HandleInput(func(ev ui.InputEvent) bool {
if b.IsDisabled() {
if disabled {
return false
}
return shortcutRecorderKey(st, ev)
@@ -178,7 +178,7 @@ func shortcutRecorderKey(st *shortcutRecorderState, ev ui.InputEvent) bool {
}
// shortcutRecorderLook displays the shortcut or recording prompt.
func shortcutRecorderLook(c *ui.Context, b *ui.Element, st *shortcutRecorderState, value Shortcut, name string) {
func shortcutRecorderLook(c *ui.Context, b ui.Element, st *shortcutRecorderState, value Shortcut, name string) {
k := core.Tokens(c)
internal.Ring(b, k.Focus, theme.ControlRadius)
label := name + ": " + value.String()
+1 -1
View File
@@ -25,7 +25,7 @@ type TwoFactorInputOptions struct {
// TwoFactorResult reports completion and resend events.
type TwoFactorResult struct {
Element *ui.Element
Element ui.Element
completed, resend bool
}
+1 -1
View File
@@ -37,7 +37,7 @@ func TestTwoFactorInputPasteCompleteAndResend(t *testing.T) {
if resent != 1 {
t.Fatal("resend not reported")
}
opts.ResendAt = time.Now().Add(65 * time.Second)
opts.ResendAt = tt.Now().Add(65 * time.Second)
opts.Error = "That code has expired."
tt.Frame()
if !tt.HasText("Resend in 1:05") && !tt.HasText("Resend in 1:04") || !tt.HasText("That code has expired.") {
+2 -2
View File
@@ -29,7 +29,7 @@ type UsageQuotaOptions struct {
}
// UsageQuota displays usage bars and reset time.
func UsageQuota(c *ui.Context, items []QuotaItem, opts UsageQuotaOptions) *ui.Element {
func UsageQuota(c *ui.Context, items []QuotaItem, opts UsageQuotaOptions) ui.Element {
warn := opts.Warn
if warn == 0 {
warn = 0.8
@@ -54,7 +54,7 @@ func UsageQuota(c *ui.Context, items []QuotaItem, opts UsageQuotaOptions) *ui.El
col, icon, note = k.Warning, "triangle-alert", core.Msg(c, "usage_quota.near")
}
amount := fmt.Sprintf(core.Msg(c, "usage_quota.amount"), data.StatisticFormat(it.Used, 0), data.StatisticFormat(it.Limit, 0), it.Unit)
ui.Column(c).Key(i).Gap(d.Unit()).Role(ui.RoleMeter).Label(it.Label).
ui.Column(c.Key(i)).Gap(d.Unit()).Role(ui.RoleMeter).Label(it.Label).
Description(fmt.Sprintf("%s, %s%% %s", amount, data.StatisticFormat(share*100, 0), note)).Children(func() {
ui.Row(c).Gap(d.Unit() * 2).AlignItems(ui.Center).Children(func() {
ui.Text(c, it.Label).FontWeight(500).Grow(1)
+1 -1
View File
@@ -32,7 +32,7 @@ type UserMenuOptions struct {
// UserMenuResult reports presence, settings and sign-out events.
type UserMenuResult struct {
Element *ui.Element
Element ui.Element
changed, settings, leave bool
}
+1 -1
View File
@@ -46,7 +46,7 @@ func TestUserMenuSnapshot(t *testing.T) {
ui.Row(c).Padding(20).Gap(16).Children(func() {
for s := UserStatusOnline; s <= UserStatusInvisible; s++ {
st := s
ui.Box(c).Key(int(s)).Children(func() { UserMenu(c, &st, UserMenuOptions{Name: "Sakiko Togawa"}) })
ui.Box(c.Key(int(s))).Children(func() { UserMenu(c, &st, UserMenuOptions{Name: "Sakiko Togawa"}) })
}
})
})
+2 -2
View File
@@ -70,7 +70,7 @@ func WhatsNewDialog(c *ui.Context, open *bool, hide *bool, releases []Release, o
r.Element = overlay.Dialog(c, open, overlay.DialogOptions{Title: title, Width: 480, Decorated: true, Actions: func() {
input.Checkbox(c, hide, core.Msg(c, "whats_new_dialog.hide"), input.CheckboxOptions{})
ui.Box(c).Grow(1)
if input.Button(c, core.Msg(c, "whats_new_dialog.close"), input.ButtonOptions{}).AutoFocus().Clicked() {
if core.AutoFocus(c, input.Button(c, core.Msg(c, "whats_new_dialog.close"), input.ButtonOptions{})).Clicked() {
*open = false
}
}}, func() {
@@ -78,7 +78,7 @@ func WhatsNewDialog(c *ui.Context, open *bool, hide *bool, releases []Release, o
if rel.Version == "" {
panic("mujica: Release needs a Version")
}
ui.Column(c).Key(i).Gap(d.Unit() * 2).Role(ui.RoleGroup).Label(rel.Version).Children(func() {
ui.Column(c.Key(i)).Gap(d.Unit() * 2).Role(ui.RoleGroup).Label(rel.Version).Children(func() {
ui.Row(c).Gap(d.Unit() * 2).AlignItems(ui.End).Children(func() {
ui.Text(c, rel.Version).Font(theme.SerifFont).FontSize(core.FontSize(c, theme.H3Size)).FontWeight(600)
if rel.Date != "" {
+3 -3
View File
@@ -72,7 +72,7 @@ func WorkspaceSwitcher(c *ui.Context, current *string, spaces []Workspace, opts
overlay.Popover(c, b, &st.open, overlay.PopoverOptions{Width: 300, Label: core.Msg(c, "workspace_switcher.label")}, func() {
res := input.SearchInput(c, &st.query, input.SearchInputOptions{Placeholder: core.Msg(c, "workspace_switcher.search"), Label: core.Msg(c, "workspace_switcher.search")})
in := res.Input
in.AutoFocus()
core.AutoFocus(c, in)
q := strings.ToLower(strings.TrimSpace(st.query))
if !st.ready || st.filtered != q || !slices.Equal(st.source, spaces) {
st.source, st.filtered, st.ready = slices.Clone(spaces), q, true
@@ -115,10 +115,10 @@ func WorkspaceSwitcher(c *ui.Context, current *string, spaces []Workspace, opts
}
// workspaceRow displays a clickable workspace with a selection mark.
func workspaceRow(c *ui.Context, w Workspace, current, cursor bool) *ui.Element {
func workspaceRow(c *ui.Context, w Workspace, current, cursor bool) ui.Element {
k := core.Tokens(c)
d := core.Density(c)
b := ui.ButtonBase(c).Key(w.ID).MinHeight(d.ControlHeight()).Padding(d.Unit(), d.Unit()*2).Gap(d.Unit() * 2).
b := ui.ButtonBase(c.Key(w.ID)).MinHeight(d.ControlHeight()).Padding(d.Unit(), d.Unit()*2).Gap(d.Unit() * 2).
Justify(ui.Start).Radius(theme.ControlRadius).Role(ui.RoleListItem).Label(w.Name).Selected(current)
internal.Ring(b, k.Focus, theme.ControlRadius)
switch {