move logSettings window here

This commit is contained in:
Jeff Carr 2024-01-03 11:36:11 -06:00
parent 6b49c4139e
commit 796d07652e
3 changed files with 103 additions and 9 deletions

96
logSettings.go Normal file
View File

@ -0,0 +1,96 @@
package debugger
import (
"go.wit.com/log"
"go.wit.com/gui/gui"
)
type LogSettings struct {
ready bool
hidden bool
err error
name string
parent *gui.Node // should be the root of the 'gui' package binary tree
window *gui.Node // our window for displaying the log package settings
group *gui.Node //
grid *gui.Node //
checkbox *gui.Node
label *gui.Node
}
func (ls *LogSettings) Set(b bool) {
log.Set(ls.name, b)
ls.checkbox.Set(b)
}
func NewLogFlag(p *gui.Node, name string) *LogSettings {
ls := new(LogSettings)
ls.parent = p
ls.ready = false
ls.name = name
ls.checkbox = p.NewCheckbox(name)
ls.label = p.NewLabel("Enable log." + name)
ls.checkbox.Set(log.Get(name))
ls.checkbox.Custom = func() {
log.Set(name, ls.checkbox.B)
}
return ls
}
// Let's you toggle on and off the various types of debugging output
// These checkboxes should be in the same order as the are printed
func DebugFlags(n *gui.Node) {
var newW, newB, g *gui.Node
logGadgets := make(map[string]*LogSettings)
newW = myGui.NewWindow("Debug Flags")
newW.Custom = myGui.StandardClose
newB = newW.NewBox("hBox", true)
g = newB.NewGroup("Show").Pad()
g.NewButton("log.SetTmp()", func () {
log.SetTmp()
})
g.NewButton("log.All(true)", func () {
for _, lf := range logGadgets {
lf.Set(true)
}
log.All(true)
})
g.NewButton("log.All(false)", func () {
for _, lf := range logGadgets {
lf.Set(false)
}
log.All(false)
})
g.NewButton("Dump Flags", func () {
// ShowDebugValues()
log.ListFlags()
})
/*
g.NewButton("All On", func () {
SetDebug(true)
})
g.NewButton("All Off", func () {
SetDebug(false)
})
*/
g = newB.NewGroup("List")
g = g.NewGrid("flags grid", 2, 2)
logGadgets["INFO"] = NewLogFlag(g, "INFO")
logGadgets["WARN"] = NewLogFlag(g, "WARN")
logGadgets["SPEW"] = NewLogFlag(g, "SPEW")
logGadgets["ERROR"] = NewLogFlag(g, "ERROR")
}

View File

@ -7,13 +7,6 @@ import (
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
) )
// main debugging window
var myGui *gui.Node
var bugWin *gui.Node
var bugTab *gui.Node
var mapWindows map[string]*gui.Node // tracks all windows that exist
/* /*
Creates a window helpful for debugging this package Creates a window helpful for debugging this package
*/ */
@ -26,7 +19,6 @@ func DebugWindow(p *gui.Node) {
bugTab.StandardClose() bugTab.StandardClose()
if gui.ArgDebug() { if gui.ArgDebug() {
log.SetTmp() log.SetTmp()
// myGui.DebugFlags()
} }
} }
@ -52,7 +44,7 @@ func DebugWindow2(n *gui.Node, title string) *gui.Node {
n.SetTabs(false) n.SetTabs(false)
gog.NewButton("logging", func () { gog.NewButton("logging", func () {
bugWin.DebugFlags() DebugFlags(myGui)
}) })
gog.NewButton("Debug Widgets", func () { gog.NewButton("Debug Widgets", func () {
gui.DebugWidgetWindow(myGui) gui.DebugWidgetWindow(myGui)

View File

@ -5,6 +5,12 @@ import (
// "go.wit.com/gui/gui/toolkit" // "go.wit.com/gui/gui/toolkit"
) )
// main debugging window
var myGui *gui.Node
var bugWin *gui.Node
var bugTab *gui.Node
var mapWindows map[string]*gui.Node // tracks all windows that exist
// global var for checking to see if this // global var for checking to see if this
// window/tab for debugging a widget exists // window/tab for debugging a widget exists