summaryrefslogtreecommitdiff
path: root/debug.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-18 00:08:37 -0600
committerJeff Carr <[email protected]>2024-01-18 00:08:37 -0600
commit3ac6b2486a7f17e96ea8d812437ed9bad8662260 (patch)
treeaaf29d4a1f6fc591a3738077e6cebf26fe637849 /debug.go
init move into seperate repo. all history lost :(v0.0.1
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'debug.go')
-rw-r--r--debug.go74
1 files changed, 74 insertions, 0 deletions
diff --git a/debug.go b/debug.go
new file mode 100644
index 0000000..ee58727
--- /dev/null
+++ b/debug.go
@@ -0,0 +1,74 @@
+package main
+
+import (
+ "fmt"
+ "go.wit.com/lib/widget"
+ "go.wit.com/log"
+)
+
+func (n *node) dumpTree(draw bool) {
+ w := n.tk
+ if w == nil {
+ return
+ }
+ n.showWidgetPlacement(true, "dumpTree()")
+
+ for _, child := range n.children {
+ child.dumpTree(draw)
+ }
+}
+
+func (n *node) showWidgetPlacement(b bool, s string) {
+ if n == nil {
+ log.Log(ERROR, "WTF w == nil")
+ return
+ }
+ w := n.tk
+
+ var s1 string
+ var pId int
+ if n.parent == nil {
+ log.Log(INFO, "showWidgetPlacement() parent == nil", n.WidgetId, w.cuiName)
+ pId = 0
+ } else {
+ pId = n.parent.WidgetId
+ }
+ s1 = fmt.Sprintf("(wId,pId)=(%2d,%2d) ", n.WidgetId, pId)
+ if n.Visible() {
+ s1 += fmt.Sprintf("gocui=(%2d,%2d)(%2d,%2d,%2d,%2d)",
+ w.gocuiSize.Width(), w.gocuiSize.Height(),
+ w.gocuiSize.w0, w.gocuiSize.h0, w.gocuiSize.w1, w.gocuiSize.h1)
+ } else {
+ s1 += fmt.Sprintf(" ")
+ }
+ if n.parent != nil {
+ if n.parent.WidgetType == widget.Grid {
+ s1 += fmt.Sprintf("At(%2d,%2d) ", n.AtW, n.AtH)
+ }
+ }
+ tmp := "." + n.progname + "."
+ log.Log(INFO, s1, s, n.WidgetType, ",", tmp) // , "text=", w.text)
+}
+
+func (n *node) dumpWidget(pad string) {
+ log.Log(NOW, "node:", pad, n.WidgetId, "At(", n.AtW, n.AtH, ") ,", n.WidgetType, ", n.progname =", n.progname, ", n.label =", n.label)
+}
+
+func (n *node) listWidgets() {
+ if n == nil {
+ return
+ }
+
+ var pad string
+ for i := 0; i < me.depth; i++ {
+ pad = pad + " "
+ }
+ n.dumpWidget(pad)
+
+ for _, child := range n.children {
+ me.depth += 1
+ child.listWidgets()
+ me.depth -= 1
+ }
+ return
+}