1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
package gui
import (
// "git.wit.org/wit/gui/toolkit"
)
// TODO: move all this shit into somewhere not global
// main debugging window
var bugWin *Node
// if there should be new windows or just tabs
var makeTabs bool = true
var mapWindows map[string]*Node
var checkd, checkdn, checkdt, checkdtk, lb1, lb2 *Node
var myButton *Node
/*
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()
bugWin.Custom = bugWin.StandardClose
bugWin.DebugTab("Debug Tab")
}
func (n *Node) DebugTab(title string) *Node {
var newN, gog, g1 *Node
// time.Sleep(1 * time.Second)
newN = n.NewTab(title)
//////////////////////// main debug things //////////////////////////////////
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)
gog.NewButton("Debug Flags", func () {
newN.DebugFlags(makeTabs)
})
gog.NewButton("Debug Widgets", func () {
DebugWidgetWindow(newN)
})
gog.NewButton("GO Language Internals", func () {
newN.DebugGolangWindow(makeTabs)
})
gog.NewButton("GO Channels debug", func () {
newN.DebugGoChannels(makeTabs)
})
gog.NewLabel("Force Quit:")
gog.NewButton("os.Exit()", func () {
exit()
})
//////////////////////// window debugging things //////////////////////////////////
g1 = newN.NewGroup("list things")
g1.NewButton("List Windows", func () {
dropdownWindow(g1)
})
g1.NewButton("List Window Widgets", func () {
dropdownWindowWidgets(g1)
})
g2 := newN.NewGroup("node things")
g2.NewButton("Node.ListChildren(true)", func () {
if (activeWidget == nil) {
activeWidget = Config.master
}
activeWidget.ListChildren(true)
})
return newN
}
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)
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
}
// var last = ""
for _, child := range Config.master.children {
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)
// 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
addDropdowns(Config.master)
}
|