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.4 KiB
Go
52 lines
1.4 KiB
Go
package feedback
|
|
|
|
import (
|
|
"github.com/egoist/mygo/ui"
|
|
|
|
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/display"
|
|
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/input"
|
|
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
|
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/text"
|
|
)
|
|
|
|
var openChest = pixel.MustSprite(`
|
|
..eeeeeeeeeeee..
|
|
.esssssssssssse.
|
|
.elllllllllllle.
|
|
..eeeeeeeeeeee..
|
|
................
|
|
eeeeeeeeeeeeeeee
|
|
ewwwwwwwwwwwwwwe
|
|
ewwwwwwwwwwwwwwe
|
|
eeeeeeeyyeeeeeee
|
|
essssssyysssssse
|
|
esssssssssssssse
|
|
eeeeeeeeeeeeeeee
|
|
`)
|
|
|
|
type EmptyStateOptions struct {
|
|
// Action labels a button; Acted reports it.
|
|
Action string
|
|
Disabled bool
|
|
}
|
|
|
|
type EmptyStateResult struct {
|
|
Element ui.Element
|
|
Acted bool
|
|
}
|
|
|
|
// EmptyState shows NO ITEMS over an empty chest.
|
|
func EmptyState(c *ui.Context, message string, o EmptyStateOptions) EmptyStateResult {
|
|
k := pixel.K(c)
|
|
res := EmptyStateResult{}
|
|
res.Element = ui.Column(c).Gap(k.D(6)).Padding(k.D(12)).AlignItems(ui.Center).Role(ui.RoleStatus).Label(k.Msg("empty")).Children(func() {
|
|
display.Sprite(c, openChest, display.SpriteOptions{Scale: 2})
|
|
text.ShadowText(c, k.Msg("empty"), text.ShadowTextOptions{Slot: pixel.Faint, Scale: 2})
|
|
pixel.Text(c, message, pixel.TextOptions{Slot: pixel.Faint})
|
|
if o.Action != "" {
|
|
res.Acted = input.Button(c, o.Action, input.ButtonOptions{Variant: input.Primary, Disabled: o.Disabled}).Clicked
|
|
}
|
|
})
|
|
return res
|
|
}
|