diff options
| author | Jeff Carr <[email protected]> | 2023-04-26 14:25:48 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2023-04-26 14:25:48 -0500 |
| commit | d4b0b8b6b6e3141114ebb448438922192c725763 (patch) | |
| tree | 7439b651b89c68ec117adaf3126e7b5bcbc677f4 /toolkit/gocui | |
| parent | 18661d38da0a56c2044b6964f2e09f8bb81d1be3 (diff) | |
gocui: code cleanups
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'toolkit/gocui')
| -rw-r--r-- | toolkit/gocui/add.go | 8 | ||||
| -rw-r--r-- | toolkit/gocui/click.go | 29 | ||||
| -rw-r--r-- | toolkit/gocui/structs.go | 1 |
3 files changed, 29 insertions, 9 deletions
diff --git a/toolkit/gocui/add.go b/toolkit/gocui/add.go index 6efbbc2..856b871 100644 --- a/toolkit/gocui/add.go +++ b/toolkit/gocui/add.go @@ -48,8 +48,12 @@ func (w *cuiWidget) addWidget() { w.showView() return case toolkit.Tab: - w.setTabWH() - w.showView() + UnsetCurrent(me.rootNode) + me.rootNode.hideWidgets() + w.isCurrent = true + w.parent.isCurrent = true + w.placeWidgets() + w.showWidgets() return case toolkit.Box: w.isFake = true 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() diff --git a/toolkit/gocui/structs.go b/toolkit/gocui/structs.go index f7f8c15..a934946 100644 --- a/toolkit/gocui/structs.go +++ b/toolkit/gocui/structs.go @@ -24,6 +24,7 @@ type config struct { baseGui *gocui.Gui // the main gocui handle rootNode *cuiWidget // the base of the binary tree. it should have id == 0 ctrlDown *cuiWidget // shown if you click the mouse when the ctrl key is pressed + current *cuiWidget // this is the current tab or window to show // this is the channel we send user events like // mouse clicks or keyboard events back to the program |
