94 lines
2.0 KiB
Go
94 lines
2.0 KiB
Go
package main
|
|
|
|
import (
|
|
log "go.wit.com/log"
|
|
"go.wit.com/toolkits/tree"
|
|
"go.wit.com/widget"
|
|
)
|
|
|
|
var fakeStartWidth int = me.FakeW
|
|
var fakeStartHeight int = me.TabH + me.FramePadH
|
|
|
|
// setup fake labels for non-visible things off screen
|
|
func setFake(n *tree.Node) {
|
|
var w *guiWidget
|
|
w = n.TK.(*guiWidget)
|
|
w.isFake = true
|
|
|
|
w.gocuiSetWH(fakeStartWidth, fakeStartHeight)
|
|
|
|
fakeStartHeight += w.gocuiSize.Height()
|
|
// TODO: use the actual max hight of the terminal window
|
|
if fakeStartHeight > 24 {
|
|
fakeStartHeight = me.TabH
|
|
fakeStartWidth += me.FakeW
|
|
}
|
|
}
|
|
|
|
// set the widget start width & height
|
|
// func (n *node) addWidget(n *tree.Node) {
|
|
func addWidget(n *tree.Node) {
|
|
var nw *guiWidget
|
|
nw = n.TK.(*guiWidget)
|
|
log.Log(INFO, "setStartWH() w.id =", n.WidgetId, "n.name", n.String())
|
|
switch n.WidgetType {
|
|
case widget.Root:
|
|
log.Log(INFO, "setStartWH() rootNode w.id =", n.WidgetId, "w.name", n.String())
|
|
nw.color = &colorRoot
|
|
setFake(n)
|
|
return
|
|
case widget.Flag:
|
|
nw.color = &colorFlag
|
|
setFake(n)
|
|
return
|
|
case widget.Window:
|
|
nw.frame = false
|
|
nw.color = &colorWindow
|
|
wRoot := me.treeRoot.TK.(*guiWidget)
|
|
wRoot.redoWindows(0, 0)
|
|
// TODO: record the first window here?
|
|
// do initial setup of helper widgets here:
|
|
if me.dropdownV == nil {
|
|
me.dropdownV = makeDropdownView("addWidget() ddview")
|
|
}
|
|
return
|
|
case widget.Tab:
|
|
nw.color = &colorTab
|
|
// redoWindows(0,0)
|
|
return
|
|
case widget.Button:
|
|
nw.color = &colorButton
|
|
case widget.Checkbox:
|
|
nw.color = &colorCheckbox
|
|
case widget.Dropdown:
|
|
nw.color = &colorDropdown
|
|
case widget.Combobox:
|
|
nw.color = &colorCombobox
|
|
case widget.Box:
|
|
nw.color = &colorBox
|
|
nw.isFake = true
|
|
setFake(n)
|
|
return
|
|
case widget.Grid:
|
|
nw.color = &colorGrid
|
|
nw.isFake = true
|
|
setFake(n)
|
|
return
|
|
case widget.Group:
|
|
nw.color = &colorGroup
|
|
nw.frame = false
|
|
return
|
|
case widget.Label:
|
|
nw.color = &colorLabel
|
|
nw.frame = false
|
|
return
|
|
default:
|
|
/*
|
|
if n.IsCurrent() {
|
|
n.updateCurrent()
|
|
}
|
|
*/
|
|
}
|
|
nw.showWidgetPlacement("addWidget()")
|
|
}
|