NODE: going down a rabbit hole

This commit is contained in:
Jeff Carr 2021-10-08 10:22:38 -05:00
parent 3cdc585913
commit 7d5b353f0d
3 changed files with 44 additions and 3 deletions

32
box.go
View File

@ -64,6 +64,38 @@ func add(box *GuiBox, newbox *GuiBox) {
log.Println("gui.add() END")
}
func (n *Node) NewBox(axis int, name string) *Node {
var newBox *GuiBox
var newNode *Node = n
newBox = new(GuiBox)
// newBox.Window = newNode.uiWindow
newBox.Name = name
if (n.box == nil) {
panic("node.newBox() box == nil")
}
if (n.box == nil) {
// add a box here
newBox.node = n
n.box = newBox
} else {
// make a new box & a new node
newNode = makeNode(n, name, 111, 112)
}
var uiBox *ui.Box
if (axis == Xaxis) {
uiBox = ui.NewHorizontalBox()
} else {
uiBox = ui.NewVerticalBox()
}
uiBox.SetPadded(true)
newBox.UiBox = uiBox
add(n.box, newBox)
return newNode
}
func NewBox(box *GuiBox, axis int, name string) *GuiBox {
log.Println("gui.NewBox() START")
n := box.FindNode()

View File

@ -2,7 +2,7 @@ package gui
import (
"log"
"time"
// "time"
// "github.com/davecgh/go-spew/spew"
@ -88,7 +88,7 @@ func (n *Node) Append(child *Node) {
child.Dump()
log.Println("parent node:")
n.Dump()
time.Sleep(3 * time.Second)
// time.Sleep(3 * time.Second)
}
func (n *Node) List() {

View File

@ -96,9 +96,11 @@ func InitWindow(parent *Node, gw *GuiWindow, name string, axis int) *Node {
newGuiWindow.UiWindow.SetMargined(true)
tmp := 0
newGuiWindow.TabNumber = &tmp
node.uiTab = newGuiWindow.UiTab
} else {
newGuiWindow.UiWindow = gw.UiWindow
newGuiWindow.UiTab = gw.UiTab
node.uiTab = newGuiWindow.UiTab
}
newGuiWindow.BoxMap = make(map[string]*GuiBox)
@ -111,6 +113,9 @@ func InitWindow(parent *Node, gw *GuiWindow, name string, axis int) *Node {
} else {
tabnum := newGuiWindow.UiTab.NumPages()
newGuiWindow.TabNumber = &tabnum
if (node.uiTab == nil) {
node.uiTab = newGuiWindow.UiTab
}
}
Data.WindowMap[newGuiWindow.Name] = newGuiWindow
@ -158,7 +163,10 @@ func InitWindow(parent *Node, gw *GuiWindow, name string, axis int) *Node {
log.Println("InitWindow() node.box != box. Hmmm....")
panic(-1)
}
// panic("InitWindow")
if (node.uiTab == nil) {
// DebugNodeChildren()
// panic("node.uiTab = nil")
}
return node
}
@ -316,6 +324,7 @@ func mapWindow(parent *Node, window *ui.Window, title string, x int, y int) *Nod
// func makeNode(parent *Node, title string, x int, y int) *Node {
node := makeNode(parent, title, x, y)
node.box = &box
node.uiWindow = window
box.node = node
newGuiWindow.BoxMap["jcarrInitTest"] = &box