summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--cmds/gui-demo/Makefile5
-rw-r--r--cmds/gui-demo/demo-window.go17
-rw-r--r--cmds/gui-demo/main.go68
-rw-r--r--cmds/gui-example/Makefile (renamed from gui-example/Makefile)0
-rw-r--r--cmds/gui-example/main.go (renamed from gui-example/main.go)0
-rw-r--r--debug-window.go2
-rw-r--r--demo-window.go6
-rw-r--r--new-structs.go2
9 files changed, 99 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index bb1e72d..1445c95 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
*.swp
-gui-example/gui-example
+cmds/gui-example/gui-example
+cmds/gui-demo/gui-demo
diff --git a/cmds/gui-demo/Makefile b/cmds/gui-demo/Makefile
new file mode 100644
index 0000000..2dbc808
--- /dev/null
+++ b/cmds/gui-demo/Makefile
@@ -0,0 +1,5 @@
+run: build
+ ./gui-demo
+
+build:
+ GO111MODULE="off" go build
diff --git a/cmds/gui-demo/demo-window.go b/cmds/gui-demo/demo-window.go
new file mode 100644
index 0000000..f0cfcce
--- /dev/null
+++ b/cmds/gui-demo/demo-window.go
@@ -0,0 +1,17 @@
+package main
+
+import "git.wit.org/wit/gui"
+
+func addDemoTab(n *gui.Node, title string) {
+ newNode := n.AddTab(title, nil)
+ if (gui.Config.Debug) {
+ newNode.Dump()
+ }
+ newNode.ListChildren(false)
+
+ groupNode1 := newNode.AddGroup("group 1")
+ groupNode1.AddComboBox("demoCombo1", "foo", "bar", "stuff")
+
+ groupNode2 := newNode.AddGroup("group 2")
+ groupNode2.AddComboBox("demoCombo2", "more 1", "more 2", "more 3")
+}
diff --git a/cmds/gui-demo/main.go b/cmds/gui-demo/main.go
new file mode 100644
index 0000000..372f2e2
--- /dev/null
+++ b/cmds/gui-demo/main.go
@@ -0,0 +1,68 @@
+package main
+
+import (
+ "log"
+ "os"
+ "time"
+
+ "git.wit.org/wit/gui"
+)
+
+// This initializes the first window
+//
+// Then starts a goroutine to demonstrate how to
+// inject things into the GUI
+func main() {
+ log.Println("Starting my Control Panel")
+
+ go gui.Main(initGUI)
+
+ watchGUI()
+}
+
+// This initializes the first window
+func initGUI() {
+ gui.Config.Title = "WIT GUI Window Demo 1"
+ gui.Config.Width = 640
+ gui.Config.Height = 480
+ gui.Config.Exit = myExit
+ node1 := gui.NewWindow()
+ addDemoTab(node1, "A Simple 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
+// You can not involke the GUI from external goroutines in most cases.
+func watchGUI() {
+ var i = 1
+ for {
+ log.Println("Waiting", i, "seconds")
+ i += 1
+ time.Sleep(1 * time.Second)
+ if i == 4 {
+ log.Println("Opening a Debug Window via the gui.Queue()")
+ gui.Config.Width = 800
+ gui.Config.Height = 300
+ gui.Config.Exit = myDebugExit
+ gui.Queue(gui.DebugWindow)
+ }
+ }
+}
+
+func myExit(n *gui.Node) {
+ log.Println()
+ log.Println("Entered myExit() on node.Name =", n.Name)
+ log.Println()
+ os.Exit(0)
+}
+
+func myDebugExit(n *gui.Node) {
+ log.Println("Entered myDebugExit() on node.Name =", n.Name)
+ log.Println("Don't actually os.Exit()")
+}
diff --git a/gui-example/Makefile b/cmds/gui-example/Makefile
index 5028ebd..5028ebd 100644
--- a/gui-example/Makefile
+++ b/cmds/gui-example/Makefile
diff --git a/gui-example/main.go b/cmds/gui-example/main.go
index 9fcb971..9fcb971 100644
--- a/gui-example/main.go
+++ b/cmds/gui-example/main.go
diff --git a/debug-window.go b/debug-window.go
index 61a7158..278aafb 100644
--- a/debug-window.go
+++ b/debug-window.go
@@ -238,6 +238,7 @@ func makeWindowDebug() *ui.Box {
}
})
+ /*
n1 = addButton(vbox, "Node.DemoTab")
n1.OnClicked(func(*ui.Button) {
y := nodeCombo.Selected()
@@ -248,6 +249,7 @@ func makeWindowDebug() *ui.Box {
node.AddDemoTab("ran gui.AddDemoTab() " + strconv.Itoa(Config.counter))
}
})
+ */
n1 = addButton(vbox, "Node.DemoAndlabsUiTab")
n1.OnClicked(func(*ui.Button) {
diff --git a/demo-window.go b/demo-window.go
index 2bde8b4..144f6ac 100644
--- a/demo-window.go
+++ b/demo-window.go
@@ -6,6 +6,7 @@ import _ "github.com/andlabs/ui/winmanifest"
var mybox *ui.Box
+/*
func (n *Node) AddDemoTab(title string) {
newNode := n.AddTab(title, makeDemoTab())
if (Config.DebugNode) {
@@ -16,7 +17,7 @@ func (n *Node) AddDemoTab(title string) {
newNode.ListChildren(false)
addDemoGroup(newNode, "new group 1")
addDemoGroup(newNode, "new group 2")
-
+
groupNode := newNode.AddGroup("new group 3")
groupNode.AddComboBox("testing", "foo", "man", "blah")
}
@@ -75,6 +76,7 @@ func addDemoGroup(n *Node, title string) {
vbox.Append(ecbox, false)
}
+*/
func (n *Node) AddGroup(title string) *Node {
hbox := n.uiBox
@@ -94,7 +96,7 @@ func (n *Node) AddGroup(title string) *Node {
return newNode
}
-func (n *Node) GetText(title string) string {
+func (n *Node) GetText(name string) string {
if (n.uiText != nil) {
return n.uiText.Text()
}
diff --git a/new-structs.go b/new-structs.go
index 858d50f..8c190a3 100644
--- a/new-structs.go
+++ b/new-structs.go
@@ -240,12 +240,12 @@ func (parent *Node) AddTab(title string, uiC *ui.Box) *Node {
uiC = hbox
}
tab.Append(title, uiC)
- tab.SetMargined(0, true)
// panic("gui.AddTab() before makeNode()")
newNode := parent.makeNode(title, 555, 600 + Config.counter)
newNode.uiTab = tab
newNode.uiBox = uiC
// panic("gui.AddTab() after makeNode()")
+ tabSetMargined(newNode.uiTab)
return newNode
}