NODE: walking around in the rabbit hole

This commit is contained in:
Jeff Carr 2021-10-09 07:13:58 -05:00
parent 3d6e0e5518
commit da16b8106c
5 changed files with 39 additions and 70 deletions

30
box.go
View File

@ -72,25 +72,18 @@ 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
func (parent *Node) NewBox(axis int, name string) *Node {
if (parent.box == nil) {
panic("gui.Node.NewBox() parent.box == nil")
}
newBox = new(GuiBox)
// newBox.Window = newNode.uiWindow
newBox := new(GuiBox)
newBox.Window = parent.window
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)
}
// make a new box & a new node
newNode := parent.makeNode(name, 111, 100 + Config.counter)
Config.counter += 1
var uiBox *ui.Box
if (axis == Xaxis) {
@ -100,7 +93,10 @@ func (n *Node) NewBox(axis int, name string) *Node {
}
uiBox.SetPadded(true)
newBox.UiBox = uiBox
add(n.box, newBox)
newNode.uiBox = uiBox
parent.Append(newNode)
// add(n.box, newBox)
return newNode
}

View File

@ -34,7 +34,7 @@ func watchGUI() {
for {
log.Println("Waiting for customExit()", i)
i += 1
time.Sleep(3 * time.Second)
time.Sleep(1 * time.Second)
if i == 2 {
log.Println("Sending ExampleWindow to gui.Queue()")
gui.Queue(gui.DebugWindow)

View File

@ -47,11 +47,13 @@ type Node struct {
parent *Node
children []*Node
window *GuiWindow
box *GuiBox
uiControl *ui.Control
uiWindow *ui.Window
uiTab *ui.Tab
uiBox *ui.Box
}
func (n *Node) Parent() *Node {
@ -67,12 +69,17 @@ func (n *Node) Dump() {
log.Println("gui.Node.Dump() Name = ", n.Name)
log.Println("gui.Node.Dump() Width = ", n.Width)
log.Println("gui.Node.Dump() Height = ", n.Height)
log.Println("gui.Node.Dump() parent = ", n.parent)
log.Println("gui.Node.Dump() children = ", n.children)
log.Println("gui.Node.Dump() window = ", n.window)
log.Println("gui.Node.Dump() box = ", n.box)
log.Println("gui.Node.Dump() uiControl = ", n.uiControl)
log.Println("gui.Node.Dump() uiWindow = ", n.uiWindow)
log.Println("gui.Node.Dump() uiTab = ", n.uiTab)
log.Println("gui.Node.Dump() uiBox = ", n.uiBox)
log.Println("gui.Node.Dump() uiControl = ", n.uiControl)
if (n.id == "") {
panic("gui.Node.Dump() id == nil")
}
@ -197,30 +204,6 @@ func findByName(node *Node, name string) *Node {
return nil
}
/*
func (parent *Node) InitTab(title string) *Node {
if parent.uiWindow == nil {
parent.Dump()
panic("gui.InitTab() ERROR ui.Window == nil")
}
if parent.box == nil {
parent.Dump()
panic("gui.InitTab() ERROR box == nil")
}
tab := ui.NewTab()
parent.uiWindow.SetChild(tab)
parent.uiWindow.SetMargined(true)
parent.uiTab = tab
tab.Append(title, initBlankWindow())
tab.SetMargined(0, true)
newNode := makeNode(parent, title, 555, 600 + Config.counter)
return newNode
}
*/
func (parent *Node) AddTab(title string) *Node {
if parent.uiWindow == nil {
parent.Dump()
@ -246,7 +229,7 @@ func (parent *Node) AddTab(title string) *Node {
tab.Append(title, initBlankWindow())
tab.SetMargined(0, true)
newNode := makeNode(parent, title, 555, 600 + Config.counter)
newNode := parent.makeNode(title, 555, 600 + Config.counter)
newNode.uiTab = tab
return newNode
}

View File

@ -186,32 +186,6 @@ func (s GuiBox) Append(child ui.Control, x bool) {
s.UiBox.Append(child, x)
}
/*
func (s GuiBox) InitTab(title string, custom func() ui.Control) *Node {
if s.Window == nil {
return nil
}
if s.Window.UiWindow == nil {
return nil
}
window := s.Window.UiWindow
tab := ui.NewTab()
window.SetChild(tab)
window.SetMargined(true)
tab.Append(title, custom())
tab.SetMargined(0, true)
// tab.SetMargined(1, true)
s.Window.UiTab = tab
if s.node == nil {
log.Println("Fuck node = ", s.node)
os.Exit(-1)
}
return s.node
}
*/
func (s *GuiBox) AddTab(title string, custom ui.Control) *ui.Tab {
if s.Window == nil {

View File

@ -20,6 +20,7 @@ func initUI(name string, callback func(*GuiBox) *GuiBox) {
box := node.box
box = callback(box)
window := box.Window
node.window = window
log.Println("StartNewWindow() box =", box)
window.UiWindow.Show()
@ -271,6 +272,21 @@ func makeNode(parent *Node, title string, x int, y int) *Node {
return &node
}
func (parent *Node) makeNode(title string, x int, y int) *Node {
var node Node
node.Name = title
node.Width = x
node.Height = y
id := Config.prefix + strconv.Itoa(Config.counter)
Config.counter += 1
node.id = id
parent.Append(&node)
node.parent = parent
return &node
}
func (n *Node) uiNewWindow(title string, x int, y int) {
w := ui.NewWindow(title, x, y, false)
w.SetBorderless(false)