diff --git a/mainCloudBox.go b/mainCloudBox.go index 7f5559a..2863396 100644 --- a/mainCloudBox.go +++ b/mainCloudBox.go @@ -3,6 +3,7 @@ package gui import "log" import "time" import "regexp" +import "reflect" import "github.com/andlabs/ui" import _ "github.com/andlabs/ui/winmanifest" @@ -210,7 +211,7 @@ func ShowMainTab(wm *WindowMap) { wm.T.SetMargined(0, true) } -func StartNewWindow(c *pb.Config, action string) { +func StartNewWindow(c *pb.Config, bg bool, action string) { log.Println("InitNewWindow() Create a new window") var newWindowMap WindowMap newWindowMap.C = c @@ -226,10 +227,21 @@ func StartNewWindow(c *pb.Config, action string) { for i, aWM := range(Data.Windows) { log.Println(aWM) if (aWM.W == nil) { - log.Println("ShowWindow() THIS WINDOW IS NOT YET SHOWN") + log.Println("ShowWindow() THIS WINDOW IS NOT YET SHOWN i=", i) + log.Println("ShowWindow() THIS WINDOW IS NOT YET SHOWN aWM=", reflect.TypeOf(aWM)) // Data.NewWindow = &aWM - Data.NewWindow = i - ui.Main(InitWindow) + // Data.NewWindow = i + // ui.Main(InitWindow) + time.Sleep(200 * time.Millisecond) + if (bg) { + ui.Main(func() { + InitWindow(Data.Windows[i], i) + }) + } else { + ui.Main(func() { + InitWindow(Data.Windows[i], i) + }) + } return } } @@ -242,8 +254,10 @@ func getSplashText() *ui.AttributedString { } -func InitWindow() { - i := Data.NewWindow +func InitWindow(wm *WindowMap, i int) { + log.Println("InitWindow() THIS WINDOW IS NOT YET SHOWN") + // i := Data.NewWindow + log.Println("InitWindow() THIS WINDOW IS NOT YET SHOWN i=", i) c := Data.Windows[i].C Data.Windows[i].W = ui.NewWindow("", int(c.Width), int(c.Height), true) @@ -257,7 +271,8 @@ func InitWindow() { Data.AllButtons = append(Data.AllButtons, newBM) Data.Windows[i].W.OnClosing(func(*ui.Window) bool { - mouseClick(&newBM) + log.Println("InitWindow() OnClosing() THIS WINDOW IS CLOSING i=", i) + // mouseClick(&newBM) ui.Quit() return true }) diff --git a/structs.go b/structs.go index 2b9bdc9..f094a55 100644 --- a/structs.go +++ b/structs.go @@ -13,9 +13,9 @@ import pb "git.wit.com/wit/witProtobuf" // If you need cross platform support, these might only // be the safe way to interact with the GUI // -var Data GuiDataStructure +var Data GuiData -type GuiDataStructure struct { +type GuiData struct { State string Width int Height int @@ -48,15 +48,7 @@ type GuiDataStructure struct { // A map of all the entry boxes AllEntries []EntryMap - // a VM (maybe the one the user is playing with?) - // if opening a new window, this is a trick to - // pass it in - CurrentVM *pb.Event_VM - Windows []*WindowMap - NewWindow int -// Window1 *WindowMap - Window2 *WindowMap EntryNick *ui.Entry EntryUser *ui.Entry @@ -97,7 +89,6 @@ type WindowMap struct { C *pb.Config AH *AreaHandler -// AreaText *ui.AttributedString Action string } diff --git a/vmBox.go b/vmBox.go index 3059faf..2c79e58 100644 --- a/vmBox.go +++ b/vmBox.go @@ -45,7 +45,7 @@ func ShowVM() { */ func AddVmConfigureTab(wm *WindowMap, name string, pbVM *pb.Event_VM) { - CreateVmBox(wm, wm.T, Data.CurrentVM) + CreateVmBox(wm, wm.T, pbVM) } func CreateVmBox(wm *WindowMap, tab *ui.Tab, vm *pb.Event_VM) { @@ -84,7 +84,7 @@ func CreateVmBox(wm *WindowMap, tab *ui.Tab, vm *pb.Event_VM) { hboxButtons.Append(CreateButton(wm, nil, vm, "Save", "SAVE", nil), false) hboxButtons.Append(CreateButton(wm, nil, vm, "Done", "DONE", nil), false) - AddBoxToTab(Data.CurrentVM.Name, tab, vbox) + AddBoxToTab(vm.Name, tab, vbox) } func createAddVmBox(wm *WindowMap, tab *ui.Tab, name string, b *ButtonMap) {