summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2021-10-28 06:27:27 -0500
committerJeff Carr <[email protected]>2021-10-28 06:27:27 -0500
commit2b85dda8006adacc7b5b0c5594033226097e9214 (patch)
tree4ac86c6880a82565460829c96e6a847ae2b63f16
parentac1d35a358a4503cbced3f4f8411935d09b255b3 (diff)
NODES: indent output based on depth in node tree
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--debug-window.go14
-rw-r--r--demo-window.go2
-rw-r--r--new-structs.go56
3 files changed, 54 insertions, 18 deletions
diff --git a/debug-window.go b/debug-window.go
index 278aafb..756ebac 100644
--- a/debug-window.go
+++ b/debug-window.go
@@ -14,17 +14,18 @@ var names = make([]string, 100)
var nodeNames = make([]string, 100)
func DebugWindow() {
- Config.Title = "replace InitWindow()"
+ Config.Title = "DebugWindow()"
node := NewWindow()
node.AddDebugTab("WIT GUI Debug Tab")
}
// TODO: remove this crap
// What does this actually do?
-// It populates the nodeNames in a map. No, not a map, an array. What is the difference again?
-func addNodeName(c *ui.Combobox, s string) {
+// It populates the nodeNames in a map. No, not a map, an array.
+// What is the difference again? (other than one being in order and a predefined length)
+func addNodeName(c *ui.Combobox, s string, id string) {
c.Append(s)
- nodeNames[y] = s
+ nodeNames[y] = id
y = y + 1
}
@@ -153,14 +154,15 @@ func makeWindowDebug() *ui.Box {
})
/////////////////////////////////////////////////////
- nodeBox := addGroup(hbox, "range Data.NodeMap")
+ nodeBox := addGroup(hbox, "Windows:")
nodeCombo := ui.NewCombobox()
for name, node := range Data.NodeMap {
if (Config.Debug) {
log.Println("range Data.NodeMap() name =", name)
}
- addNodeName(nodeCombo, node.id)
+ tmp := node.id + " (" + name + ")"
+ addNodeName(nodeCombo, tmp, node.id)
}
nodeCombo.SetSelected(0)
diff --git a/demo-window.go b/demo-window.go
index 12cbe73..918b75b 100644
--- a/demo-window.go
+++ b/demo-window.go
@@ -46,7 +46,7 @@ func (n *Node) AddComboBox(title string, s ...string) *Node {
ecbox.OnChanged(func(*ui.EditableCombobox) {
test := ecbox.Text()
- log.Println("text is now:", test)
+ log.Println("node.Name = '" + n.Name + "' text for '" + title + "' is now: '" + test + "'")
})
box.Append(ecbox, false)
diff --git a/new-structs.go b/new-structs.go
index 8c190a3..9fe0873 100644
--- a/new-structs.go
+++ b/new-structs.go
@@ -3,7 +3,6 @@ package gui
import (
"log"
"fmt"
- // "time"
// "github.com/davecgh/go-spew/spew"
@@ -125,23 +124,53 @@ func (n *Node) List() {
findByIdDFS(n, "test")
}
+var listChildrenParent *Node
+var listChildrenDepth int = 0
+
+func indentPrintln(depth int, format string, a ...interface{}) {
+ var tabs string
+ for i := 0; i < depth; i++ {
+ tabs = tabs + "\t"
+ }
+
+ // newFormat := tabs + strconv.Itoa(depth) + " " + format
+ newFormat := tabs + format
+ log.Println(newFormat, a)
+}
+
func (n *Node) ListChildren(dump bool) {
- log.Println("\tListChildren() node =", n.id, n.Name, n.Width, n.Height)
+ indentPrintln(listChildrenDepth, "\t", n.id, n.Width, n.Height, n.Name)
if (dump == true) {
n.Dump()
}
if len(n.children) == 0 {
- if (n.parent != nil) {
- log.Println("\t\t\tparent =",n.parent.id)
+ if (n.parent == nil) {
+ } else {
+ if (Config.DebugNode) {
+ log.Println("\t\t\tparent =",n.parent.id)
+ }
+ if (listChildrenParent != nil) {
+ if (Config.DebugNode) {
+ log.Println("\t\t\tlistChildrenParent =",listChildrenParent.id)
+ }
+ if (listChildrenParent.id != n.parent.id) {
+ log.Println("parent.child does not match child.parent")
+ panic("parent.child does not match child.parent")
+ }
+ }
+ }
+ if (Config.DebugNode) {
+ log.Println("\t\t", n.id, "has no children")
}
- log.Println("\t\t", n.id, "has no children")
return
}
for _, child := range n.children {
- log.Println("\t\tListChildren() child =",child.id, child.Name, child.Width, child.Height)
+ // log.Println("\t\t", child.id, child.Width, child.Height, child.Name)
if (child.parent != nil) {
- log.Println("\t\t\tparent =",child.parent.id)
+ if (Config.DebugNode) {
+ log.Println("\t\t\tparent =",child.parent.id)
+ }
} else {
log.Println("\t\t\tno parent")
panic("no parent")
@@ -149,12 +178,17 @@ func (n *Node) ListChildren(dump bool) {
if (dump == true) {
child.Dump()
}
- if (child.children == nil) {
- log.Println("\t\t", child.id, "has no children")
- } else {
- log.Println("\t\t\tHas children:", child.children)
+ if (Config.DebugNode) {
+ if (child.children == nil) {
+ log.Println("\t\t", child.id, "has no children")
+ } else {
+ log.Println("\t\t\tHas children:", child.children)
+ }
}
+ listChildrenParent = n
+ listChildrenDepth += 1
child.ListChildren(dump)
+ listChildrenDepth -= 1
}
return
}