diff --git a/debug.go b/debug.go index dbdbc68..d5273e0 100644 --- a/debug.go +++ b/debug.go @@ -171,6 +171,39 @@ func FindNode(name string) *Node { return nil } +func (dn *GuiData) ListChildren(dump bool) { + if Data.NodeMap == nil { + log.Println("Data.NodeMap == nil") + return + } + log.Println("Dumping Data.NodeMap:") + for name, node := range Data.NodeMap { + log.Println("\tData.NodeMap name =", node.id, node.Width, node.Height, name) + if (dump == true) { + node.Dump() + } + node.ListChildren(dump) + } +} + +func (dn *GuiData) findId(id string) *Node { + if Data.NodeMap == nil { + log.Println("Data.NodeMap == nil") + return nil + } + log.Println("Dumping Data.NodeMap:") + for name, node := range Data.NodeMap { + log.Println("\tData.NodeMap name =", node.id, node.Width, node.Height, name) + if (id == node.id) { + return node + } + // TODO: fix // Oct 9 + // node.findId(id) + } + return nil +} + +/* func DebugNodeChildren() { if Data.NodeMap == nil { log.Println("Data.NodeMap == nil") @@ -185,3 +218,4 @@ func DebugNodeChildren() { // log.Println("\tData.NodeMap node =", node) } } +*/ diff --git a/new-structs.go b/new-structs.go index d6e2550..4c24692 100644 --- a/new-structs.go +++ b/new-structs.go @@ -99,7 +99,7 @@ func (n *Node) List() { findByIdDFS(n, "test") } -func (n *Node) ListChildren() { +func (n *Node) ListChildren(dump bool) { log.Println("\tListChildren() node =", n.id, n.Name, n.Width, n.Height) if len(n.children) == 0 { @@ -118,13 +118,15 @@ func (n *Node) ListChildren() { log.Println("\t\t\tno parent") panic("no parent") } - // child.Dump() + if (dump == true) { + child.Dump() + } if (child.children == nil) { log.Println("\t\t\tNo children END") // break } log.Println("\t\t\tHas children:", child.children) - child.ListChildren() + child.ListChildren(dump) } return } diff --git a/structs.go b/structs.go index bf5dec8..961e743 100644 --- a/structs.go +++ b/structs.go @@ -171,7 +171,7 @@ func (b *GuiBox) FindNode() *Node { if b.node != nil { return b.node } - DebugNodeChildren() + Data.ListChildren(true) b.Dump() log.Println("gui.FindNode() on GuiBox is nil") os.Exit(-1) diff --git a/window-debug.go b/window-debug.go index c68468d..308c3ea 100644 --- a/window-debug.go +++ b/window-debug.go @@ -9,13 +9,21 @@ import ( ) var names = make([]string, 100) +var nodeNames = make([]string, 100) + +// TODO: remove this crap +func addNodeName(c *ui.Combobox, s string) { + c.Append(s) + nodeNames[y] = s + y = y + 1 +} func makeWindowDebug() ui.Control { hbox := ui.NewHorizontalBox() hbox.SetPadded(true) ///////////////////////////////////////////////////// - vbox := addGroup(hbox, "Window") + vbox := addGroup(hbox, "range Data.WindowMap") cbox := ui.NewCombobox() for name, _ := range Data.WindowMap { @@ -132,6 +140,28 @@ func makeWindowDebug() ui.Control { DumpMap() }) + ///////////////////////////////////////////////////// + nodeBox := addGroup(hbox, "range Data.NodeMap") + nodeCombo := ui.NewCombobox() + + for name, node := range Data.NodeMap { + log.Println("range Data.NodeMap() name =", name) + addNodeName(nodeCombo, node.id) + } + nodeCombo.SetSelected(0) + + nodeBox.Append(nodeCombo, false) + + nodeCombo.OnSelected(func(*ui.Combobox) { + y := nodeCombo.Selected() + log.Println("y =", y) + log.Println("nodeNames[y] =", nodeNames[y]) + node := Data.findId(nodeNames[y]) + if (node != nil) { + node.Dump() + } + }) + ///////////////////////////////////////////////////// vbox = addGroup(hbox, "Node Debug") @@ -145,9 +175,14 @@ func makeWindowDebug() ui.Control { DebugDataNodeChildren() }) - n3 := addButton(vbox, "Node.ListChildren()") + n3 := addButton(vbox, "Node.ListChildren(false)") n3.OnClicked(func(*ui.Button) { - DebugNodeChildren() + Data.ListChildren(false) + }) + + n4 := addButton(vbox, "Node.ListChildren(true)") + n4.OnClicked(func(*ui.Button) { + Data.ListChildren(true) }) /* @@ -161,8 +196,11 @@ func makeWindowDebug() ui.Control { return hbox } +// TODO: remove this crap var x int = 0 +var y int = 0 +// TODO: remove this crap func addName(c *ui.Combobox, s string) { c.Append(s) names[x] = s diff --git a/window.go b/window.go index 75a427c..e603050 100644 --- a/window.go +++ b/window.go @@ -131,7 +131,7 @@ func InitWindow(parent *Node, gw *GuiWindow, name string, axis int) *Node { } } if (box.node == nil) { - DebugNodeChildren() + Data.ListChildren(true) log.Println("InitWindow() box has a FUCKING nil node") fn := FindNode("full initTab") log.Println("InitWindow() fn =", fn) @@ -139,7 +139,7 @@ func InitWindow(parent *Node, gw *GuiWindow, name string, axis int) *Node { } if (newGuiWindow.node == nil) { - DebugNodeChildren() + Data.ListChildren(true) log.Println("InitWindow() newGuiWindow has a FUCKING nil node") // panic(-1) }