NODE: climbing up the rabbit hole

This commit is contained in:
Jeff Carr 2021-10-09 10:46:57 -05:00
parent da16b8106c
commit b3e00c173b
4 changed files with 34 additions and 9 deletions

View File

@ -70,7 +70,11 @@ func (n *Node) Dump() {
log.Println("gui.Node.Dump() Width = ", n.Width) log.Println("gui.Node.Dump() Width = ", n.Width)
log.Println("gui.Node.Dump() Height = ", n.Height) log.Println("gui.Node.Dump() Height = ", n.Height)
log.Println("gui.Node.Dump() parent = ", n.parent) if (n.parent == nil) {
log.Println("gui.Node.Dump() parent = nil")
} else {
log.Println("gui.Node.Dump() parent = ", n.parent.id)
}
log.Println("gui.Node.Dump() children = ", n.children) log.Println("gui.Node.Dump() children = ", n.children)
log.Println("gui.Node.Dump() window = ", n.window) log.Println("gui.Node.Dump() window = ", n.window)
@ -204,7 +208,7 @@ func findByName(node *Node, name string) *Node {
return nil return nil
} }
func (parent *Node) AddTab(title string) *Node { func (parent *Node) AddTab(title string, uiC ui.Control) *Node {
if parent.uiWindow == nil { if parent.uiWindow == nil {
parent.Dump() parent.Dump()
panic("gui.AddTab() ERROR ui.Window == nil") panic("gui.AddTab() ERROR ui.Window == nil")
@ -226,7 +230,10 @@ func (parent *Node) AddTab(title string) *Node {
tab := parent.uiTab tab := parent.uiTab
parent.uiWindow.SetMargined(true) parent.uiWindow.SetMargined(true)
tab.Append(title, initBlankWindow()) if (uiC == nil) {
uiC = parent.initBlankWindow()
}
tab.Append(title, uiC)
tab.SetMargined(0, true) tab.SetMargined(0, true)
newNode := parent.makeNode(title, 555, 600 + Config.counter) newNode := parent.makeNode(title, 555, 600 + Config.counter)

View File

@ -200,6 +200,7 @@ func (s *GuiBox) AddTab(title string, custom ui.Control) *ui.Tab {
return tab return tab
} }
/*
func (s GuiBox) AddBoxTab(title string) *GuiBox { func (s GuiBox) AddBoxTab(title string) *GuiBox {
uiTab := s.AddTab(title, initBlankWindow()) uiTab := s.AddTab(title, initBlankWindow())
tabSetMargined(uiTab) tabSetMargined(uiTab)
@ -209,10 +210,12 @@ func (s GuiBox) AddBoxTab(title string) *GuiBox {
box.Window.UiTab = uiTab box.Window.UiTab = uiTab
return box return box
} }
*/
func (s GuiBox) AddDemoTab(title string) { func (n *Node) AddDemoTab(title string) {
uiTab := s.AddTab(title, makeWindowTemplate()) newNode := n.AddTab(title, makeWindowTemplate())
tabSetMargined(uiTab) newNode.Dump()
tabSetMargined(newNode.uiTab)
} }
func (s GuiBox) AddDebugTab(title string) { func (s GuiBox) AddDebugTab(title string) {

View File

@ -187,6 +187,17 @@ func makeWindowDebug() ui.Control {
Data.ListChildren(true) Data.ListChildren(true)
}) })
n1 = addButton(vbox, "Node.Dump()")
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.Dump()
}
})
n1 = addButton(vbox, "Node.ListChildren(false)") n1 = addButton(vbox, "Node.ListChildren(false)")
n1.OnClicked(func(*ui.Button) { n1.OnClicked(func(*ui.Button) {
y := nodeCombo.Selected() y := nodeCombo.Selected()
@ -269,7 +280,10 @@ func FindBox(s string) *GuiBox {
} }
func dumpBox(s string) { func dumpBox(s string) {
for name, window := range Data.WindowMap { var name string
var window *GuiWindow
for name, window = range Data.WindowMap {
if name != s { if name != s {
continue continue
} }
@ -286,6 +300,7 @@ func dumpBox(s string) {
log.Println("gui.dumpBox() BoxMap START") log.Println("gui.dumpBox() BoxMap START")
for name, abox := range window.BoxMap { for name, abox := range window.BoxMap {
log.Printf("gui.DumpBoxes() \tBOX mapname=%-12s abox.Name=%-12s", name, abox.Name) log.Printf("gui.DumpBoxes() \tBOX mapname=%-12s abox.Name=%-12s", name, abox.Name)
abox.Dump()
if name == "MAINBOX" { if name == "MAINBOX" {
if Config.Debug { if Config.Debug {
scs := spew.ConfigState{MaxDepth: 1} scs := spew.ConfigState{MaxDepth: 1}

View File

@ -214,7 +214,7 @@ func CreateWindow(title string, tabname string, x int, y int, custom func() ui.C
log.Println("SERIOUS ERROR n.box == nil in CreateWindow()") log.Println("SERIOUS ERROR n.box == nil in CreateWindow()")
log.Println("SERIOUS ERROR n.box == nil in CreateWindow()") log.Println("SERIOUS ERROR n.box == nil in CreateWindow()")
} }
n.AddTab(title) n.AddTab(title, custom())
// TODO: run custom() here // Oct 9 // TODO: run custom() here // Oct 9
return n return n
} }
@ -319,7 +319,7 @@ func CreateBlankWindow(title string, x int, y int) *Node {
return node return node
} }
func initBlankWindow() ui.Control { func (n *Node) initBlankWindow() ui.Control {
hbox := ui.NewHorizontalBox() hbox := ui.NewHorizontalBox()
hbox.SetPadded(true) hbox.SetPadded(true)