gocli: close to working tabs

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2023-04-26 12:18:08 -05:00
parent 064f3ca748
commit 051ad00de3
2 changed files with 26 additions and 6 deletions

View File

@ -46,7 +46,6 @@ func (w *cuiWidget) addWidget() {
case toolkit.Window: case toolkit.Window:
w.setTabWH() w.setTabWH()
w.drawView() w.drawView()
// w.frame = false
return return
case toolkit.Tab: case toolkit.Tab:
w.setTabWH() w.setTabWH()

View File

@ -10,6 +10,15 @@ import (
"git.wit.org/wit/gui/toolkit" "git.wit.org/wit/gui/toolkit"
) )
// set isCurrent = false everywhere
func UnsetCurrent(w *cuiWidget) {
w.isCurrent = false
for _, child := range w.children {
UnsetCurrent(child)
}
}
func (w *cuiWidget) doWidgetClick() { func (w *cuiWidget) doWidgetClick() {
switch w.widgetType { switch w.widgetType {
case toolkit.Root: case toolkit.Root:
@ -18,20 +27,32 @@ func (w *cuiWidget) doWidgetClick() {
me.rootNode.nextH = 0 me.rootNode.nextH = 0
me.rootNode.redoTabs(true) me.rootNode.redoTabs(true)
case toolkit.Flag: case toolkit.Flag:
me.rootNode.redoColor(true) // me.rootNode.redoColor(true)
me.rootNode.dumpTree(true)
case toolkit.Window: case toolkit.Window:
UnsetCurrent(me.rootNode)
me.rootNode.hideWidgets() me.rootNode.hideWidgets()
me.rootNode.nextW = 0
me.rootNode.nextH = 0
me.rootNode.redoTabs(true)
w.isCurrent = true
if w.hasTabs { if w.hasTabs {
// w.isCurrent = false // set isCurrent = true on the first tab
w.isCurrent = true for _, child := range w.children {
} else { child.isCurrent = true
w.isCurrent = true break
}
} }
w.placeWidgets() w.placeWidgets()
w.showWidgets() w.showWidgets()
// THIS IS THE BEGINING OF THE LAYOUT
case toolkit.Tab: case toolkit.Tab:
me.rootNode.hideWidgets() me.rootNode.hideWidgets()
w.isCurrent = true w.isCurrent = true
w.parent.isCurrent = true
w.placeWidgets() w.placeWidgets()
w.showWidgets() w.showWidgets()
case toolkit.Group: case toolkit.Group: