2023-02-25 14:05:25 -06:00
|
|
|
package gui
|
|
|
|
|
2023-03-12 08:47:16 -05:00
|
|
|
import (
|
|
|
|
"git.wit.org/wit/gui/toolkit"
|
|
|
|
)
|
|
|
|
|
|
|
|
// 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() {
|
|
|
|
Config.Title = "go.wit.org/gui debug window"
|
|
|
|
Config.Width = 300
|
|
|
|
Config.Height = 200
|
|
|
|
bugWin = NewWindow()
|
2023-03-01 11:35:36 -06:00
|
|
|
bugWin.Custom = bugWin.StandardClose
|
2023-02-25 14:05:25 -06:00
|
|
|
bugWin.DebugTab("Debug Tab")
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
newN.Dump()
|
|
|
|
|
|
|
|
//////////////////////// 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
|
|
|
|
log(debugGui, "Custom() n.widget =", cb.widget.Name, cb.widget.B)
|
|
|
|
}
|
|
|
|
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-03-12 08:47:16 -05:00
|
|
|
newN.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-03-12 08:47:16 -05:00
|
|
|
newN.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-03-12 08:47:16 -05:00
|
|
|
newN.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-12 08:47:16 -05:00
|
|
|
g2 := newN.NewGroup("node things")
|
2023-02-25 14:05:25 -06:00
|
|
|
|
2023-03-12 08:47:16 -05:00
|
|
|
g2.NewButton("Node.ListChildren(false)", func () {
|
|
|
|
g := debugGui
|
|
|
|
d := debugDump
|
2023-02-25 14:05:25 -06:00
|
|
|
debugGui = true
|
|
|
|
debugDump = true
|
2023-03-12 08:47:16 -05:00
|
|
|
activeWidget.ListChildren(false, nil, nil)
|
|
|
|
debugGui = g
|
|
|
|
debugDump = d
|
2023-02-25 14:05:25 -06:00
|
|
|
})
|
2023-03-12 08:47:16 -05:00
|
|
|
g2.NewButton("Node.ListChildren(true)", func () {
|
|
|
|
g := debugGui
|
|
|
|
d := debugDump
|
2023-02-25 14:05:25 -06:00
|
|
|
debugGui = true
|
|
|
|
debugDump = true
|
2023-03-12 08:47:16 -05:00
|
|
|
activeWidget.ListChildren(true, nil, nil)
|
|
|
|
debugGui = g
|
|
|
|
debugDump = d
|
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() {
|
|
|
|
name := dd.widget.S
|
|
|
|
activeWidget = mapWindows[name]
|
|
|
|
setActiveWidget(activeWidget)
|
|
|
|
log("The Window was set to", name)
|
|
|
|
}
|
|
|
|
log(debugGui, "dd =", dd)
|
|
|
|
|
|
|
|
// var last = ""
|
|
|
|
for _, child := range Config.master.children {
|
|
|
|
log(debugGui, "\t\t", child.id, child.Width, child.Height, child.Name)
|
|
|
|
// skip the fake "Flag" node
|
|
|
|
if (child.widget.Type == toolkit.Flag) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
|
|
|
|
activeWidget.ListChildren(true, dd, mapWindows)
|
|
|
|
}
|