summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2021-10-09 01:51:15 -0500
committerJeff Carr <[email protected]>2021-10-09 01:51:15 -0500
commit3204eb151f4bd38854df22c91ab7c5f4ab06951e (patch)
treefef5ce910be79ae6ccdfb77715b77878d39a6a69
parentc59560da383f56bb1a86f02b7b4ecf7bca3bb588 (diff)
NODE: going down a rabbit hole
-rw-r--r--box.go22
-rw-r--r--entry.go11
-rw-r--r--new-structs.go33
-rw-r--r--structs.go2
-rw-r--r--window.go5
5 files changed, 60 insertions, 13 deletions
diff --git a/box.go b/box.go
index 10fb1bc..0d2a487 100644
--- a/box.go
+++ b/box.go
@@ -47,16 +47,24 @@ func add(box *GuiBox, newbox *GuiBox) {
log.Println("\tgui.add() adding", newbox.Name, "to", box.Name)
// copy the box settings over
newbox.Window = box.Window
- if (box.UiBox == nil) {
- log.Println("\tgui.add() ERROR box.UiBox == nil")
- panic("crap")
+ if (box.node == nil) {
+ box.Dump()
+ panic("gui.add() ERROR box.node == nil")
}
+
if (newbox.UiBox == nil) {
- log.Println("\tgui.add() ERROR newbox.UiBox == nil")
- panic("crap")
+ panic("gui.add() ERROR newbox.UiBox == nil")
+ }
+
+ 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)
// add the newbox to the Window.BoxMap[]
diff --git a/entry.go b/entry.go
index d7f31c9..f3abce2 100644
--- a/entry.go
+++ b/entry.go
@@ -13,6 +13,17 @@ func NewLabel(box *GuiBox, text string) {
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 {
if (box == nil) {
log.Println("gui.GetText() ERROR box == nil")
diff --git a/new-structs.go b/new-structs.go
index aa86ef9..d6e2550 100644
--- a/new-structs.go
+++ b/new-structs.go
@@ -68,6 +68,10 @@ func (n *Node) FindTab() *ui.Tab {
return n.uiTab
}
+func (n *Node) FindControl() *ui.Control {
+ return n.uiControl
+}
+
func (n *Node) FindBox() *GuiBox {
return n.box
}
@@ -99,7 +103,9 @@ func (n *Node) ListChildren() {
log.Println("\tListChildren() node =", n.id, n.Name, n.Width, n.Height)
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")
return
}
@@ -161,7 +167,7 @@ func findByName(node *Node, name string) *Node {
return nil
}
-func (n *Node) InitTab(title string, custom func() ui.Control) *Node {
+func (n *Node) InitTab(title string) *Node {
if n.uiWindow == nil {
n.Dump()
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.SetMargined(true)
+ tab.Append(title, initBlankWindow())
+ tab.SetMargined(0, true)
+
+ 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, 666)
+ newNode := makeNode(n, title, 555, 600 + Config.counter)
newNode.uiTab = tab
return newNode
}
diff --git a/structs.go b/structs.go
index 8b1a99a..bf5dec8 100644
--- a/structs.go
+++ b/structs.go
@@ -226,7 +226,7 @@ func (s *GuiBox) AddTab(title string, custom ui.Control) *ui.Tab {
}
func (s GuiBox) AddBoxTab(title string) *GuiBox {
- uiTab := s.AddTab(title, InitBlankWindow())
+ uiTab := s.AddTab(title, initBlankWindow())
tabSetMargined(uiTab)
var box *GuiBox
diff --git a/window.go b/window.go
index 518b92c..75a427c 100644
--- a/window.go
+++ b/window.go
@@ -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()")
}
- n.InitTab(title, custom)
+ n.InitTab(title)
+ // TODO: run custom() here // Oct 9
return n
}
@@ -283,7 +284,7 @@ func CreateBlankWindow(title string, x int, y int) *Node {
return n
}
-func InitBlankWindow() ui.Control {
+func initBlankWindow() ui.Control {
hbox := ui.NewHorizontalBox()
hbox.SetPadded(true)