diff options
| author | Jeff Carr <[email protected]> | 2021-10-27 16:31:54 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2021-10-27 16:31:54 -0500 |
| commit | 81c44bce5313d4415a0fa062ececc4547832d66d (patch) | |
| tree | 050d019f1f80587d9112a1a7d18e6994707fd7dc | |
| parent | 10e13423db08e282a1f41c2f38f348d630cfca96 (diff) | |
REFACTOR: moving around things in the rabbit hole
Signed-off-by: Jeff Carr <[email protected]>
| -rw-r--r-- | debug-window.go (renamed from window-debug.go) | 0 | ||||
| -rw-r--r-- | demo-window-andlabs-ui.go (renamed from window-demo-andlabs-ui.go) | 0 | ||||
| -rw-r--r-- | demo-window.go (renamed from window-demo.go) | 54 | ||||
| -rw-r--r-- | gui-example/main.go | 13 | ||||
| -rw-r--r-- | new-structs.go | 1 | ||||
| -rw-r--r-- | window.go | 17 |
6 files changed, 79 insertions, 6 deletions
diff --git a/window-debug.go b/debug-window.go index 61a7158..61a7158 100644 --- a/window-debug.go +++ b/debug-window.go diff --git a/window-demo-andlabs-ui.go b/demo-window-andlabs-ui.go index 806dc14..806dc14 100644 --- a/window-demo-andlabs-ui.go +++ b/demo-window-andlabs-ui.go diff --git a/window-demo.go b/demo-window.go index 92e89e8..2bde8b4 100644 --- a/window-demo.go +++ b/demo-window.go @@ -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 +} diff --git a/gui-example/main.go b/gui-example/main.go index 2b8cc39..9fcb971 100644 --- a/gui-example/main.go +++ b/gui-example/main.go @@ -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 diff --git a/new-structs.go b/new-structs.go index 92933ed..858d50f 100644 --- a/new-structs.go +++ b/new-structs.go @@ -55,6 +55,7 @@ type Node struct { uiWindow *ui.Window uiTab *ui.Tab uiBox *ui.Box + uiText *ui.EditableCombobox } func (n *Node) Parent() *Node { @@ -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) |
