Add feedback components 106-130; inert scope, focus return, two-step deploy
This commit is contained in:
87 files changed
+2492
-147
No files matched your search
+1
-1
@@ -120,7 +120,7 @@ type AvatarGroupOptions struct {
|
||||
// AvatarGroup overlaps faces and counts the rest in a chip.
|
||||
func AvatarGroup(c *ui.Context, names []string, o AvatarGroupOptions) *ui.Element {
|
||||
k, sc := pixel.K(c), scale(o.Scale)
|
||||
shown := names[:min(len(names), orDef("AvatarGroup Max", o.Max, 4))]
|
||||
shown := names[:min(len(names), pixel.Or("AvatarGroup Max", o.Max, 4))]
|
||||
rest := len(names) - len(shown)
|
||||
more := ""
|
||||
if rest > 0 {
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ func Bubble(c *ui.Context, o BubbleOptions, children func()) *ui.Element {
|
||||
panic(fmt.Sprintf("display: unknown Side %d", o.Tail))
|
||||
}
|
||||
k := pixel.K(c)
|
||||
at := orDef("Bubble At", o.At, 8)
|
||||
at := pixel.Or("Bubble At", o.At, 8)
|
||||
pad := [4]int{6, 8, 6, 8}
|
||||
pad[[...]int{Bottom: 2, Top: 0, Left: 3, Right: 1}[o.Tail]] += tailLen
|
||||
return ui.Column(c).Padding(k.D(pad[0]), k.D(pad[1]), k.D(pad[2]), k.D(pad[3])).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
|
||||
+1
-12
@@ -23,20 +23,9 @@ func art(c *ui.Context, k pixel.Kit, label string, w, h int, fn func(g pixel.Can
|
||||
return e
|
||||
}
|
||||
|
||||
// orDef is v, or def for zero; negative panics.
|
||||
func orDef(name string, v, def int) int {
|
||||
if v < 0 {
|
||||
panic(fmt.Sprintf("display: %s %d is negative", name, v))
|
||||
}
|
||||
if v == 0 {
|
||||
return def
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// scale is s, or 1 for zero; outside 1–4 panics.
|
||||
func scale(s int) int {
|
||||
s = orDef("Scale", s, 1)
|
||||
s = pixel.Or("Scale", s, 1)
|
||||
if s > 4 {
|
||||
panic(fmt.Sprintf("display: Scale %d outside 1–4", s))
|
||||
}
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ type pictureCache struct {
|
||||
func Picture(c *ui.Context, img image.Image, o PictureOptions) *ui.Element {
|
||||
k := pixel.K(c)
|
||||
b := img.Bounds()
|
||||
w, h := orDef("Picture W", o.W, b.Dx()), orDef("Picture H", o.H, b.Dy())
|
||||
w, h := pixel.Or("Picture W", o.W, b.Dx()), pixel.Or("Picture H", o.H, b.Dy())
|
||||
e := art(c, k, o.Label, w, h, nil)
|
||||
pc := ui.Local(e, pictureKey{}, func() pictureCache { return pictureCache{} })
|
||||
if sum := fingerprint(img); pc.dots == nil || pc.sum != sum || pc.pal != k.Palette() || pc.w != w || pc.h != h {
|
||||
|
||||
@@ -16,7 +16,7 @@ type PlaceholderOptions struct {
|
||||
// Placeholder is a dithered box with a cross and size.
|
||||
func Placeholder(c *ui.Context, o PlaceholderOptions) *ui.Element {
|
||||
k := pixel.K(c)
|
||||
w, h := orDef("Placeholder W", o.W, 64), orDef("Placeholder H", o.H, 48)
|
||||
w, h := pixel.Or("Placeholder W", o.W, 64), pixel.Or("Placeholder H", o.H, 48)
|
||||
size := fmt.Sprintf("%d×%d", w, h)
|
||||
return art(c, k, size, w, h, func(g pixel.Canvas) {
|
||||
if w < 3 || h < 3 {
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ type PortraitOptions struct {
|
||||
// Portrait frames a character's picture over a nameplate.
|
||||
func Portrait(c *ui.Context, name string, o PortraitOptions, picture func()) *ui.Element {
|
||||
k := pixel.K(c)
|
||||
size := orDef("Portrait Size", o.Size, 48)
|
||||
size := pixel.Or("Portrait Size", o.Size, 48)
|
||||
return ui.Column(c).Width(k.D(size + 6)).Role(ui.RoleGroup).Label(name).Children(func() {
|
||||
ui.Box(c).Size(k.D(size+6), k.D(size+6)).Padding(k.D(3)).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
g := k.Canvas(p, r)
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ type qrCache struct {
|
||||
// QRCode encodes s at level M, with a quiet zone.
|
||||
func QRCode(c *ui.Context, s string, o QRCodeOptions) *ui.Element {
|
||||
k := pixel.K(c)
|
||||
sc := orDef("QRCode Scale", o.Scale, 2)
|
||||
sc := pixel.Or("QRCode Scale", o.Scale, 2)
|
||||
e := ui.Box(c)
|
||||
qc := ui.Local(e, qrKey{}, func() qrCache { return qrCache{} })
|
||||
if qc.code == nil || qc.text != s {
|
||||
|
||||
@@ -15,7 +15,7 @@ type RarityFrameOptions struct {
|
||||
func RarityFrame(c *ui.Context, r Rarity, o RarityFrameOptions, children func()) *ui.Element {
|
||||
k := pixel.K(c)
|
||||
ink := r.slot()
|
||||
pad := 3 + orDef("RarityFrame Padding", o.Padding, 4)
|
||||
pad := 3 + pixel.Or("RarityFrame Padding", o.Padding, 4)
|
||||
return ui.Column(c).Padding(k.D(pad)).Role(ui.RoleGroup).Label(r.name(k)).Draw(func(p *ui.Painter, r2 ui.Rect) {
|
||||
g := k.Canvas(p, r2)
|
||||
if g.W < 6 || g.H < 6 {
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ type SpriteOptions struct {
|
||||
// Sprite plays a multi-slot sprite, mirrored when asked.
|
||||
func Sprite(c *ui.Context, sp *pixel.Sprite, o SpriteOptions) *ui.Element {
|
||||
k, sc := pixel.K(c), scale(o.Scale)
|
||||
fps := orDef("Sprite FPS", o.FPS, 0)
|
||||
fps := pixel.Or("Sprite FPS", o.FPS, 0)
|
||||
if o.Mirror {
|
||||
sp = sp.Mirror()
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ type SwatchOptions struct {
|
||||
// Swatch shows the active palette's sixteen slots with names.
|
||||
func Swatch(c *ui.Context, o SwatchOptions) *ui.Element {
|
||||
k := pixel.K(c)
|
||||
cols := orDef("Swatch Columns", o.Columns, 4)
|
||||
cols := pixel.Or("Swatch Columns", o.Columns, 4)
|
||||
cell := 14 + pixel.Measure("AccentLit")
|
||||
return ui.Row(c).Wrap().Width(k.D(cols * (cell + 4))).Gap(k.D(4)).Role(ui.RoleList).Label(k.Palette().Name).Children(func() {
|
||||
for s := range pixel.Slot(pixel.Slots) {
|
||||
|
||||
Reference in new issue
Block a user