2023-02-25 14:05:25 -06:00
|
|
|
package gui
|
|
|
|
|
2023-03-12 08:47:16 -05:00
|
|
|
import (
|
2023-03-23 12:35:12 -05:00
|
|
|
// "git.wit.org/wit/gui/toolkit"
|
2023-03-12 08:47:16 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// TODO: move all this shit into somewhere not global
|
|
|
|
|
|
|
|
// main debugging window
|
2023-02-25 14:05:25 -06:00
|
|
|
var bugWin *Node
|
2023-03-12 08:47:16 -05:00
|
|
|
// if there should be new windows or just tabs
|
|
|
|
var makeTabs bool = true
|
|
|
|
|
2023-02-25 14:05:25 -06:00
|
|
|
var mapWindows map[string]*Node
|
2023-03-12 08:47:16 -05:00
|
|
|
var checkd, checkdn, checkdt, checkdtk, lb1, lb2 *Node
|
|
|
|
var myButton *Node
|
2023-02-25 14:05:25 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
Creates a window helpful for debugging this package
|
|
|
|
*/
|
|
|
|
func DebugWindow() {
|
2023-04-08 15:34:36 -05:00
|
|
|
bugWin = Config.rootNode.NewWindow("go.wit.org/gui debug window").DebugTab("Debug Tab")
|
2023-03-01 11:35:36 -06:00
|
|
|
bugWin.Custom = bugWin.StandardClose
|
2023-04-08 15:34:36 -05:00
|
|
|
// bugWin.DebugTab("Debug Tab")
|
2023-02-25 14:05:25 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func (n *Node) DebugTab(title string) *Node {
|
2023-03-12 08:47:16 -05:00
|
|
|
var newN, gog, g1 *Node
|
2023-02-25 14:05:25 -06:00
|
|
|
|
|
|
|
// time.Sleep(1 * time.Second)
|
|
|
|
newN = n.NewTab(title)
|
|
|
|
|
|
|
|
//////////////////////// main debug things //////////////////////////////////
|
2023-03-12 08:47:16 -05:00
|
|
|
gog = newN.NewGroup("Debugging Windows:")
|
|
|
|
|
|
|
|
// generally useful debugging
|
|
|
|
cb := gog.NewCheckbox("Seperate windows")
|
|
|
|
cb.Custom = func() {
|
|
|
|
makeTabs = cb.widget.B
|
2023-04-03 10:26:47 -05:00
|
|
|
log(debugGui, "Custom() n.widget =", cb.Name, cb.widget.B)
|
2023-03-12 08:47:16 -05:00
|
|
|
}
|
|
|
|
makeTabs = false
|
|
|
|
cb.Set(false)
|
2023-03-03 14:41:38 -06:00
|
|
|
|
2023-03-01 11:35:36 -06:00
|
|
|
gog.NewButton("Debug Flags", func () {
|
2023-04-06 14:16:59 -05:00
|
|
|
bugWin.DebugFlags(makeTabs)
|
2023-03-01 11:35:36 -06:00
|
|
|
})
|
|
|
|
gog.NewButton("Debug Widgets", func () {
|
2023-03-12 08:47:16 -05:00
|
|
|
DebugWidgetWindow(newN)
|
2023-02-25 14:05:25 -06:00
|
|
|
})
|
2023-03-03 14:41:38 -06:00
|
|
|
gog.NewButton("GO Language Internals", func () {
|
2023-04-06 14:16:59 -05:00
|
|
|
bugWin.DebugGolangWindow(makeTabs)
|
2023-02-25 14:05:25 -06:00
|
|
|
})
|
2023-03-03 14:41:38 -06:00
|
|
|
gog.NewButton("GO Channels debug", func () {
|
2023-04-06 14:16:59 -05:00
|
|
|
bugWin.DebugGoChannels(makeTabs)
|
2023-03-01 11:35:36 -06:00
|
|
|
})
|
|
|
|
|
2023-03-12 08:47:16 -05:00
|
|
|
gog.NewLabel("Force Quit:")
|
2023-02-25 14:05:25 -06:00
|
|
|
|
2023-03-12 08:47:16 -05:00
|
|
|
gog.NewButton("os.Exit()", func () {
|
|
|
|
exit()
|
|
|
|
})
|
2023-02-25 14:05:25 -06:00
|
|
|
|
2023-03-12 08:47:16 -05:00
|
|
|
//////////////////////// window debugging things //////////////////////////////////
|
|
|
|
g1 = newN.NewGroup("list things")
|
2023-02-25 14:05:25 -06:00
|
|
|
|
2023-03-12 08:47:16 -05:00
|
|
|
g1.NewButton("List Windows", func () {
|
|
|
|
dropdownWindow(g1)
|
2023-02-25 14:05:25 -06:00
|
|
|
})
|
2023-03-12 08:47:16 -05:00
|
|
|
g1.NewButton("List Window Widgets", func () {
|
|
|
|
dropdownWindowWidgets(g1)
|
2023-03-01 11:35:36 -06:00
|
|
|
})
|
2023-02-25 14:05:25 -06:00
|
|
|
|
2023-03-29 23:03:04 -05:00
|
|
|
g2 := newN.NewGroup("more things")
|
2023-02-25 14:05:25 -06:00
|
|
|
|
2023-03-12 08:47:16 -05:00
|
|
|
g2.NewButton("Node.ListChildren(true)", func () {
|
2023-03-23 12:35:12 -05:00
|
|
|
if (activeWidget == nil) {
|
2023-03-29 23:03:04 -05:00
|
|
|
activeWidget = Config.rootNode
|
2023-03-23 12:35:12 -05:00
|
|
|
}
|
|
|
|
activeWidget.ListChildren(true)
|
2023-02-25 14:05:25 -06:00
|
|
|
})
|
|
|
|
|
2023-03-29 23:03:04 -05:00
|
|
|
g2.NewButton("test conc", func () {
|
|
|
|
makeConc()
|
|
|
|
})
|
|
|
|
|
|
|
|
g2.NewButton("List Plugins", func () {
|
|
|
|
for _, aplug := range allPlugins {
|
|
|
|
log("Loaded plugin:", aplug.name, aplug.filename)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2023-04-12 13:00:29 -05:00
|
|
|
g2.NewButton("load toolkit 'gocui'", func () {
|
|
|
|
Config.rootNode.LoadToolkit("gocui")
|
2023-03-29 23:03:04 -05:00
|
|
|
})
|
|
|
|
|
2023-02-25 14:05:25 -06:00
|
|
|
return newN
|
|
|
|
}
|
2023-03-12 08:47:16 -05:00
|
|
|
|
|
|
|
func dropdownWindow(p *Node) {
|
|
|
|
var mapWindows map[string]*Node
|
|
|
|
mapWindows = make(map[string]*Node)
|
|
|
|
|
|
|
|
dd := p.NewDropdown("Window Dropdown")
|
|
|
|
dd.Custom = func() {
|
2023-04-06 20:25:14 -05:00
|
|
|
name := dd.S
|
2023-03-12 08:47:16 -05:00
|
|
|
activeWidget = mapWindows[name]
|
|
|
|
setActiveWidget(activeWidget)
|
2023-04-06 20:25:14 -05:00
|
|
|
log(true, "The Window was set to", name)
|
2023-03-12 08:47:16 -05:00
|
|
|
}
|
|
|
|
log(debugGui, "dd =", dd)
|
2023-03-23 12:35:12 -05:00
|
|
|
if (activeWidget == nil) {
|
|
|
|
// the debug window doesn't exist yet so you can't display the change
|
|
|
|
// TODO: make a fake binary tree for this(?)
|
|
|
|
return
|
|
|
|
}
|
2023-03-12 08:47:16 -05:00
|
|
|
|
|
|
|
// var last = ""
|
2023-03-29 23:03:04 -05:00
|
|
|
for _, child := range Config.rootNode.children {
|
2023-03-12 08:47:16 -05:00
|
|
|
log(debugGui, "\t\t", child.id, child.Width, child.Height, child.Name)
|
|
|
|
dd.AddDropdownName(child.Name)
|
|
|
|
// last = child.Name
|
|
|
|
mapWindows[child.Name] = child
|
|
|
|
if (activeWidget == nil) {
|
|
|
|
activeWidget = child
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// dd.SetDropdownName(last)
|
|
|
|
}
|
|
|
|
|
|
|
|
func dropdownWindowWidgets(p *Node) {
|
|
|
|
var mapWindows map[string]*Node
|
|
|
|
mapWindows = make(map[string]*Node)
|
|
|
|
|
|
|
|
dd := p.NewDropdown("Window Widgets Dropdown")
|
|
|
|
dd.Custom = func() {
|
|
|
|
name := dd.widget.S
|
|
|
|
activeWidget = mapWindows[name]
|
|
|
|
setActiveWidget(activeWidget)
|
|
|
|
}
|
|
|
|
log(debugGui, "dd =", dd)
|
|
|
|
|
2023-03-23 12:35:12 -05:00
|
|
|
// log("dumpWidget() ", b, listChildrenDepth, defaultPadding, n.id, info)
|
|
|
|
|
|
|
|
var addDropdowns func (*Node)
|
|
|
|
addDropdowns = func (n *Node) {
|
|
|
|
s := n.dumpWidget(true)
|
|
|
|
dd.AddDropdownName(s)
|
|
|
|
mapWindows[s] = n
|
|
|
|
|
|
|
|
for _, child := range n.children {
|
|
|
|
listChildrenDepth += 1
|
|
|
|
addDropdowns(child)
|
|
|
|
listChildrenDepth -= 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// list everything in the binary tree
|
2023-03-29 23:03:04 -05:00
|
|
|
addDropdowns(Config.rootNode)
|
2023-03-12 08:47:16 -05:00
|
|
|
}
|