Files
ZacharyZhang-NYandClaude Opus 5.5 03e1f91706 Upgrade MyGo to v0.5.5
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>
2026-10-17 01:31:08 -04:00

48 lines
1.4 KiB
Go

package overlay
import (
"fmt"
"log/slog"
"github.com/egoist/mygo/ui"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/input"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/text"
)
type CoachmarkOptions struct {
Disabled bool
}
type CoachmarkResult struct {
Element ui.Element
Next bool
}
// coachWidth is the bubble's text width in dots.
const coachWidth = 140
// Coachmark points a bubble at target: step count, NEXT ▶.
func Coachmark(c *ui.Context, target ui.Element, message string, step, steps int, o CoachmarkOptions) CoachmarkResult {
k := pixel.K(c)
if step < 1 || step > steps {
panic(fmt.Sprintf("overlay: Coachmark step %d of %d", step, steps))
}
var res CoachmarkResult
res.Element = bubble(c, target.Bounds(), func() {
ui.Column(c).Width(k.D(coachWidth)).Gap(k.D(4)).Role(ui.RoleGroup).Label(message).Children(func() {
text.Paragraph(c, message, text.ParagraphOptions{})
ui.Row(c).AlignItems(ui.Center).Children(func() {
text.MicroText(c, fmt.Sprintf("%d/%d", step, steps), text.MicroTextOptions{Slot: pixel.Faint})
ui.Box(c).Grow(1)
res.Next = input.Button(c, k.Msg("next_step"), input.ButtonOptions{Size: input.Small, Variant: input.Primary, Disabled: o.Disabled}).Clicked
})
})
}, coachWidth+16)
if res.Next {
slog.Debug("8bit: coachmark next", "step", step, "steps", steps)
}
return res
}