NODE: walking around in the rabbit hole

This commit is contained in:
Jeff Carr 2021-10-09 03:04:15 -05:00
parent 24244a206e
commit 310569479b
3 changed files with 48 additions and 25 deletions

View File

@ -114,14 +114,10 @@ func addTableTab() {
time.Sleep(1 * time.Second)
}
func DebugDataNodeMap() {
if Data.NodeMap == nil {
log.Println("DebugDataNodeMap() NodeMap == nil")
return
}
func (dn *GuiData) DumpNodeMap() {
log.Println("DebugDataNodeMap():")
for name, node := range Data.NodeMap {
log.Println("\tNode name =", node.Width, node.Height, name)
for name, node := range dn.NodeMap {
log.Println("\tNode =", node.id, node.Width, node.Height, name)
if (node.children == nil) {
log.Println("\t\tNo children")
} else {
@ -173,12 +169,12 @@ func FindNode(name string) *Node {
func (dn *GuiData) ListChildren(dump bool) {
if Data.NodeMap == nil {
log.Println("Data.NodeMap == nil")
log.Println("gui.Data.ListChildren() Data.NodeMap == nil")
return
}
log.Println("Dumping Data.NodeMap:")
log.Println("gui.Data.ListChildren() Data.NodeMap:")
for name, node := range Data.NodeMap {
log.Println("\tData.NodeMap name =", node.id, node.Width, node.Height, name)
log.Println("\tgui.Data.ListChildren() node =", node.id, node.Width, node.Height, name)
if (dump == true) {
node.Dump()
}
@ -188,13 +184,14 @@ func (dn *GuiData) ListChildren(dump bool) {
func (dn *GuiData) findId(id string) *Node {
if Data.NodeMap == nil {
log.Println("Data.NodeMap == nil")
log.Println("gui.Data.findId() map == nil")
return nil
}
log.Println("Dumping Data.NodeMap:")
// log.Println("Dumping Data.NodeMap:")
for name, node := range Data.NodeMap {
log.Println("\tData.NodeMap name =", node.id, node.Width, node.Height, name)
// log.Println("\tData.NodeMap name =", node.id, node.Width, node.Height, name)
if (id == node.id) {
log.Println("\tgui.Data.findId() found node =", node.id, node.Width, node.Height, name)
return node
}
// TODO: fix // Oct 9

View File

@ -102,14 +102,16 @@ func (n *Node) List() {
func (n *Node) ListChildren(dump bool) {
log.Println("\tListChildren() node =", n.id, n.Name, n.Width, n.Height)
if (dump == true) {
n.Dump()
}
if len(n.children) == 0 {
if (n.parent != nil) {
log.Println("\t\t\tparent =",n.parent.id)
}
log.Println("\t\tNo children START")
log.Println("\t\t", n.id, "has no children")
return
}
// spew.Dump(n)
for _, child := range n.children {
log.Println("\t\tListChildren() child =",child.id, child.Name, child.Width, child.Height)
if (child.parent != nil) {
@ -118,12 +120,14 @@ func (n *Node) ListChildren(dump bool) {
log.Println("\t\t\tno parent")
panic("no parent")
}
/*
if (dump == true) {
child.Dump()
}
*/
if (child.children == nil) {
log.Println("\t\t\tNo children END")
// break
log.Println("\t\t", child.id, "has no children")
break
}
log.Println("\t\t\tHas children:", child.children)
child.ListChildren(dump)

View File

@ -165,26 +165,48 @@ func makeWindowDebug() ui.Control {
/////////////////////////////////////////////////////
vbox = addGroup(hbox, "Node Debug")
n1 := addButton(vbox, "DebugDataNodeMap()")
n1 := addButton(vbox, "Data.DumpNodeMap()")
n1.OnClicked(func(*ui.Button) {
DebugDataNodeMap()
Data.DumpNodeMap()
})
n2 := addButton(vbox, "DebugDataNodeChildren()")
n2.OnClicked(func(*ui.Button) {
n1 = addButton(vbox, "DebugDataNodeChildren()")
n1.OnClicked(func(*ui.Button) {
DebugDataNodeChildren()
})
n3 := addButton(vbox, "Node.ListChildren(false)")
n3.OnClicked(func(*ui.Button) {
n1 = addButton(vbox, "Data.ListChildren(false)")
n1.OnClicked(func(*ui.Button) {
Data.ListChildren(false)
})
n4 := addButton(vbox, "Node.ListChildren(true)")
n4.OnClicked(func(*ui.Button) {
n1 = addButton(vbox, "Data.ListChildren(true)")
n1.OnClicked(func(*ui.Button) {
Data.ListChildren(true)
})
n1 = addButton(vbox, "Node.ListChildren(false)")
n1.OnClicked(func(*ui.Button) {
y := nodeCombo.Selected()
log.Println("y =", y)
log.Println("nodeNames[y] =", nodeNames[y])
node := Data.findId(nodeNames[y])
if (node != nil) {
node.ListChildren(false)
}
})
n1 = addButton(vbox, "Node.ListChildren(true)")
n1.OnClicked(func(*ui.Button) {
y := nodeCombo.Selected()
log.Println("y =", y)
log.Println("nodeNames[y] =", nodeNames[y])
node := Data.findId(nodeNames[y])
if (node != nil) {
node.ListChildren(true)
}
})
/*
/////////////////////////////////////////////////////
vbox = addGroup(hbox, "Numbers")