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)
|
var nodeNames = make([]string, 100)
|
||||||
|
|
||||||
func DebugWindow() {
|
func DebugWindow() {
|
||||||
Config.Title = "replace InitWindow()"
|
Config.Title = "DebugWindow()"
|
||||||
node := NewWindow()
|
node := NewWindow()
|
||||||
node.AddDebugTab("WIT GUI Debug Tab")
|
node.AddDebugTab("WIT GUI Debug Tab")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove this crap
|
// TODO: remove this crap
|
||||||
// What does this actually do?
|
// What does this actually do?
|
||||||
// It populates the nodeNames in a map. No, not a map, an array. What is the difference again?
|
// It populates the nodeNames in a map. No, not a map, an array.
|
||||||
func addNodeName(c *ui.Combobox, s string) {
|
// 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)
|
c.Append(s)
|
||||||
nodeNames[y] = s
|
nodeNames[y] = id
|
||||||
y = y + 1
|
y = y + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,14 +154,15 @@ func makeWindowDebug() *ui.Box {
|
||||||
})
|
})
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
nodeBox := addGroup(hbox, "range Data.NodeMap")
|
nodeBox := addGroup(hbox, "Windows:")
|
||||||
nodeCombo := ui.NewCombobox()
|
nodeCombo := ui.NewCombobox()
|
||||||
|
|
||||||
for name, node := range Data.NodeMap {
|
for name, node := range Data.NodeMap {
|
||||||
if (Config.Debug) {
|
if (Config.Debug) {
|
||||||
log.Println("range Data.NodeMap() name =", name)
|
log.Println("range Data.NodeMap() name =", name)
|
||||||
}
|
}
|
||||||
addNodeName(nodeCombo, node.id)
|
tmp := node.id + " (" + name + ")"
|
||||||
|
addNodeName(nodeCombo, tmp, node.id)
|
||||||
}
|
}
|
||||||
nodeCombo.SetSelected(0)
|
nodeCombo.SetSelected(0)
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ func (n *Node) AddComboBox(title string, s ...string) *Node {
|
||||||
|
|
||||||
ecbox.OnChanged(func(*ui.EditableCombobox) {
|
ecbox.OnChanged(func(*ui.EditableCombobox) {
|
||||||
test := ecbox.Text()
|
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)
|
box.Append(ecbox, false)
|
||||||
|
|
|
@ -3,7 +3,6 @@ package gui
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"fmt"
|
"fmt"
|
||||||
// "time"
|
|
||||||
|
|
||||||
// "github.com/davecgh/go-spew/spew"
|
// "github.com/davecgh/go-spew/spew"
|
||||||
|
|
||||||
|
@ -125,23 +124,53 @@ func (n *Node) List() {
|
||||||
findByIdDFS(n, "test")
|
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) {
|
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) {
|
if (dump == true) {
|
||||||
n.Dump()
|
n.Dump()
|
||||||
}
|
}
|
||||||
if len(n.children) == 0 {
|
if len(n.children) == 0 {
|
||||||
if (n.parent != nil) {
|
if (n.parent == nil) {
|
||||||
log.Println("\t\t\tparent =",n.parent.id)
|
} 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
|
return
|
||||||
}
|
}
|
||||||
for _, child := range n.children {
|
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) {
|
if (child.parent != nil) {
|
||||||
log.Println("\t\t\tparent =",child.parent.id)
|
if (Config.DebugNode) {
|
||||||
|
log.Println("\t\t\tparent =",child.parent.id)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Println("\t\t\tno parent")
|
log.Println("\t\t\tno parent")
|
||||||
panic("no parent")
|
panic("no parent")
|
||||||
|
@ -149,12 +178,17 @@ func (n *Node) ListChildren(dump bool) {
|
||||||
if (dump == true) {
|
if (dump == true) {
|
||||||
child.Dump()
|
child.Dump()
|
||||||
}
|
}
|
||||||
if (child.children == nil) {
|
if (Config.DebugNode) {
|
||||||
log.Println("\t\t", child.id, "has no children")
|
if (child.children == nil) {
|
||||||
} else {
|
log.Println("\t\t", child.id, "has no children")
|
||||||
log.Println("\t\t\tHas children:", child.children)
|
} else {
|
||||||
|
log.Println("\t\t\tHas children:", child.children)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
listChildrenParent = n
|
||||||
|
listChildrenDepth += 1
|
||||||
child.ListChildren(dump)
|
child.ListChildren(dump)
|
||||||
|
listChildrenDepth -= 1
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue