2024-01-17 23:54:19 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"go.wit.com/log"
|
2024-01-19 12:18:11 -06:00
|
|
|
"go.wit.com/toolkits/tree"
|
2024-01-18 04:27:19 -06:00
|
|
|
"go.wit.com/widget"
|
2024-01-17 23:54:19 -06:00
|
|
|
)
|
|
|
|
|
2024-02-05 12:06:17 -06:00
|
|
|
func add(n *tree.Node) {
|
2024-01-17 23:54:19 -06:00
|
|
|
p := n.Parent
|
|
|
|
switch n.WidgetType {
|
|
|
|
case widget.Window:
|
|
|
|
newWindow(p, n)
|
|
|
|
case widget.Group:
|
|
|
|
newGroup(p, n)
|
|
|
|
case widget.Grid:
|
|
|
|
newGrid(n)
|
|
|
|
case widget.Box:
|
|
|
|
newBox(n)
|
|
|
|
case widget.Label:
|
|
|
|
newLabel(p, n)
|
|
|
|
case widget.Button:
|
|
|
|
newButton(p, n)
|
|
|
|
case widget.Checkbox:
|
|
|
|
newCheckbox(p, n)
|
2024-02-05 12:06:17 -06:00
|
|
|
setChecked(n, n.State.Checked)
|
2024-01-17 23:54:19 -06:00
|
|
|
case widget.Spinner:
|
|
|
|
newSpinner(p, n)
|
|
|
|
case widget.Slider:
|
|
|
|
newSlider(p, n)
|
|
|
|
case widget.Dropdown:
|
|
|
|
newDropdown(p, n)
|
2024-02-05 15:04:01 -06:00
|
|
|
setText(n, n.State.DefaultS)
|
2024-01-17 23:54:19 -06:00
|
|
|
case widget.Combobox:
|
|
|
|
newCombobox(p, n)
|
2024-02-05 15:04:01 -06:00
|
|
|
setText(n, n.State.DefaultS)
|
2024-01-17 23:54:19 -06:00
|
|
|
case widget.Textbox:
|
|
|
|
newTextbox(p, n)
|
2024-02-05 15:04:01 -06:00
|
|
|
setText(n, n.State.DefaultS)
|
2024-01-17 23:54:19 -06:00
|
|
|
/*
|
|
|
|
case widget.Image:
|
|
|
|
newImage(p, n)
|
|
|
|
*/
|
|
|
|
default:
|
2024-02-05 12:06:17 -06:00
|
|
|
log.Log(ERROR, "add() error TODO: ", n.WidgetType, n.ProgName())
|
2024-01-17 23:54:19 -06:00
|
|
|
}
|
2024-02-05 12:06:17 -06:00
|
|
|
}
|
2024-01-26 11:18:01 -06:00
|
|
|
|
2024-02-05 12:06:17 -06:00
|
|
|
func newAdd(n *tree.Node) {
|
|
|
|
if n == nil {
|
|
|
|
log.Warn("Tree Error: Add() sent n == nil")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if n.WidgetType == widget.Root {
|
|
|
|
me.treeRoot = n
|
|
|
|
return
|
|
|
|
}
|
|
|
|
add(n)
|
|
|
|
if n.TK == nil {
|
|
|
|
log.Warn("Tree sent an action on a widget we didn't seem to have.")
|
|
|
|
// do this init here again? Probably something
|
|
|
|
// went wrong and we should reset the our while gocui.View tree
|
|
|
|
n.TK = initWidget(n)
|
|
|
|
}
|
|
|
|
// show(n, !a.State.Hidden)
|
|
|
|
if n.Hidden() {
|
|
|
|
hide(n)
|
|
|
|
} else {
|
|
|
|
if n.State.Enable {
|
|
|
|
// nothing to do
|
|
|
|
} else {
|
|
|
|
enable(n, false)
|
|
|
|
}
|
|
|
|
}
|
2024-01-17 23:54:19 -06:00
|
|
|
}
|