2024-01-18 00:08:37 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
log "go.wit.com/log"
|
2024-01-28 02:20:31 -06:00
|
|
|
"go.wit.com/toolkits/tree"
|
2024-01-18 04:10:08 -06:00
|
|
|
"go.wit.com/widget"
|
2024-01-18 00:08:37 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
var fakeStartWidth int = me.FakeW
|
|
|
|
var fakeStartHeight int = me.TabH + me.FramePadH
|
|
|
|
|
|
|
|
// setup fake labels for non-visible things off screen
|
2024-01-28 02:20:31 -06:00
|
|
|
func setFake(n *tree.Node) {
|
|
|
|
var w *guiWidget
|
|
|
|
w = n.TK.(*guiWidget)
|
2024-01-18 00:08:37 -06:00
|
|
|
w.isFake = true
|
|
|
|
|
2024-01-28 02:20:31 -06:00
|
|
|
w.gocuiSetWH(fakeStartWidth, fakeStartHeight)
|
2024-01-18 00:08:37 -06:00
|
|
|
|
|
|
|
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
|
2024-01-28 02:20:31 -06:00
|
|
|
// 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())
|
2024-01-18 00:08:37 -06:00
|
|
|
switch n.WidgetType {
|
|
|
|
case widget.Root:
|
2024-01-28 02:20:31 -06:00
|
|
|
log.Log(INFO, "setStartWH() rootNode w.id =", n.WidgetId, "w.name", n.String())
|
2024-01-18 00:08:37 -06:00
|
|
|
nw.color = &colorRoot
|
2024-01-28 02:20:31 -06:00
|
|
|
setFake(n)
|
2024-01-18 00:08:37 -06:00
|
|
|
return
|
|
|
|
case widget.Flag:
|
|
|
|
nw.color = &colorFlag
|
2024-01-28 02:20:31 -06:00
|
|
|
setFake(n)
|
2024-01-18 00:08:37 -06:00
|
|
|
return
|
|
|
|
case widget.Window:
|
|
|
|
nw.frame = false
|
2024-02-05 04:19:32 -06:00
|
|
|
// nw.color = &colorWindow
|
|
|
|
nw.setColor(&colorWindow)
|
2024-01-29 23:01:39 -06:00
|
|
|
wRoot := me.treeRoot.TK.(*guiWidget)
|
|
|
|
wRoot.redoWindows(0, 0)
|
2024-02-01 21:47:31 -06:00
|
|
|
// TODO: record the first window here?
|
|
|
|
// do initial setup of helper widgets here:
|
2024-02-02 11:07:56 -06:00
|
|
|
if me.dropdownV == nil {
|
|
|
|
me.dropdownV = makeDropdownView("addWidget() ddview")
|
2024-02-01 21:47:31 -06:00
|
|
|
}
|
2024-01-18 00:08:37 -06:00
|
|
|
return
|
|
|
|
case widget.Tab:
|
|
|
|
nw.color = &colorTab
|
|
|
|
// redoWindows(0,0)
|
|
|
|
return
|
|
|
|
case widget.Button:
|
|
|
|
nw.color = &colorButton
|
2024-02-01 11:37:46 -06:00
|
|
|
case widget.Checkbox:
|
|
|
|
nw.color = &colorCheckbox
|
2024-02-01 18:28:59 -06:00
|
|
|
case widget.Dropdown:
|
|
|
|
nw.color = &colorDropdown
|
|
|
|
case widget.Combobox:
|
|
|
|
nw.color = &colorCombobox
|
2024-01-18 00:08:37 -06:00
|
|
|
case widget.Box:
|
|
|
|
nw.color = &colorBox
|
|
|
|
nw.isFake = true
|
2024-01-28 02:20:31 -06:00
|
|
|
setFake(n)
|
2024-01-18 00:08:37 -06:00
|
|
|
return
|
|
|
|
case widget.Grid:
|
|
|
|
nw.color = &colorGrid
|
|
|
|
nw.isFake = true
|
2024-01-28 02:20:31 -06:00
|
|
|
setFake(n)
|
2024-01-18 00:08:37 -06:00
|
|
|
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()
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
}
|
2024-01-28 13:14:43 -06:00
|
|
|
nw.showWidgetPlacement("addWidget()")
|
2024-01-18 00:08:37 -06:00
|
|
|
}
|