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
+8
-8
@@ -32,7 +32,7 @@ type DrawerOptions struct {
|
||||
}
|
||||
|
||||
// Drawer shows a panel along a window edge while *open is true; Escape closes it.
|
||||
func Drawer(c *ui.Context, open *bool, opts DrawerOptions, content func()) *ui.Element {
|
||||
func Drawer(c *ui.Context, open *bool, opts DrawerOptions, content func()) ui.Element {
|
||||
if opts.Title == "" {
|
||||
panic("mujica: Drawer needs a Title")
|
||||
}
|
||||
@@ -45,12 +45,12 @@ func Drawer(c *ui.Context, open *bool, opts DrawerOptions, content func()) *ui.E
|
||||
site, focus := core.OverlaySite(c)
|
||||
if !*open {
|
||||
focus.Closed(c, site)
|
||||
return nil
|
||||
return ui.Element{}
|
||||
}
|
||||
k := core.Tokens(c)
|
||||
size := drawerSize(c, opts)
|
||||
closed := false
|
||||
body := func(panel *ui.Element, p float32) {
|
||||
body := func(panel ui.Element, p float32) {
|
||||
drawerPanel(c, panel, opts.Side, size, p)
|
||||
panel.Label(opts.Title)
|
||||
closed = dialogHeader(c, opts.Title, false, true, "drawer.close")
|
||||
@@ -61,7 +61,7 @@ func Drawer(c *ui.Context, open *bool, opts DrawerOptions, content func()) *ui.E
|
||||
dialogActions(c, opts.Actions)
|
||||
}
|
||||
}
|
||||
var panel *ui.Element
|
||||
var panel ui.Element
|
||||
escaped := false
|
||||
if opts.NonModal {
|
||||
ui.Overlay(c, func() {
|
||||
@@ -74,7 +74,7 @@ func Drawer(c *ui.Context, open *bool, opts DrawerOptions, content func()) *ui.E
|
||||
} else {
|
||||
core.OverlayLayer(c, open)
|
||||
shown := true
|
||||
panel = ui.DialogBase(c, &shown, func(back, panel *ui.Element) {
|
||||
panel = ui.DialogBase(c, &shown, func(back, panel ui.Element) {
|
||||
p := core.OverlayEnter(c, panel)
|
||||
back.Background(OverlayScrim(k).Alpha(p))
|
||||
drawerBackdrop(back, opts.Side)
|
||||
@@ -107,7 +107,7 @@ func drawerSize(c *ui.Context, opts DrawerOptions) float32 {
|
||||
func drawerHorizontal(s DrawerSide) bool { return s == DrawerLeft || s == DrawerRight }
|
||||
|
||||
// drawerBackdrop lines the panel up against its edge inside a modal backdrop.
|
||||
func drawerBackdrop(back *ui.Element, s DrawerSide) {
|
||||
func drawerBackdrop(back ui.Element, s DrawerSide) {
|
||||
if drawerHorizontal(s) {
|
||||
back.Row()
|
||||
}
|
||||
@@ -118,7 +118,7 @@ func drawerBackdrop(back *ui.Element, s DrawerSide) {
|
||||
}
|
||||
|
||||
// drawerPlace puts a non-modal panel against its edge, shown by size.
|
||||
func drawerPlace(c *ui.Context, panel *ui.Element, s DrawerSide, size float32) {
|
||||
func drawerPlace(c *ui.Context, panel ui.Element, s DrawerSide, size float32) {
|
||||
w, h := c.Size()
|
||||
switch s {
|
||||
case DrawerRight:
|
||||
@@ -133,7 +133,7 @@ func drawerPlace(c *ui.Context, panel *ui.Element, s DrawerSide, size float32) {
|
||||
}
|
||||
|
||||
// drawerPanel styles the panel at entrance progress p, sliding in from its edge.
|
||||
func drawerPanel(c *ui.Context, panel *ui.Element, s DrawerSide, size, p float32) {
|
||||
func drawerPanel(c *ui.Context, panel ui.Element, s DrawerSide, size, p float32) {
|
||||
k := core.Tokens(c)
|
||||
u := core.Density(c).Unit()
|
||||
off := -(1 - p) * size
|
||||
|
||||
Reference in new issue
Block a user