From d4b0b8b6b6e3141114ebb448438922192c725763 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 26 Apr 2023 14:25:48 -0500 Subject: gocui: code cleanups Signed-off-by: Jeff Carr --- toolkit/gocui/click.go | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'toolkit/gocui/click.go') diff --git a/toolkit/gocui/click.go b/toolkit/gocui/click.go index 14ae53d..d0c5d90 100644 --- a/toolkit/gocui/click.go +++ b/toolkit/gocui/click.go @@ -19,6 +19,27 @@ func UnsetCurrent(w *cuiWidget) { } } +func updateCurrentTabs() { + me.rootNode.nextW = 0 + me.rootNode.nextH = 0 + me.rootNode.redoTabs(true) +} + +// shows the widgets in a tab +func setCurrent(w *cuiWidget) { + if w.widgetType != toolkit.Tab { + return + } + me.current = w + UnsetCurrent(me.rootNode) + me.rootNode.hideWidgets() + w.isCurrent = true + w.parent.isCurrent = true + updateCurrentTabs() + w.placeWidgets() + w.showWidgets() +} + func (w *cuiWidget) doWidgetClick() { switch w.widgetType { case toolkit.Root: @@ -50,13 +71,7 @@ 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 - w.placeWidgets() - w.showWidgets() + setCurrent(w) case toolkit.Group: w.placeWidgets() w.toggleTree() -- cgit v1.2.3