Add code components 366-385; ScrollArea Follow, editor sync
A terminal with history, a Go-colored code block, a log viewer that follows, a hex viewer, a memory map, a JSON tree, a line diff, a GAME OVER crash screen, an FPS meter, profiler bars, breakpoints, variables, command history, a shortcut list, a debug grid, a pixel editor that exports string art, a palette editor, a sprite sheet, a glyph map and a 6502 register view. layout.ScrollArea takes Follow, and ChatLog now uses it. data.TreeNode takes a Value drawn in its Slot. pixel gains Has, and Sprite.Art writes MustSprite art. pixel.Editor takes the caller's value at each input event, so a value changed between frames is never typed onto.
This commit is contained in:
42 files changed
+3415
-37
No files matched your search
+15
-3
@@ -3,6 +3,7 @@ package data
|
||||
import (
|
||||
"log/slog"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/egoist/mygo/ui"
|
||||
|
||||
@@ -10,7 +11,10 @@ import (
|
||||
)
|
||||
|
||||
type TreeNode struct {
|
||||
Label string
|
||||
Label string
|
||||
// Value follows the label in Slot, as a key's value.
|
||||
Value string
|
||||
Slot pixel.Slot
|
||||
Children []TreeNode
|
||||
}
|
||||
|
||||
@@ -102,7 +106,7 @@ func Tree(c *ui.Context, text string, roots []TreeNode, selected *string, o Tree
|
||||
}
|
||||
*selected = rows[at].key
|
||||
res.Changed = *selected != old
|
||||
base.Description(nodes[*selected].Label)
|
||||
base.Description(strings.TrimSpace(nodes[*selected].Label + " " + nodes[*selected].Value))
|
||||
shown := rows
|
||||
shell.Size(k.D(pixel.Or("Tree Width", o.Width, 160)), k.D(len(shown)*pixel.LineHeight)).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
g := k.Canvas(p, r)
|
||||
@@ -119,7 +123,15 @@ func Tree(c *ui.Context, text string, roots []TreeNode, selected *string, o Tree
|
||||
g.Sprite(x+4, y+5, pointer, 0, ink, 1)
|
||||
}
|
||||
}
|
||||
g.Text(x+12, y, nodes[rw.key].Label, ink, 1)
|
||||
n := nodes[rw.key]
|
||||
g.Text(x+12, y, n.Label, ink, 1)
|
||||
// On the chosen row the value takes its ink.
|
||||
if vs := n.Slot; n.Value != "" {
|
||||
if i == at {
|
||||
vs = ink
|
||||
}
|
||||
g.Text(x+18+pixel.Measure(n.Label), y, n.Value, vs, 1)
|
||||
}
|
||||
}
|
||||
g.Finish(st)
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user