TABS: very reliable tab, window and node handling
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
934470d1a9
commit
9960652ec7
2
entry.go
2
entry.go
|
@ -12,7 +12,7 @@ import _ "github.com/andlabs/ui/winmanifest"
|
||||||
func (n *Node) NewLabel(text string) *Node {
|
func (n *Node) NewLabel(text string) *Node {
|
||||||
// make new node here
|
// make new node here
|
||||||
// n.Append(ui.NewLabel(text), false)
|
// n.Append(ui.NewLabel(text), false)
|
||||||
newNode := makeNode(n, text, 333, 334)
|
newNode := n.makeNode(text, 333, 334)
|
||||||
newNode.Dump()
|
newNode.Dump()
|
||||||
// panic("node.NewLabel()")
|
// panic("node.NewLabel()")
|
||||||
|
|
||||||
|
|
32
window.go
32
window.go
|
@ -2,7 +2,7 @@ package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"fmt"
|
// "fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/andlabs/ui"
|
"github.com/andlabs/ui"
|
||||||
|
@ -21,7 +21,7 @@ func (n *Node) ErrorWindow2(msg1 string, msg2 string) (*Node) {
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeNode(parent *Node, title string, x int, y int) *Node {
|
func initNode(title string, x int, y int) *Node {
|
||||||
var node Node
|
var node Node
|
||||||
node.Name = title
|
node.Name = title
|
||||||
node.Width = x
|
node.Width = x
|
||||||
|
@ -31,26 +31,18 @@ func makeNode(parent *Node, title string, x int, y int) *Node {
|
||||||
Config.counter += 1
|
Config.counter += 1
|
||||||
node.id = id
|
node.id = id
|
||||||
|
|
||||||
// panic("gui.makeNode() START")
|
|
||||||
if (parent == nil) {
|
|
||||||
if (Data.NodeMap[title] != nil) {
|
if (Data.NodeMap[title] != nil) {
|
||||||
log.Println("Duplicate window name =", title)
|
log.Println("Duplicate window name =", title)
|
||||||
// TODO: just change the 'title' to something unique
|
// TODO: just change the 'title' to something unique
|
||||||
panic(fmt.Sprintf("Duplicate window name = %s\n", title))
|
// panic(fmt.Sprintf("Duplicate window name = %s\n", title))
|
||||||
return nil
|
return Data.NodeMap[title]
|
||||||
}
|
}
|
||||||
// panic("gui.makeNode() before NodeMap()")
|
|
||||||
Data.NodeMap[title] = &node
|
Data.NodeMap[title] = &node
|
||||||
Data.NodeArray = append(Data.NodeArray, &node)
|
Data.NodeArray = append(Data.NodeArray, &node)
|
||||||
Data.NodeSlice = append(Data.NodeSlice, &node)
|
Data.NodeSlice = append(Data.NodeSlice, &node)
|
||||||
// panic("gui.makeNode() after NodeMap()")
|
|
||||||
return &node
|
return &node
|
||||||
} else {
|
// parent.Append(&node)
|
||||||
// panic("gui.makeNode() before Append()")
|
//node.parent = parent
|
||||||
parent.Append(&node)
|
|
||||||
// panic("gui.makeNode() after Append()")
|
|
||||||
}
|
|
||||||
node.parent = parent
|
|
||||||
return &node
|
return &node
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +96,7 @@ func (n *Node) uiNewWindow(title string, x int, y int) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func mapWindow(parent *Node, window *ui.Window, title string, x int, y int) *Node {
|
func mapWindow(parent *Node, window *ui.Window, title string, x int, y int) *Node {
|
||||||
log.Println("gui.WindowMap START title =", title)
|
log.Println("gui.WindowMap START title =", title)
|
||||||
|
|
||||||
|
@ -112,6 +105,7 @@ func mapWindow(parent *Node, window *ui.Window, title string, x int, y int) *Nod
|
||||||
|
|
||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// This routine creates a blank window with a Title and size (W x H)
|
// This routine creates a blank window with a Title and size (W x H)
|
||||||
//
|
//
|
||||||
|
@ -124,11 +118,13 @@ func NewWindow() *Node {
|
||||||
w := Config.Width
|
w := Config.Width
|
||||||
h := Config.Height
|
h := Config.Height
|
||||||
|
|
||||||
var n *Node
|
if (Data.NodeMap[title] != nil) {
|
||||||
n = mapWindow(nil, nil, title, w, h)
|
log.Println("Duplicate window name =", title)
|
||||||
// box := n.box
|
return Data.NodeMap[title]
|
||||||
// log.Println("gui.NewWindow() title = box.Name =", box.Name)
|
}
|
||||||
|
|
||||||
|
var n *Node
|
||||||
|
n = initNode(title, w, h)
|
||||||
n.uiNewWindow(title, w, h)
|
n.uiNewWindow(title, w, h)
|
||||||
window := n.uiWindow
|
window := n.uiWindow
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue