NODE: going down a rabbit hole

This commit is contained in:
Jeff Carr 2021-10-09 01:51:15 -05:00
parent 7d5b353f0d
commit e16eb26379
5 changed files with 61 additions and 14 deletions

22
box.go
View File

@ -47,16 +47,24 @@ func add(box *GuiBox, newbox *GuiBox) {
log.Println("\tgui.add() adding", newbox.Name, "to", box.Name) log.Println("\tgui.add() adding", newbox.Name, "to", box.Name)
// copy the box settings over // copy the box settings over
newbox.Window = box.Window newbox.Window = box.Window
if (box.UiBox == nil) { if (box.node == nil) {
log.Println("\tgui.add() ERROR box.UiBox == nil") box.Dump()
panic("crap") panic("gui.add() ERROR box.node == nil")
} }
if (newbox.UiBox == nil) { if (newbox.UiBox == nil) {
log.Println("\tgui.add() ERROR newbox.UiBox == nil") panic("gui.add() ERROR newbox.UiBox == nil")
panic("crap") }
if (box.UiBox == nil) {
}
if (box.UiBox == nil) {
DebugDataNodeChildren()
box.Dump()
return
panic("gui.add() ERROR box.UiBox == nil")
} }
// log.Println("\tgui.add() newbox.UiBox == ", newbox.UiBox.GetParent())
// spew.Dump(newbox.UiBox)
box.UiBox.Append(newbox.UiBox, false) box.UiBox.Append(newbox.UiBox, false)
// add the newbox to the Window.BoxMap[] // add the newbox to the Window.BoxMap[]

View File

@ -13,6 +13,17 @@ func NewLabel(box *GuiBox, text string) {
box.Append(ui.NewLabel(text), false) box.Append(ui.NewLabel(text), false)
} }
func (n *Node) NewLabel(text string) *Node {
// make new node here
// n.Append(ui.NewLabel(text), false)
newNode := makeNode(n, text, 333, 334)
newNode.Dump()
// panic("node.NewLabel()")
n.Append(newNode)
return newNode
}
func GetText(box *GuiBox, name string) string { func GetText(box *GuiBox, name string) string {
if (box == nil) { if (box == nil) {
log.Println("gui.GetText() ERROR box == nil") log.Println("gui.GetText() ERROR box == nil")

View File

@ -68,6 +68,10 @@ func (n *Node) FindTab() *ui.Tab {
return n.uiTab return n.uiTab
} }
func (n *Node) FindControl() *ui.Control {
return n.uiControl
}
func (n *Node) FindBox() *GuiBox { func (n *Node) FindBox() *GuiBox {
return n.box return n.box
} }
@ -99,7 +103,9 @@ func (n *Node) ListChildren() {
log.Println("\tListChildren() node =", n.id, n.Name, n.Width, n.Height) log.Println("\tListChildren() node =", n.id, n.Name, n.Width, n.Height)
if len(n.children) == 0 { if len(n.children) == 0 {
log.Println("\t\t\tparent =",n.parent.id) if (n.parent != nil) {
log.Println("\t\t\tparent =",n.parent.id)
}
log.Println("\t\tNo children START") log.Println("\t\tNo children START")
return return
} }
@ -161,7 +167,7 @@ func findByName(node *Node, name string) *Node {
return nil return nil
} }
func (n *Node) InitTab(title string, custom func() ui.Control) *Node { func (n *Node) InitTab(title string) *Node {
if n.uiWindow == nil { if n.uiWindow == nil {
n.Dump() n.Dump()
panic("gui.InitTab() ERROR ui.Window == nil") panic("gui.InitTab() ERROR ui.Window == nil")
@ -175,10 +181,31 @@ func (n *Node) InitTab(title string, custom func() ui.Control) *Node {
n.uiWindow.SetChild(tab) n.uiWindow.SetChild(tab)
n.uiWindow.SetMargined(true) n.uiWindow.SetMargined(true)
tab.Append(title, custom()) tab.Append(title, initBlankWindow())
tab.SetMargined(0, true) tab.SetMargined(0, true)
newNode := makeNode(n, title, 555, 666) newNode := makeNode(n, title, 555, 600 + Config.counter)
newNode.uiTab = tab
return newNode
}
func (n *Node) AddTab(title string, custom func() ui.Control) *Node {
if n.uiWindow == nil {
n.Dump()
panic("gui.AddTab() ERROR ui.Window == nil")
}
if n.box == nil {
n.Dump()
panic("gui.AddTab() ERROR box == nil")
}
tab := ui.NewTab()
n.uiWindow.SetMargined(true)
tab.Append(title, custom())
tab.SetMargined(0, true)
newNode := makeNode(n, title, 555, 600 + Config.counter)
newNode.uiTab = tab newNode.uiTab = tab
return newNode return newNode
} }

View File

@ -226,7 +226,7 @@ func (s *GuiBox) AddTab(title string, custom ui.Control) *ui.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)
var box *GuiBox var box *GuiBox

View File

@ -213,7 +213,8 @@ 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.InitTab(title, custom) n.InitTab(title)
// TODO: run custom() here // Oct 9
return n return n
} }
@ -283,7 +284,7 @@ func CreateBlankWindow(title string, x int, y int) *Node {
return n return n
} }
func InitBlankWindow() ui.Control { func initBlankWindow() ui.Control {
hbox := ui.NewHorizontalBox() hbox := ui.NewHorizontalBox()
hbox.SetPadded(true) hbox.SetPadded(true)