summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2023-04-03 17:49:37 -0500
committerJeff Carr <[email protected]>2023-04-03 17:49:37 -0500
commit8982b2a8cfb10ad2ac2e50c0fcbdad88556e495a (patch)
treeeac01f4fcfeec2da568fa597e831648a78104f72
parentefe4d11576c0dbb0b1e4189274f9908c3eb7e7c3 (diff)
gocui: simple grid working
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--cmds/buttonplugin/main.go4
-rw-r--r--toolkit/gocui/click.go14
-rw-r--r--toolkit/gocui/place.go27
3 files changed, 24 insertions, 21 deletions
diff --git a/cmds/buttonplugin/main.go b/cmds/buttonplugin/main.go
index 8168c31..d1b0489 100644
--- a/cmds/buttonplugin/main.go
+++ b/cmds/buttonplugin/main.go
@@ -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 () {
})
diff --git a/toolkit/gocui/click.go b/toolkit/gocui/click.go
index e32825a..ce61bb7 100644
--- a/toolkit/gocui/click.go
+++ b/toolkit/gocui/click.go
@@ -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()")
}
diff --git a/toolkit/gocui/place.go b/toolkit/gocui/place.go
index c51d69f..d5d0f40 100644
--- a/toolkit/gocui/place.go
+++ b/toolkit/gocui/place.go
@@ -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 {
+ // increment for the next child
+ w.nextW = p.nextW + wCount * 20
+ w.nextH = p.nextH + hCount * 4
child.redoBox(draw)
- if (b) {
+
+ 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
- b = false
} else {
wCount = 0
- w.nextH += 1
- b = true
+ hCount += 1
}
- 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)
}
w.showWidgetPlacement(logNow, "grid:")
case toolkit.Box: