From 2e2e68ce070a987304d3f8e4bae832b2672f7875 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 28 Jan 2024 14:03:06 -0600 Subject: [PATCH] trying to fix windows Signed-off-by: Jeff Carr --- click.go | 17 ++++++++++++----- debug.go | 6 +++--- gocui.go | 6 +++--- keybindings.go | 9 ++++++++- place.go | 4 +++- view.go | 2 +- 6 files changed, 30 insertions(+), 14 deletions(-) diff --git a/click.go b/click.go index 874f8ce..c3814e4 100644 --- a/click.go +++ b/click.go @@ -119,8 +119,10 @@ func (w *guiWidget) doWidgetClick() { w.setColor(&colorActiveW) if w.active { w.active = false - w.placeWidgets(me.RawW, me.RawH) + w.dumpTree("before") + w.placeWidgets(3, 2) w.showWidgets() + w.dumpTree("after") } else { w.active = true w.hideWidgets() @@ -165,22 +167,27 @@ func (w *guiWidget) doWidgetClick() { w.showWidgets() case widget.Group: // n.placeWidgets(p.tk.startH, newH) + w.dumpTree("click start") if w.active { w.active = false - startW := me.RawW - startH := me.RawH + startW := w.parent.AtW + startH := w.parent.AtH + w.placeWidgets(startW, startH) + w.showWidgets() + /* for _, child := range w.children { log.Log(INFO, "START W,H", startW, startH) - child.placeWidgets(me.RawW, me.RawH) + child.placeWidgets(startW, startH) child.showWidgets() } + */ } else { w.active = true for _, child := range w.children { child.hideWidgets() } } - w.dumpTree() + w.dumpTree("click end") case widget.Checkbox: if widget.GetBool(w.value) { w.setCheckbox(false) diff --git a/debug.go b/debug.go index 04f2a90..9419a9d 100644 --- a/debug.go +++ b/debug.go @@ -7,16 +7,16 @@ import ( "go.wit.com/widget" ) -func (w *guiWidget) dumpTree() { +func (w *guiWidget) dumpTree(s string) { // log.Log(ERROR, "dumpTree w", w.node.WidgetId, w.WidgetType, w.String()) if w == nil { log.Log(ERROR, "dumpTree w.TK == nil", w.node.WidgetId, w.WidgetType, w.String()) return } - w.showWidgetPlacement("dumpTree()") + w.showWidgetPlacement("dumpTree() " + s) for _, child := range w.children { - child.dumpTree() + child.dumpTree(s) } } diff --git a/gocui.go b/gocui.go index 482cfc4..dec6d20 100644 --- a/gocui.go +++ b/gocui.go @@ -50,7 +50,7 @@ func gocuiMain() { func gocuiEvent(g *gocui.Gui) error { maxX, maxY := g.Size() mx, my := g.MousePosition() - log.Log(NOW, "handleEvent() START", maxX, maxY, mx, my, msgMouseDown) + log.Verbose("handleEvent() START", maxX, maxY, mx, my, msgMouseDown) if _, err := g.View("msg"); msgMouseDown && err == nil { moveMsg(g) } @@ -61,10 +61,10 @@ func gocuiEvent(g *gocui.Gui) error { // setOutput(me.logStdout) } } else { - log.Log(INFO, "output widget already exists", maxX, maxY, mx, my) + log.Verbose("output widget already exists", maxX, maxY, mx, my) } mouseMove(g) - log.Log(INFO, "handleEvent() END ", maxX, maxY, mx, my, msgMouseDown) + log.Verbose("handleEvent() END ", maxX, maxY, mx, my, msgMouseDown) return nil } diff --git a/keybindings.go b/keybindings.go index 902eed8..d570367 100644 --- a/keybindings.go +++ b/keybindings.go @@ -119,7 +119,14 @@ func addDebugKeys(g *gocui.Gui) { g.SetKeybinding("", 'M', gocui.ModNone, func(g *gocui.Gui, v *gocui.View) error { w := me.treeRoot.TK.(*guiWidget) - w.dumpTree() + w.dumpTree("M") + return nil + }) + + // redo windows + g.SetKeybinding("", 'w', gocui.ModNone, + func(g *gocui.Gui, v *gocui.View) error { + redoWindows(0, 0) return nil }) diff --git a/place.go b/place.go index f826472..53a0995 100644 --- a/place.go +++ b/place.go @@ -65,7 +65,7 @@ func (tk *guiWidget) placeWidgets(startW int, startH int) { case widget.Group: // move the group to the parent's next location tk.gocuiSetWH(startW, startH) - tk.showWidgetPlacement("group()") + tk.dumpTree("start place") newW := startW + me.GroupPadW newH := startH + 3 // normal hight of the group label @@ -78,7 +78,9 @@ func (tk *guiWidget) placeWidgets(startW int, startH int) { // increment straight down newH += h + log.Log(INFO, "REAL HIGHT ADDED", h, "newH", newH) } + tk.dumpTree("end place") default: tk.gocuiSetWH(startW, startH) // n.moveTo(startW, startH) diff --git a/view.go b/view.go index 157640a..5da6701 100644 --- a/view.go +++ b/view.go @@ -174,7 +174,7 @@ func (w *guiWidget) recreateView() { } if w.String() == "CLOUDFLARE_EMAIL" { w.showWidgetPlacement("w.String()="+w.String()+" w.label="+w.labelN+" "+w.cuiName) - w.dumpTree() + w.dumpTree("cloudflare") } log.Log(ERROR, "recreateView() END") }