summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toolkit/gocui/add.go8
-rw-r--r--toolkit/gocui/click.go29
-rw-r--r--toolkit/gocui/structs.go1
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