summaryrefslogtreecommitdiff
path: root/logsettings/draw.go
blob: f125f1b591fdc7ad04ac29fc235de8cafe058d3e (plain)
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
package logsettings

import 	(
	"go.wit.com/log"
	"go.wit.com/gui/gui"
	"go.wit.com/gui/gadgets"
)

func (d *LogSettings) Show() {
	if ! d.Ready() {
		log.Warn("LogSettings.Show() window is not Ready()")
		return
	}
	log.Warn("LogSettings.Show() window")
	if d.hidden {
		log.Warn("LogSettings.Show() window HERE window =", d.window)
		if d.window == nil {
			log.Warn("LogSettings.Show() create the window")
			d.draw()
		}
		d.window.Show()
	}
	d.hidden = false
}

func (d *LogSettings) Hide() {
	if ! d.Ready() {
		log.Warn("LogSettings.Show() window is not Ready()")
		return
	}
	log.Warn("LogSettings.Hide() window")
	if ! d.hidden {
		d.window.Hide()
	}
	d.hidden = true
}

// 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 (d *LogSettings) draw() {
	if ! d.Ready() {return}
	var newW, newB, g *gui.Node

	newW = d.parent.NewWindow("Debug Flags")
	newW.Custom = d.parent.StandardClose

	newB = newW.NewBox("hBox", true)
	g = newB.NewGroup("Show").Pad()

	g.NewButton("log.SetTmp()", func () {
		log.SetTmp()
	})

	g.NewButton("log.SetAll(true)", func () {
		log.SetAll(true)
	})

	g.NewButton("log.SetAll(false)", func () {
		log.SetAll(false)
	})

	g.NewButton("Dump Flags", func () {
		// ShowDebugValues()
		log.ShowFlags()
	})

	g = newB.NewGroup("List")
	g = g.NewGrid("flags grid", 5, 2)
	flags := log.ShowFlags()
	for _, f := range flags {
		log.Log(true, "Get() ", "(" + f.Subsystem + ")", f.Name, "=", f.B, ":", f.Desc)
		gadgets.NewLogFlag(g, f)
	}
}