diff --git a/debugGochan.go b/gochan.go similarity index 91% rename from debugGochan.go rename to gochan.go index e21dda8..3f62b24 100644 --- a/debugGochan.go +++ b/gochan.go @@ -9,18 +9,18 @@ import ( "go.wit.com/log" "go.wit.com/gui/gui" + "go.wit.com/gui/gadgets" ) var debugWG *sync.WaitGroup var debugNumberChan chan int -func DebugGoChannels(n *gui.Node) { - var w, g *gui.Node +func DebugGoChannels(p *gui.Node) *gadgets.BasicWindow { + var w *gadgets.BasicWindow + var g *gui.Node - w = n.NewWindow("Debug GO Channels") - w.Custom = w.StandardClose - - g = w.NewGroup("Channel stuff") + w = gadgets.NewBasicWindow(p, "Debug GO Channels") + g = w.Box().NewGroup("Channel stuff").Pad() // var debugWG sync.WaitGroup g.NewButton("init()", func () { @@ -63,7 +63,9 @@ func DebugGoChannels(n *gui.Node) { g.NewButton("print", func () { log.Log(true, "waitgroup counter is ?") }) + return w } + func sendNumber(i int) { log.Log(true, "START debugNumberChan <-", i, " (sending", i, "to channel)") debugNumberChan <- i diff --git a/debugGolang.go b/golang.go similarity index 93% rename from debugGolang.go rename to golang.go index 1cddf9a..a037ca2 100644 --- a/debugGolang.go +++ b/golang.go @@ -10,16 +10,15 @@ import ( "go.wit.com/log" "go.wit.com/gui/gui" + "go.wit.com/gui/gadgets" ) -func DebugGolangWindow(n *gui.Node) { - var newW, newB, g, og, outputTextbox *gui.Node +func DebugGolangWindow(p *gui.Node) *gadgets.BasicWindow { + var w *gadgets.BasicWindow + var g, og, outputTextbox *gui.Node - newW = n.NewWindow("GO") - newW.Custom = newW.StandardClose - newB = newW.NewBox("hBox", true) - - g = newB.NewGroup("Language Internals") + w = gadgets.NewBasicWindow(p, "GO") + g = w.Box().NewGroup("Language Internals").Pad() g.NewButton("ReadModuleInfo()", func () { tmp, _ := debug.ReadBuildInfo() @@ -91,7 +90,7 @@ func DebugGolangWindow(n *gui.Node) { panic("test") }) - g = newB.NewGroup("TODO: finish these") + g = w.Box().NewGroup("TODO: finish these").Pad() // g.NewLabel("TODO:") @@ -122,11 +121,13 @@ func DebugGolangWindow(n *gui.Node) { outputTextbox.SetText(dumpModuleInfo()) }) - og = newB.NewGroup("output") + og = w.Box().NewGroup("output").Pad() outputTextbox = og.NewTextbox("outputBox") outputTextbox.Custom = func () { log.Log(true, "custom TextBox() for golang output a =", outputTextbox.S) } + + return w } func runtimeReadMemStats() string { diff --git a/mainWindow.go b/main.go similarity index 78% rename from mainWindow.go rename to main.go index b40056c..bf18ed3 100644 --- a/mainWindow.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "go.wit.com/log" "go.wit.com/gui/gui" + "go.wit.com/gui/gadgets" "go.wit.com/gui/gadgets/logsettings" ) @@ -13,35 +14,40 @@ import ( */ func DebugWindow(p *gui.Node) { - myGui = p - bugWin = myGui.NewWindow("go.wit.com/gui debug window") - bugWin.StandardClose() - bugTab = DebugWindow2(bugWin, "Debug Tab") - bugTab.StandardClose() + if (me != nil) { + me.bugWin.Toggle() + return + } + me = new(debuggerSettings) + me.myGui = p + + me.bugWin = gadgets.NewBasicWindow(p,"go.wit.com/gui debug window") + + DebugWindow2(me.bugWin.Box(), "Debug Tab") // initialize the log settings window (does not display it) - myLS = logsettings.New(myGui) + + me.myLS = logsettings.New(me.myGui) if ArgDebug() { log.SetTmp() } } -func DebugWindow2(n *gui.Node, title string) *gui.Node { - var newW, newB, gr *gui.Node - // var logSettings *gadgets.LogSettings - - // time.Sleep(1 * time.Second) - newW = n.NewWindow(title) - - newB = newW.NewBox("hBox", true) +func DebugWindow2(newB *gui.Node, title string) *gui.Node { + var gr *gui.Node //////////////////////// main debug things ////////////////////////////////// gr = newB.NewGroup("Debugging Windows:") gr.NewButton("logging", func () { - myLS.Show() + me.myLS.Toggle() }) - gr.NewButton("Debug Widgets", func () { - DebugWidgetWindow(myGui) + gr.NewButton("Widgets Window", func () { + if me.widgets == nil { + me.widgets = DebugWidgetWindow(me.myGui) + me.widgets.Draw() + return + } + me.widgets.Toggle() }) gr.NewLabel("Force Quit:") @@ -98,10 +104,24 @@ func DebugWindow2(n *gui.Node, title string) *gui.Node { gr = newB.NewGroup("Learn GO") gr.NewButton("GO Language Internals", func () { - DebugGolangWindow(myGui) + if me.golang == nil { + me.golang = DebugGolangWindow(me.myGui) + me.golang.Draw() + return + } + if me.golang.Ready() { + me.golang.Toggle() + } }) gr.NewButton("GO Channels debug", func () { - DebugGoChannels(myGui) + if me.gochan == nil { + me.gochan = DebugGoChannels(me.myGui) + me.gochan.Draw() + return + } + if me.gochan.Ready() { + me.gochan.Toggle() + } }) return newB @@ -169,4 +189,5 @@ func dropdownWindowWidgets(p *gui.Node) { } func setActiveWidget(w *gui.Node) { + log.Warn("TODO: setActiveWidget()") } diff --git a/structs.go b/structs.go index 8d4e9f9..8997887 100644 --- a/structs.go +++ b/structs.go @@ -2,17 +2,35 @@ package debugger import ( "go.wit.com/gui/gui" + "go.wit.com/gui/gadgets" "go.wit.com/gui/gadgets/logsettings" ) -// main debugging window -var myGui *gui.Node +var me *debuggerSettings + +type debuggerSettings struct { + ready bool + hidden bool + err error + + myGui *gui.Node + + bugWin *gadgets.BasicWindow + widgets *gadgets.BasicWindow + golang *gadgets.BasicWindow + gochan *gadgets.BasicWindow + + myLS *logsettings.LogSettings + + mapWindows map[string]*gui.Node // tracks all windows that exist +} + var bugWin *gui.Node +/* +// main debugging window var bugTab *gui.Node - -var myLS *logsettings.LogSettings - -var mapWindows map[string]*gui.Node // tracks all windows that exist +var myGui *gui.Node +*/ // global var for checking to see if this // window/tab for debugging a widget exists diff --git a/debugWidget.go b/widget.go similarity index 92% rename from debugWidget.go rename to widget.go index c6c953c..3f459a8 100644 --- a/debugWidget.go +++ b/widget.go @@ -6,6 +6,7 @@ import ( "go.wit.com/log" "go.wit.com/gui/gui" + "go.wit.com/gui/gadgets" ) @@ -29,20 +30,11 @@ func setActiveWidget(w *gui.Node) { } */ -func DebugWidgetWindow(w *gui.Node) { - var newW, newB *gui.Node - if (bugWidget != nil) { - // this window was already created. Just change the widget we are working against - setActiveWidget(w) - return - } +func DebugWidgetWindow(p *gui.Node) *gadgets.BasicWindow { + var w *gadgets.BasicWindow + w = gadgets.NewBasicWindow(p, "Widgets") - newW = w.NewWindow("Widgets") - newW.Custom = newW.StandardClose - bugWidget = newW - newB = newW.NewBox("hBox", true) - - g := newB.NewGroup("widget:") + g := w.Box().NewGroup("widget:").Pad() g2 := g.NewGroup("widget:") activeLabel = g2.NewLabel("undef") @@ -67,7 +59,7 @@ func DebugWidgetWindow(w *gui.Node) { // common things that should work against each widget - g = newB.NewGroup("common things") + g = w.Box().NewGroup("common things") g.NewButton("Enable()", func () { activeWidget.Enable() }) @@ -84,12 +76,12 @@ func DebugWidgetWindow(w *gui.Node) { activeWidget.Dump() }) - g = newB.NewGroup("add things") + g = w.Box().NewGroup("add things") debugAddWidgetButton(g) g.NewLabel("experiments:") debugAddWidgetButtons(g) - g = newB.NewGroup("change things") + g = w.Box().NewGroup("change things") g.NewButton("AddText()", func () { activeWidget.AddText(activeLabelNewName.S) /* @@ -129,13 +121,15 @@ func DebugWidgetWindow(w *gui.Node) { activeWidget.Delete(activeWidget) }) - g = newB.NewGroup("not working?") - activeJunk = newB.NewGroup("junk:") + g = w.Box().NewGroup("not working?") + activeJunk = w.Box().NewGroup("junk:") activeJunk.NewLabel("test junk") if (activeWidget == nil) { - setActiveWidget(myGui) + setActiveWidget(me.myGui) } + + return w } func debugAddWidgetButtons(n *gui.Node) {