NODE: continued work on implementing a node tree
This commit is contained in:
parent
a3c0cc390c
commit
e4446ea51a
|
@ -16,12 +16,13 @@ type Node struct {
|
||||||
Height int
|
Height int
|
||||||
|
|
||||||
children []*Node
|
children []*Node
|
||||||
|
box *GuiBox
|
||||||
|
|
||||||
control *ui.Control
|
control *ui.Control
|
||||||
window *ui.Window
|
window *ui.Window
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n Node) SetName(name string) {
|
func (n *Node) SetName(name string) {
|
||||||
// n.uiType.SetName(name)
|
// n.uiType.SetName(name)
|
||||||
if (n.window != nil) {
|
if (n.window != nil) {
|
||||||
log.Println("node is a window. setting title =", name)
|
log.Println("node is a window. setting title =", name)
|
||||||
|
@ -32,15 +33,30 @@ func (n Node) SetName(name string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n Node) Append(child Node) {
|
func (n *Node) FindWindowBox() *GuiBox {
|
||||||
|
if (n.box == nil) {
|
||||||
|
log.Println("SERIOUS ERROR n.box == nil in FindWindowBox()")
|
||||||
|
log.Println("SERIOUS ERROR n.box == nil in FindWindowBox()")
|
||||||
|
log.Println("SERIOUS ERROR n.box == nil in FindWindowBox()")
|
||||||
|
log.Println("SERIOUS ERROR n.box == nil in FindWindowBox()")
|
||||||
|
}
|
||||||
|
return n.box
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *Node) Append(child Node) {
|
||||||
// if (n.UiBox == nil) {
|
// if (n.UiBox == nil) {
|
||||||
// return
|
// return
|
||||||
// }
|
// }
|
||||||
// n.uiType.Append(child, x)
|
// n.uiType.Append(child, x)
|
||||||
}
|
}
|
||||||
|
func (n *Node) List() {
|
||||||
|
findByIdDFS(n, "test")
|
||||||
|
}
|
||||||
|
|
||||||
func findByIdDFS(node *Node, id string) *Node {
|
func findByIdDFS(node *Node, id string) *Node {
|
||||||
|
log.Println("findByIdDFS()", id, node)
|
||||||
if node.id == id {
|
if node.id == id {
|
||||||
|
log.Println("Found node id =", id, node)
|
||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -177,7 +177,7 @@ func (s GuiBox) InitTab(title string, custom func() ui.Control) *Node {
|
||||||
return s.node
|
return s.node
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s GuiBox) AddTab(title string, custom ui.Control) *ui.Tab {
|
func (s *GuiBox) AddTab(title string, custom ui.Control) *ui.Tab {
|
||||||
if s.Window == nil {
|
if s.Window == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
19
window.go
19
window.go
|
@ -146,10 +146,16 @@ func DeleteWindow(name string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateWindow(title string, tabname string, x int, y int, custom func() ui.Control) *GuiBox {
|
func CreateWindow(title string, tabname string, x int, y int, custom func() ui.Control) *Node {
|
||||||
box := CreateBlankWindow(title, x, y)
|
n := CreateBlankWindow(title, x, y)
|
||||||
box.InitTab(title, custom)
|
if (n.box == nil) {
|
||||||
return box
|
log.Println("SERIOUS ERROR n.box == nil in CreateWindow()")
|
||||||
|
log.Println("SERIOUS ERROR n.box == nil in CreateWindow()")
|
||||||
|
log.Println("SERIOUS ERROR n.box == nil in CreateWindow()")
|
||||||
|
log.Println("SERIOUS ERROR n.box == nil in CreateWindow()")
|
||||||
|
}
|
||||||
|
n.box.InitTab(title, custom)
|
||||||
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
func uiNewWindow(title string, x int, y int) *Node {
|
func uiNewWindow(title string, x int, y int) *Node {
|
||||||
|
@ -177,12 +183,13 @@ func uiNewWindow(title string, x int, y int) *Node {
|
||||||
return &node
|
return &node
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateBlankWindow(title string, x int, y int) *GuiBox {
|
func CreateBlankWindow(title string, x int, y int) *Node {
|
||||||
box := mapWindow(nil, title, x, y)
|
box := mapWindow(nil, title, x, y)
|
||||||
log.Println("gui.CreateBlankWindow() title = box.Name =", box.Name)
|
log.Println("gui.CreateBlankWindow() title = box.Name =", box.Name)
|
||||||
|
|
||||||
n := uiNewWindow(box.Name, x, y)
|
n := uiNewWindow(box.Name, x, y)
|
||||||
box.node = n
|
box.node = n
|
||||||
|
n.box = box
|
||||||
window := n.window
|
window := n.window
|
||||||
|
|
||||||
ui.OnShouldQuit(func() bool {
|
ui.OnShouldQuit(func() bool {
|
||||||
|
@ -192,7 +199,7 @@ func CreateBlankWindow(title string, x int, y int) *GuiBox {
|
||||||
})
|
})
|
||||||
|
|
||||||
box.Window.UiWindow = window
|
box.Window.UiWindow = window
|
||||||
return box
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitBlankWindow() ui.Control {
|
func InitBlankWindow() ui.Control {
|
||||||
|
|
Loading…
Reference in New Issue