diff options
| -rw-r--r-- | new-structs.go | 20 | ||||
| -rw-r--r-- | structs.go | 2 | ||||
| -rw-r--r-- | window.go | 19 |
3 files changed, 32 insertions, 9 deletions
diff --git a/new-structs.go b/new-structs.go index df25cae..d6ff409 100644 --- a/new-structs.go +++ b/new-structs.go @@ -16,12 +16,13 @@ type Node struct { Height int children []*Node + box *GuiBox control *ui.Control window *ui.Window } -func (n Node) SetName(name string) { +func (n *Node) SetName(name string) { // n.uiType.SetName(name) if (n.window != nil) { log.Println("node is a window. setting title =", name) @@ -32,15 +33,30 @@ func (n Node) SetName(name string) { 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) { // return // } // n.uiType.Append(child, x) } +func (n *Node) List() { + findByIdDFS(n, "test") +} func findByIdDFS(node *Node, id string) *Node { + log.Println("findByIdDFS()", id, node) if node.id == id { + log.Println("Found node id =", id, node) return node } @@ -177,7 +177,7 @@ func (s GuiBox) InitTab(title string, custom func() ui.Control) *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 { return nil } @@ -146,10 +146,16 @@ func DeleteWindow(name string) { } } -func CreateWindow(title string, tabname string, x int, y int, custom func() ui.Control) *GuiBox { - box := CreateBlankWindow(title, x, y) - box.InitTab(title, custom) - return box +func CreateWindow(title string, tabname string, x int, y int, custom func() ui.Control) *Node { + n := CreateBlankWindow(title, x, y) + if (n.box == nil) { + 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 { @@ -177,12 +183,13 @@ func uiNewWindow(title string, x int, y int) *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) log.Println("gui.CreateBlankWindow() title = box.Name =", box.Name) n := uiNewWindow(box.Name, x, y) box.node = n + n.box = box window := n.window ui.OnShouldQuit(func() bool { @@ -192,7 +199,7 @@ func CreateBlankWindow(title string, x int, y int) *GuiBox { }) box.Window.UiWindow = window - return box + return n } func InitBlankWindow() ui.Control { |
