diff options
| -rw-r--r-- | find.go | 35 | ||||
| -rw-r--r-- | gui-example/main.go | 9 | ||||
| -rw-r--r-- | gui.go | 2 | ||||
| -rw-r--r-- | main.go | 14 | ||||
| -rw-r--r-- | window-debug.go | 39 | ||||
| -rw-r--r-- | window-demo.go (renamed from window-template.go) | 0 |
6 files changed, 56 insertions, 43 deletions
@@ -0,0 +1,35 @@ +package gui + +import ( + "log" + +// "github.com/andlabs/ui" +// _ "github.com/andlabs/ui/winmanifest" +// "github.com/davecgh/go-spew/spew" +) + + +func FindWindow(s string) *GuiWindow { + for name, window := range Data.WindowMap { + if name == s { + return window + } + } + log.Printf("COULD NOT FIND WINDOW", s) + return nil +} + +func FindBox(s string) *GuiBox { + for name, window := range Data.WindowMap { + if name != s { + continue + } + for name, abox := range window.BoxMap { + log.Printf("gui.DumpBoxes() \tBOX mapname=%-12s abox.Name=%-12s", name, abox.Name) + return abox + } + log.Println("gui.FindBox() NEED TO INIT WINDOW name =", name) + } + log.Println("gui.FindBox() COULD NOT FIND BOX", s) + return nil +} diff --git a/gui-example/main.go b/gui-example/main.go index 69f3172..c9e8cbd 100644 --- a/gui-example/main.go +++ b/gui-example/main.go @@ -26,10 +26,13 @@ func main() { } func initGUI() { - n := gui.NewWindow("jcarr start", 640, 480) - n.AddDemoTab("up the rabbit hole") + n := gui.NewWindow("WIT GUI Example Window", 640, 480) + n.AddDemoTab("A Simple 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 { @@ -37,7 +40,7 @@ func watchGUI() { i += 1 time.Sleep(1 * time.Second) if i == 4 { - log.Println("Sending ExampleWindow to gui.Queue()") + log.Println("Opening a Debug Window via the gui.Queue()") gui.Queue(gui.DebugWindow) } } @@ -23,7 +23,7 @@ func init() { Data.NodeSlice = make([]*Node, 0) Config.counter = 0 - Config.prefix = "jwc" + Config.prefix = "wit" Config.DebugNode = false Config.DebugTabs = false } @@ -40,17 +40,3 @@ func ExampleWindow() { window.UiWindow.Show() } - -func DebugWindow() { - log.Println("START gui.ExampleWindow()") - - title := "Debug Window" - node := InitWindow(nil, nil, title, 0) - box := node.box - window := box.Window - log.Println("box =", box) - log.Println("window =", window) - node.AddDebugTab("jcarr Debug") - - window.UiWindow.Show() -} diff --git a/window-debug.go b/window-debug.go index 3afe8e3..69eb7bb 100644 --- a/window-debug.go +++ b/window-debug.go @@ -11,6 +11,20 @@ import ( var names = make([]string, 100) var nodeNames = make([]string, 100) +func DebugWindow() { + log.Println("START gui.DebugWindow()") + + title := "WIT GUI Debug Window" + node := InitWindow(nil, nil, title, 0) + box := node.box + window := box.Window + log.Println("box =", box) + log.Println("window =", window) + node.AddDebugTab("WIT GUI Debug Tab") + + window.UiWindow.Show() +} + // TODO: remove this crap // What does this actually do? // It populates the nodeNames in a map. No, not a map, an array. What is the difference again? @@ -278,31 +292,6 @@ func addGroup(b *ui.Box, name string) *ui.Box { return vbox } -func FindWindow(s string) *GuiWindow { - for name, window := range Data.WindowMap { - if name == s { - return window - } - } - log.Printf("COULD NOT FIND WINDOW", s) - return nil -} - -func FindBox(s string) *GuiBox { - for name, window := range Data.WindowMap { - if name != s { - continue - } - for name, abox := range window.BoxMap { - log.Printf("gui.DumpBoxes() \tBOX mapname=%-12s abox.Name=%-12s", name, abox.Name) - return abox - } - log.Println("gui.FindBox() NEED TO INIT WINDOW name =", name) - } - log.Println("gui.FindBox() COULD NOT FIND BOX", s) - return nil -} - func dumpBox(s string) { var name string var window *GuiWindow diff --git a/window-template.go b/window-demo.go index 82162dd..82162dd 100644 --- a/window-template.go +++ b/window-demo.go |
