summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--box.go13
-rw-r--r--new-structs.go54
-rw-r--r--window.go10
3 files changed, 30 insertions, 47 deletions
diff --git a/box.go b/box.go
index 51da1c5..ef7c265 100644
--- a/box.go
+++ b/box.go
@@ -73,17 +73,18 @@ func add(box *GuiBox, newbox *GuiBox) {
log.Println("gui.add() END")
}
-func (parent *Node) NewBox(axis int, name string) *Node {
- if (parent.box == nil) {
- panic("gui.Node.NewBox() parent.box == nil")
+func (n *Node) NewBox(axis int, name string) *Node {
+ if (n.box == nil) {
+ log.Println("box == nil. I can't add a box!")
+ panic("gui.Node.NewBox() node.box == nil")
}
newBox := new(GuiBox)
- newBox.Window = parent.window
+ newBox.Window = n.window
newBox.Name = name
// make a new box & a new node
- newNode := parent.makeNode(name, 111, 100 + Config.counter)
+ newNode := n.makeNode(name, 111, 100 + Config.counter)
Config.counter += 1
var uiBox *ui.Box
@@ -96,7 +97,7 @@ func (parent *Node) NewBox(axis int, name string) *Node {
newBox.UiBox = uiBox
newNode.uiBox = uiBox
- parent.Append(newNode)
+ n.Append(newNode)
// add(n.box, newBox)
return newNode
}
diff --git a/new-structs.go b/new-structs.go
index 9fe0873..5ef3309 100644
--- a/new-structs.go
+++ b/new-structs.go
@@ -198,54 +198,37 @@ func (n *Node) ListChildren(dump bool) {
//
// This function should make a new node with the parent and
// the 'stuff' Node as a child
-func (parent *Node) AddTabNode(title string, b *GuiBox) *Node {
- // Ybox := gui.NewBox(box, gui.Yaxis, "Working Stuff")
- // var baseControl ui.Control
- // baseControl = Ybox.UiBox
- // return baseControl
-
+func (n *Node) AddTabNode(title string, b *GuiBox) *Node {
var newNode *Node
- // var newControl ui.Control
-
- /*
- if (parent.box == nil) {
- // TODO: fix this to use a blank box
- // uiC := parent.initBlankWindow()
- hbox := ui.NewHorizontalBox()
- hbox.SetPadded(true)
- newNode.uiBox = hbox
- panic("node.AddTabNode() can not add a tab if the box == nil")
- }
- if (parent.uiTab == nil) {
- panic("node.AddTabNode() can not add a tab if parent.uiTab == nil")
- }
- */
+ parent := n
newNode = parent.makeNode(title, 444, 400 + Config.counter)
newNode.uiTab = parent.uiTab
newNode.box = b
- /*
- newControl = b.UiBox
- newNode.uiTab.Append(title, newControl)
- */
- newNode.uiTab.Append(title, b.UiBox)
-
- fmt.Println("")
- log.Println("parent:")
- parent.Dump()
+ if (Config.DebugNode) {
+ fmt.Println("")
+ log.Println("parent:")
+ parent.Dump()
- fmt.Println("")
- log.Println("newNode:")
- newNode.Dump()
+ fmt.Println("")
+ log.Println("newNode:")
+ newNode.Dump()
+ }
- // panic("node.AddTabNode()")
+ if (newNode.uiTab == nil) {
+ log.Println("wit/gui/ AddTabNode() Something went wrong tab == nil")
+ // TODO: try to find the tab or window and make them if need be
+ return newNode
+ }
+ newNode.uiTab.Append(title, b.UiBox)
return newNode
}
// func (parent *Node) AddTab(title string, uiC ui.Control) *Node {
-func (parent *Node) AddTab(title string, uiC *ui.Box) *Node {
+func (n *Node) AddTab(title string, uiC *ui.Box) *Node {
+ parent := n
log.Println("gui.Node.AddTab() START name =", title)
if parent.uiWindow == nil {
parent.Dump()
@@ -275,7 +258,6 @@ func (parent *Node) AddTab(title string, uiC *ui.Box) *Node {
}
tab.Append(title, uiC)
- // panic("gui.AddTab() before makeNode()")
newNode := parent.makeNode(title, 555, 600 + Config.counter)
newNode.uiTab = tab
newNode.uiBox = uiC
diff --git a/window.go b/window.go
index 56081d2..7415010 100644
--- a/window.go
+++ b/window.go
@@ -147,18 +147,18 @@ func (parent *Node) makeNode(title string, x int, y int) *Node {
return &node
}
-func (parent *Node) AddNode(title string) *Node {
+func (n *Node) AddNode(title string) *Node {
var node Node
node.Name = title
- node.Width = parent.Width
- node.Height = parent.Height
+ node.Width = n.Width
+ node.Height = n.Height
id := Config.prefix + strconv.Itoa(Config.counter)
Config.counter += 1
node.id = id
- parent.Append(&node)
- node.parent = parent
+ n.Append(&node)
+ node.parent = n
return &node
}