REFACTOR: moving around things in the rabbit hole
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
176cae3a80
commit
2c470f86c9
|
@ -16,7 +16,9 @@ func (n *Node) AddDemoTab(title string) {
|
|||
newNode.ListChildren(false)
|
||||
addDemoGroup(newNode, "new group 1")
|
||||
addDemoGroup(newNode, "new group 2")
|
||||
addDemoGroup(newNode, "new group 3")
|
||||
|
||||
groupNode := newNode.AddGroup("new group 3")
|
||||
groupNode.AddComboBox("testing", "foo", "man", "blah")
|
||||
}
|
||||
|
||||
func makeDemoTab() *ui.Box {
|
||||
|
@ -73,3 +75,53 @@ func addDemoGroup(n *Node, title string) {
|
|||
|
||||
vbox.Append(ecbox, false)
|
||||
}
|
||||
|
||||
func (n *Node) AddGroup(title string) *Node {
|
||||
hbox := n.uiBox
|
||||
if (hbox == nil) {
|
||||
return n
|
||||
}
|
||||
group := ui.NewGroup(title)
|
||||
group.SetMargined(true)
|
||||
hbox.Append(group, true)
|
||||
|
||||
vbox := ui.NewVerticalBox()
|
||||
vbox.SetPadded(true)
|
||||
group.SetChild(vbox)
|
||||
|
||||
newNode := n.AddNode(title)
|
||||
newNode.uiBox = vbox
|
||||
return newNode
|
||||
}
|
||||
|
||||
func (n *Node) GetText(title string) string {
|
||||
if (n.uiText != nil) {
|
||||
return n.uiText.Text()
|
||||
}
|
||||
return n.Name
|
||||
}
|
||||
|
||||
func (n *Node) AddComboBox(title string, s ...string) *Node {
|
||||
box := n.uiBox
|
||||
if (box == nil) {
|
||||
return n
|
||||
}
|
||||
|
||||
ecbox := ui.NewEditableCombobox()
|
||||
|
||||
for id, name := range s {
|
||||
log.Println("Adding Combobox Entry:", id, name)
|
||||
ecbox.Append(name)
|
||||
}
|
||||
|
||||
ecbox.OnChanged(func(*ui.EditableCombobox) {
|
||||
test := ecbox.Text()
|
||||
log.Println("text is now:", test)
|
||||
})
|
||||
|
||||
box.Append(ecbox, false)
|
||||
|
||||
newNode := n.AddNode(title)
|
||||
newNode.uiText = ecbox
|
||||
return newNode
|
||||
}
|
|
@ -22,14 +22,19 @@ func main() {
|
|||
|
||||
// This initializes the first window
|
||||
func initGUI() {
|
||||
gui.Config.Title = "WIT GUI Window Demo"
|
||||
gui.Config.Title = "WIT GUI Window Demo 1"
|
||||
gui.Config.Width = 640
|
||||
gui.Config.Height = 480
|
||||
gui.Config.Exit = myExit
|
||||
node1 := gui.NewWindow()
|
||||
node1.AddDemoTab("A Simple Tab Demo")
|
||||
|
||||
node := gui.NewWindow()
|
||||
node.AddDemoTab("A Simple Tab Demo")
|
||||
node.AddDemoAndlabsUiTab("A Simple andlabs/ui Tab Demo")
|
||||
gui.Config.Title = "WIT GUI Window Demo 2"
|
||||
gui.Config.Width = 640
|
||||
gui.Config.Height = 240
|
||||
gui.Config.Exit = myExit
|
||||
node2 := gui.NewWindow()
|
||||
node2.AddDemoAndlabsUiTab("A Simple andlabs/ui Tab Demo")
|
||||
}
|
||||
|
||||
// This demonstrates how to properly interact with the GUI
|
||||
|
|
|
@ -55,6 +55,7 @@ type Node struct {
|
|||
uiWindow *ui.Window
|
||||
uiTab *ui.Tab
|
||||
uiBox *ui.Box
|
||||
uiText *ui.EditableCombobox
|
||||
}
|
||||
|
||||
func (n *Node) Parent() *Node {
|
||||
|
|
17
window.go
17
window.go
|
@ -77,12 +77,12 @@ func (n *Node) Add(e Element) *Node {
|
|||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
//
|
||||
// Create a new node
|
||||
// if parent == nil, that means it is a new window and needs to be put
|
||||
// in the window map (aka Data.NodeMap)
|
||||
//
|
||||
/*
|
||||
func (parent *Node) addNode(title string) *Node {
|
||||
var node Node
|
||||
node.Name = title
|
||||
|
@ -147,6 +147,21 @@ func (parent *Node) makeNode(title string, x int, y int) *Node {
|
|||
return &node
|
||||
}
|
||||
|
||||
func (parent *Node) AddNode(title string) *Node {
|
||||
var node Node
|
||||
node.Name = title
|
||||
node.Width = parent.Width
|
||||
node.Height = parent.Height
|
||||
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue