Add data components 151-175; clear MyGo row highlights
Lists, tables, trees, grids, inventories and records in data/. Outline and GridView build on ui.List: ui.Outline strokes its arrows and ui.GridView spaces and tints items. The pixel theme keeps MyGo's row highlights clear so scrolled rows stay on whole dots; off lists take a veil against the wheel. Adds Canvas.Silhouette, SwitchOptions Label and exports Rarity.Slot.
This commit is contained in:
47 files changed
+3379
-17
No files matched your search
@@ -0,0 +1,42 @@
|
||||
package data
|
||||
|
||||
import (
|
||||
"github.com/egoist/mygo/ui"
|
||||
|
||||
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
||||
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/text"
|
||||
)
|
||||
|
||||
// Activity is one entry of a feed.
|
||||
type Activity struct {
|
||||
Icon *pixel.Sprite
|
||||
Text, Time string
|
||||
}
|
||||
|
||||
type FeedOptions struct{}
|
||||
|
||||
// Feed lists activity: icon, text and time, dotted apart.
|
||||
func Feed(c *ui.Context, entries []Activity, o FeedOptions) *ui.Element {
|
||||
k := pixel.K(c)
|
||||
return ui.Column(c).FillWidth().Children(func() {
|
||||
for i, a := range entries {
|
||||
last := i == len(entries)-1
|
||||
ui.Row(c).FillWidth().Gap(k.D(6)).Padding(k.D(4), 0).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
if !last {
|
||||
g := k.Canvas(p, r)
|
||||
g.Checker(0, g.H-1, g.W, 1, pixel.Edge)
|
||||
}
|
||||
}).Children(func() {
|
||||
ui.Box(c).Size(k.D(12), k.D(12)).Shrink(0).Role(ui.RoleNone).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
if a.Icon != nil {
|
||||
k.Canvas(p, r).Sprite(0, 0, a.Icon, 0, pixel.Accent, 1)
|
||||
}
|
||||
})
|
||||
ui.Column(c).Grow(1).Children(func() {
|
||||
text.Paragraph(c, a.Text, text.ParagraphOptions{})
|
||||
pixel.Text(c, a.Time, pixel.TextOptions{Slot: pixel.Faint})
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user