From e750b068316661f1320af47b18517c837bca8e76 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 26 Apr 2023 12:38:39 -0500 Subject: [PATCH] gocui: closer to correct tabs Signed-off-by: Jeff Carr --- cmds/buttonplugin/main.go | 2 +- toolkit/gocui/add.go | 6 +++--- toolkit/gocui/checkbox.go | 2 +- toolkit/gocui/click.go | 6 ++++-- toolkit/gocui/plugin.go | 4 ++-- toolkit/gocui/structs.go | 2 +- toolkit/gocui/tab.go | 8 ++++---- toolkit/gocui/view.go | 3 ++- 8 files changed, 18 insertions(+), 15 deletions(-) diff --git a/cmds/buttonplugin/main.go b/cmds/buttonplugin/main.go index d206591..7ced40b 100644 --- a/cmds/buttonplugin/main.go +++ b/cmds/buttonplugin/main.go @@ -35,7 +35,7 @@ func buttonWindow() { log.Println("buttonWindow() START") w = myGui.NewWindow(title).SetText("Nueva Ventana de Botones") - t = w.NewTab("buttonTab") + t = w.NewTab("buttonTab is this thing") g = t.NewGroup("buttonGroup") g1 := t.NewGroup("buttonGroup 2") more = g1.NewGroup("more") diff --git a/toolkit/gocui/add.go b/toolkit/gocui/add.go index 1282081..6efbbc2 100644 --- a/toolkit/gocui/add.go +++ b/toolkit/gocui/add.go @@ -28,7 +28,7 @@ func (w *cuiWidget) setFake() { fakeStartWidth += me.DevelOffsetW } if (logInfo) { - w.drawView() + w.showView() } } @@ -45,11 +45,11 @@ func (w *cuiWidget) addWidget() { return case toolkit.Window: w.setTabWH() - w.drawView() + w.showView() return case toolkit.Tab: w.setTabWH() - w.drawView() + w.showView() return case toolkit.Box: w.isFake = true diff --git a/toolkit/gocui/checkbox.go b/toolkit/gocui/checkbox.go index 4a0808a..5568ee3 100644 --- a/toolkit/gocui/checkbox.go +++ b/toolkit/gocui/checkbox.go @@ -28,5 +28,5 @@ func (w *cuiWidget) setCheckbox(b bool) { } w.deleteView() - w.drawView() + w.showView() } diff --git a/toolkit/gocui/click.go b/toolkit/gocui/click.go index 214ef0b..e03a0e9 100644 --- a/toolkit/gocui/click.go +++ b/toolkit/gocui/click.go @@ -50,6 +50,8 @@ func (w *cuiWidget) doWidgetClick() { w.showWidgets() // THIS IS THE BEGINING OF THE LAYOUT case toolkit.Tab: + UnsetCurrent(me.rootNode) + me.rootNode.hideWidgets() w.isCurrent = true w.parent.isCurrent = true @@ -120,7 +122,7 @@ func (w *cuiWidget) drawTree(draw bool) { w.showWidgetPlacement(logNow, "drawTree()") if (draw) { // w.textResize() - w.drawView() + w.showView() } else { w.deleteView() } @@ -219,7 +221,7 @@ func ctrlDown(g *gocui.Gui, v *gocui.View) error { if (me.ctrlDown.v == nil) { me.ctrlDown.text = found.text me.ctrlDown.showWidgetPlacement(logNow, "ctrlDown:") - me.ctrlDown.drawView() + me.ctrlDown.showView() } else { me.ctrlDown.deleteView() } diff --git a/toolkit/gocui/plugin.go b/toolkit/gocui/plugin.go index f70ae96..f204e09 100644 --- a/toolkit/gocui/plugin.go +++ b/toolkit/gocui/plugin.go @@ -27,7 +27,7 @@ func action(a *toolkit.Action) { } case toolkit.Show: if (a.B) { - w.drawView() + w.showView() } else { w.hideWidgets() } @@ -71,7 +71,7 @@ func (w *cuiWidget) SetText(text string) { w.s = text w.textResize() w.deleteView() - w.drawView() + w.showView() } func (w *cuiWidget) Set(val any) { diff --git a/toolkit/gocui/structs.go b/toolkit/gocui/structs.go index 7972cfd..f7f8c15 100644 --- a/toolkit/gocui/structs.go +++ b/toolkit/gocui/structs.go @@ -58,7 +58,7 @@ type config struct { WindowW int `default:"8" dense:"0"` WindowH int `default:"-1"` TabW int `default:"2" dense:"0"` - TabH int `default:"2" dense:"0"` + TabH int `default:"1" dense:"0"` // additional amount of space to indent on a group GroupPadW int `default:"6" dense:"2"` diff --git a/toolkit/gocui/tab.go b/toolkit/gocui/tab.go index 32f3fce..ae38b17 100644 --- a/toolkit/gocui/tab.go +++ b/toolkit/gocui/tab.go @@ -37,7 +37,7 @@ func (w *cuiWidget) showFake() { if (w.isFake) { w.setFake() w.showWidgetPlacement(logNow, "showFake:") - w.drawView() + w.showView() } for _, child := range w.children { child.showFake() @@ -50,7 +50,7 @@ func (w *cuiWidget) showWidgets() { } else { if w.IsCurrent() { w.showWidgetPlacement(logNow, "current:") - w.drawView() + w.showView() } else { w.showWidgetPlacement(logNow, "not:") // w.drawView() @@ -121,12 +121,12 @@ func (w *cuiWidget) redoTabs(draw bool) { } w.setWindowWH() w.deleteView() - w.drawView() + w.showView() } if (w.widgetType == toolkit.Tab) { w.setTabWH() w.deleteView() - w.drawView() + w.showView() } for _, child := range w.children { diff --git a/toolkit/gocui/view.go b/toolkit/gocui/view.go index d830c98..b47c075 100644 --- a/toolkit/gocui/view.go +++ b/toolkit/gocui/view.go @@ -35,7 +35,8 @@ func (w *cuiWidget) textResize() { w.showWidgetPlacement(logNow, "textResize()") } -func (w *cuiWidget) drawView() { +// display's the text of the widget in gocui +func (w *cuiWidget) showView() { var err error if (w.cuiName == "") { log(logError, "drawView() w.cuiName was not set for widget", w)