make a WindowMap to track which windows exist

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-06-03 15:45:40 -07:00
parent 7ec7fd15c0
commit 8d9f0b6a34
3 changed files with 18 additions and 4 deletions

View File

@ -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))

14
gui.go
View File

@ -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()

View File

@ -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