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>
28 lines
669 B
Go
28 lines
669 B
Go
package files
|
||
|
||
import (
|
||
"fmt"
|
||
|
||
"github.com/egoist/mygo/ui"
|
||
|
||
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
||
)
|
||
|
||
type FileIconOptions struct {
|
||
// Scale is 1–4; zero means 1.
|
||
Scale int
|
||
}
|
||
|
||
// FileIcon draws a kind: a folder or a dog-eared page.
|
||
func FileIcon(c *ui.Context, kind Kind, o FileIconOptions) ui.Element {
|
||
k := pixel.K(c)
|
||
ka := look(kind)
|
||
s := pixel.Or("FileIcon Scale", o.Scale, 1)
|
||
if s > 4 {
|
||
panic(fmt.Sprintf("files: FileIcon Scale %d is past 4", s))
|
||
}
|
||
return ui.Box(c).Size(k.D(12*s), k.D(12*s)).Role(ui.RoleImage).Label(k.Msg(ka.msg)).Draw(func(p *ui.Painter, r ui.Rect) {
|
||
k.Canvas(p, r).Sprite(0, 0, ka.art, 0, pixel.Ink, s)
|
||
})
|
||
}
|