gocui: simple grid working

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2023-04-03 17:49:37 -05:00
parent b0ae0810c4
commit 40ad372361
3 changed files with 27 additions and 24 deletions

View File

@ -63,7 +63,9 @@ func buttonWindow() {
g1.NewButton("hello2", func () {
log.Println("world2")
})
more2 = g1.NewGroup("more2")
more2 = g1.NewGrid("gridnuts", 3, 3)
more2.NewLabel("more2")
g.NewButton("this app is useful for plugin debuggin", func () {
})

View File

@ -23,9 +23,9 @@ func (w *cuiWidget) doWidgetClick() {
case toolkit.Tab:
w.redoBox(true)
w.toggleTree()
// w.toggleTree()
// me.rootNode.redoColor(true)
case toolkit.Grid:
w.redoBox(true)
w.toggleTree()
case toolkit.Box:
// w.showWidgetPlacement(logNow, "drawTree()")
if (w.horizontal) {
@ -125,8 +125,8 @@ func ctrlDown(g *gocui.Gui, v *gocui.View) error {
// find buttons that are below where the mouse button click
f = func(widget *cuiWidget) {
// if ((widget.logicalSize.w0 < w) && (w < widget.logicalSize.w1)) {
if ((widget.realSize.w0 < w) && (w < widget.realSize.w1) &&
(widget.realSize.h0 < h) && (h < widget.realSize.h1)) {
if ((widget.realSize.w0 <= w) && (w <= widget.realSize.w1) &&
(widget.realSize.h0 <= h) && (h <= widget.realSize.h1)) {
widgets = append(widgets, widget)
found = widget
}
@ -137,8 +137,8 @@ func ctrlDown(g *gocui.Gui, v *gocui.View) error {
}
f(me.rootNode)
var t string
for i, widget := range widgets {
log(logNow, "ctrlDown() FOUND widget", i, widget.name)
for _, widget := range widgets {
log(logNow, "ctrlDown() FOUND widget", widget.id, widget.name)
t += widget.cuiName + " " + widget.name + "\n"
// widget.showWidgetPlacement(logNow, "drawTree()")
}

View File

@ -73,30 +73,31 @@ func (w *cuiWidget) redoBox(draw bool) {
child.redoBox(draw)
}
case toolkit.Grid:
log("redoBox GRID", p.nextW, p.nextH, p.name)
log("redoBox GRID", p.nextW, p.nextH, p.name)
log("redoBox GRID", w.nextW, w.nextH, w.name, w.text)
// hmm
w.logicalSize.w0 = p.nextW
w.logicalSize.h0 = p.nextH
w.logicalSize.w1 = p.nextW
w.logicalSize.h1 = p.nextH
w.nextW = p.nextW
w.nextH = p.nextH
var wCount, hCount int
var b bool = true
var wCount int = 0
var hCount int = 0
for _, child := range w.children {
child.redoBox(draw)
if (b) {
wCount += 1
b = false
} else {
wCount = 0
w.nextH += 1
b = true
}
// increment for the next child
w.nextW = p.nextW + wCount * 20
w.nextH = p.nextH + hCount * 4
log(logInfo, "redoBox(GRID) (w,h count)", wCount, hCount, "(X,Y)", w.x, w.y, w.name)
child.redoBox(draw)
log(logNow, "redoBox(GRID) (w,h count)", wCount, hCount, "(X,Y)", w.x, w.y, w.name)
child.showWidgetPlacement(logNow, "grid:")
if ((wCount + 1) < w.y) {
wCount += 1
} else {
wCount = 0
hCount += 1
}
}
w.showWidgetPlacement(logNow, "grid:")
case toolkit.Box: