summaryrefslogtreecommitdiff
path: root/debug_widget.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2023-03-01 11:35:36 -0600
committerJeff Carr <[email protected]>2023-03-01 11:35:36 -0600
commit8dbf5a09097b7868e9218bf98716c57eac998a10 (patch)
treeab3bdfeaf5a59a55de9d2a6661d2d824090491e5 /debug_widget.go
parentf3bb68396afa7452ecf1c8d4744c825a9d81057c (diff)
lots cleaner code between the pluginv0.6.1
Queue() around SetText is helping userspace crashing merge forceDump(bool) into Dump() debugging output configuration is pretty clean keep cutting down duplicate things --gui-verbose flag works make label "standard" code add debug.FreeOSMemory() move the GO language internals to display in the GUI update push to do tags and go to github.com/wit-go/ remove the other license file it might be confusing golang.org and github proper WidgetType added a Quit() button Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'debug_widget.go')
-rw-r--r--debug_widget.go115
1 files changed, 115 insertions, 0 deletions
diff --git a/debug_widget.go b/debug_widget.go
new file mode 100644
index 0000000..da15706
--- /dev/null
+++ b/debug_widget.go
@@ -0,0 +1,115 @@
+package gui
+
+import (
+ "strconv"
+)
+
+func DebugWidgetWindow(w *Node) {
+ var win, g *Node
+
+ title := "ID =" + strconv.Itoa(w.id) + " " + w.widget.Name
+
+ Config.Title = title
+ Config.Width = 300
+ Config.Height = 400
+ win = NewWindow()
+ win.Custom = w.StandardClose
+
+ g = win.NewGroup("Actions")
+
+ g.NewLabel(title)
+ g.NewButton("Dump()", func () {
+ w.Dump()
+ })
+ g.NewButton("Disable()", func () {
+ w.widget.Action = "Disable"
+ send(w.parent, w)
+ })
+ g.NewButton("Enable()", func () {
+ w.widget.Action = "Enable"
+ send(w.parent, w)
+ })
+ g.NewButton("Show()", func () {
+ w.widget.Action = "Show"
+ send(w.parent, w)
+ })
+ g.NewButton("Hide()", func () {
+ w.widget.Action = "Hide"
+ send(w.parent, w)
+ })
+ g.NewButton("Value()", func () {
+ log("w.B =", w.widget.B)
+ log("w.I =", w.widget.I)
+ log("w.S =", w.widget.S)
+ })
+ g.NewButton("Set Value(20)", func () {
+ w.widget.Action = "Set"
+ w.widget.B = true
+ w.widget.I = 20
+ w.widget.S = "Set Value(20)"
+ send(w.parent, w)
+ })
+ g.NewButton("Delete()", func () {
+ Delete(w)
+ })
+}
+
+func (n *Node) debugWidgets(makeWindow bool) {
+ var w, gList, gShow *Node
+
+ // Either:
+ // make a new window
+ // make a new tab in the existing window
+ if (makeWindow) {
+ Config.Title = "Widgets"
+ Config.Width = 300
+ Config.Height = 400
+ w = NewWindow()
+ w.Custom = w.StandardClose
+ } else {
+ w = n.NewTab("Widgets")
+ }
+ w.Dump()
+
+ gList = w.NewGroup("Pick a widget to debug")
+ gShow = w.NewGroup("Added Widgets go here")
+
+ gList.NewButton("Button", func () {
+ a := gShow.NewButton("myButton", func () {
+ log("this code is more better")
+ })
+ DebugWidgetWindow(a)
+ })
+ gList.NewButton("Checkbox", func () {
+ a := gShow.NewCheckbox("myCheckbox")
+ a.Custom = func () {
+ log("custom checkox func a =", a.widget.B, a.id)
+ }
+ DebugWidgetWindow(a)
+ })
+ gList.NewButton("Label", func () {
+ a := gShow.NewLabel("mylabel")
+ DebugWidgetWindow(a)
+ })
+ gList.NewButton("Textbox", func () {
+ a := gShow.NewTextbox("mytext")
+ a.Custom = func () {
+ log("custom TextBox() a =", a.widget.S, a.id)
+ }
+ DebugWidgetWindow(a)
+ })
+ gList.NewButton("Slider", func () {
+ a := gShow.NewSlider("tmp slider", 10, 55)
+ a.Custom = func () {
+ log("custom slider() a =", a.widget.S, a.id)
+ }
+ DebugWidgetWindow(a)
+ })
+ gList.NewButton("Spinner", func () {
+ a := gShow.NewSpinner("tmp spinner", 6, 32)
+ a.Custom = func () {
+ log("custom spinner() a =", a.widget.S, a.id)
+ }
+ DebugWidgetWindow(a)
+ })
+}