NODES: indent output based on depth in node tree
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
57f95e9486
commit
5e5df9630e
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue