DOCS: clean up variable names for node.*() functions

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2021-10-28 10:39:33 -05:00
parent 5e5df9630e
commit e5763fa317
3 changed files with 31 additions and 48 deletions

13
box.go
View File

@ -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
}

View File

@ -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)
*/
if (Config.DebugNode) {
fmt.Println("")
log.Println("parent:")
parent.Dump()
fmt.Println("")
log.Println("newNode:")
newNode.Dump()
}
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)
fmt.Println("")
log.Println("parent:")
parent.Dump()
fmt.Println("")
log.Println("newNode:")
newNode.Dump()
// panic("node.AddTabNode()")
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

View File

@ -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
}