From 3a94b27b6308b41f54753b5ae0e38ed97837e440 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 3 Jun 2019 12:56:33 -0700 Subject: better display and debugging Signed-off-by: Jeff Carr --- debug.go | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'debug.go') diff --git a/debug.go b/debug.go index 42937d1..9d862bc 100644 --- a/debug.go +++ b/debug.go @@ -20,24 +20,8 @@ func WatchGUI() { for { if (count > 20) { log.Println("Sleep() in watchGUI()") - for i, window := range Data.Windows { - log.Println("watchGUI() Data.Windows", i, "Name =", window.Name) - for name, abox := range window.BoxMap { - log.Printf("\twatchGUI() BOX mapname=%-12s abox.Name=%-12s", name, abox.Name) - /* - if (name == "DEBUG") { - log.Println("\t\twatchGUI() BOX abox =", reflect.TypeOf(abox)) - win := abox.Window - log.Println("\t\twatchGUI() BOX win =", reflect.TypeOf(win)) - area := win.Area - log.Println("\t\twatchGUI() BOX area =", reflect.TypeOf(area), area.UiArea) - // spew.Dump(area.UiArea) - // area.UiArea.Show() - // time.Sleep(2000 * time.Millisecond) - // os.Exit(0) - } - */ - } + if (Config.Debug) { + DumpBoxes() } count = 0 } @@ -46,6 +30,28 @@ func WatchGUI() { } } +func DumpBoxes() { + for i, window := range Data.Windows { + log.Println("watchGUI() Data.Windows", i, "Name =", window.Name) + for name, abox := range window.BoxMap { + log.Printf("\twatchGUI() BOX mapname=%-12s abox.Name=%-12s", name, abox.Name) + /* + if (name == "DEBUG") { + log.Println("\t\twatchGUI() BOX abox =", reflect.TypeOf(abox)) + win := abox.Window + log.Println("\t\twatchGUI() BOX win =", reflect.TypeOf(win)) + area := win.Area + log.Println("\t\twatchGUI() BOX area =", reflect.TypeOf(area), area.UiArea) + // spew.Dump(area.UiArea) + // area.UiArea.Show() + // time.Sleep(2000 * time.Millisecond) + // os.Exit(0) + } + */ + } + } +} + func addTableTab() { var parts []TableColumnData -- cgit v1.2.3 From 50c6e6c07d12841370a0830d79a7b74b974a20f8 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 3 Jun 2019 15:45:40 -0700 Subject: make a WindowMap to track which windows exist Signed-off-by: Jeff Carr --- debug.go | 7 +++++-- gui.go | 14 ++++++++++++-- structs.go | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) (limited to 'debug.go') diff --git a/debug.go b/debug.go index 9d862bc..89ac686 100644 --- a/debug.go +++ b/debug.go @@ -31,10 +31,13 @@ func WatchGUI() { } func DumpBoxes() { + for name, window := range Data.WindowMap { + log.Println("gui.DumpBoxes() Data.WindowMap name =", name, "Window.Name =", window.Name) + } for i, window := range Data.Windows { - log.Println("watchGUI() Data.Windows", i, "Name =", window.Name) + log.Println("gui.DumpBoxes() Data.Windows", i, "Name =", window.Name) for name, abox := range window.BoxMap { - log.Printf("\twatchGUI() BOX mapname=%-12s abox.Name=%-12s", name, abox.Name) + log.Printf("gui.DumpBoxes() \tBOX mapname=%-12s abox.Name=%-12s", name, abox.Name) /* if (name == "DEBUG") { log.Println("\t\twatchGUI() BOX abox =", reflect.TypeOf(abox)) diff --git a/gui.go b/gui.go index e54517c..ef1ff49 100644 --- a/gui.go +++ b/gui.go @@ -12,6 +12,8 @@ const Yaxis = 1 // box that is vertical func GuiInit() { Data.buttonMap = make(map[*ui.Button]*GuiButton) + Data.WindowMap = make(map[string]*GuiWindow) + ui.OnShouldQuit(func() bool { ui.Quit() return true @@ -29,8 +31,16 @@ func InitGuiWindow(name string, gw *GuiWindow) *GuiWindow { newGuiWindow.UiTab = gw.UiTab newGuiWindow.BoxMap = make(map[string]*GuiBox) newGuiWindow.EntryMap = make(map[string]*GuiEntry) - newGuiWindow.EntryMap["test"] = nil - Data.Windows = append(Data.Windows, &newGuiWindow) + Data.Windows = append(Data.Windows, &newGuiWindow) + + if (Data.WindowMap == nil) { + log.Println("gui.InitGuiWindow() making the Data.WindowMap here") + Data.WindowMap = make(map[string]*GuiWindow) + } + Data.WindowMap[name] = &newGuiWindow + + // make a blank entry for testing + // newGuiWindow.EntryMap["test"] = nil if (Data.buttonMap == nil) { GuiInit() diff --git a/structs.go b/structs.go index a074e56..aae0b7f 100644 --- a/structs.go +++ b/structs.go @@ -29,6 +29,7 @@ type GuiData struct { // A map of all the entry boxes AllEntries []*GuiEntry Windows []*GuiWindow + WindowMap map[string]*GuiWindow // A map of all buttons everywhere on all // windows, all tabs, across all goroutines -- cgit v1.2.3 From 70779ab33b662d3e7849133f57521c2ce217bf96 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 3 Jun 2019 17:05:50 -0700 Subject: fixes for debugging Signed-off-by: Jeff Carr --- debug.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'debug.go') diff --git a/debug.go b/debug.go index 89ac686..1a20532 100644 --- a/debug.go +++ b/debug.go @@ -3,11 +3,11 @@ package gui import "log" import "time" import "fmt" -// import "reflect" +import "reflect" // import "github.com/andlabs/ui" // import _ "github.com/andlabs/ui/winmanifest" -// import "github.com/davecgh/go-spew/spew" +import "github.com/davecgh/go-spew/spew" // import pb "git.wit.com/wit/witProtobuf" // @@ -32,7 +32,16 @@ func WatchGUI() { func DumpBoxes() { for name, window := range Data.WindowMap { - log.Println("gui.DumpBoxes() Data.WindowMap name =", name, "Window.Name =", window.Name) + log.Println("gui.DumpBoxes()", name) + log.Println("gui.DumpBoxes()\tWindow.name =", window.Name) + log.Println("gui.DumpBoxes()\tWindow.UiWindow type =", reflect.TypeOf(window.UiWindow)) + log.Println("gui.DumpBoxes()\tWindow.UiWindow =", window.UiWindow) + if (window.UiTab != nil) { + log.Println("gui.DumpBoxes()\tWindow.UiTab type =", reflect.TypeOf(window.UiTab)) + log.Println("gui.DumpBoxes()\tWindow.UiTab =", window.UiTab) + log.Println("gui.DumpBoxes()\tWindow.UiTab.NumPages() =", window.UiTab.NumPages()) + spew.Dump(window.UiTab) + } } for i, window := range Data.Windows { log.Println("gui.DumpBoxes() Data.Windows", i, "Name =", window.Name) -- cgit v1.2.3