large change to map the window

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-29 20:04:45 -07:00
parent 940591bb87
commit 9cd895db6e
2 changed files with 48 additions and 26 deletions

49
main.go
View File

@ -144,11 +144,14 @@ func main() {
// make this the main loop in an attempt to figure out the crashes
// do not change this until the GUI is stable
gui.Data.Window1 = new(gui.WindowMap)
gui.Data.Window1.AreaText = getSplashText()
gui.InitNewWindow(config, "SPLASH")
gui.ShowWindow()
// gui.Data.Window1 = new(gui.WindowMap)
// gui.Data.Window1.AreaText = getSplashText()
// this crashes here. crazy!
// gui.Data.Window1.AreaText = getNEWTEXT()
gui.GoMainWindow()
// gui.GoMainWindow()
}
// This is the handler for all mosue clicks (buttons, areas, etc))
@ -171,15 +174,19 @@ func mainMouseClick(b *gui.ButtonMap) {
log.Println("mainMouseClick() b.Action =", b.Account)
spew.Dump(b.Account)
var wm *gui.WindowMap
wm = b.WM
// gui.Data.Current = b.Account
log.Println("mainMouseClick() BACK IN CONTROL PANEL CODE")
if (b.Account != nil) {
log.Println("\tmainMouseClick() setting current account = ", b.Account.Nick)
}
if (b.Action == "NEWTEXT") {
gui.Data.Window1.AH.Attrstr = getNEWTEXT()
log.Println("AH.Attrstr = ", gui.Data.Window1.AH.Attrstr)
gui.Data.Window1.AH.Area.QueueRedrawAll()
wm.AH.Attrstr = getNEWTEXT()
log.Println("AH.Attrstr = ", wm.AH.Attrstr)
wm.AH.Area.QueueRedrawAll()
} else if (b.Action == "AREA") {
if (config == nil) {
log.Println("gui.State = splash BUT SOMETHING HAS GONE VERY WRONG")
@ -197,23 +204,25 @@ func mainMouseClick(b *gui.ButtonMap) {
}
}
if (gui.Data.State == "splash") {
gui.ShowAccountQuestionTab()
gui.ShowAccountQuestionTab(wm)
gui.Data.State = "account1"
return
}
if (gui.Data.State == "main") {
gui.ShowMainTab()
log.Println("gui.Data.State == main b =", b)
log.Println("gui.Data.State == main wm =", wm)
gui.ShowMainTab(wm)
gui.Data.State = "done"
return
} else if (gui.Data.State == "account1") {
gui.ShowAccountTab(0)
gui.ShowAccountTab(wm, 0)
gui.Data.State = "main"
return
}
} else if (b.Action == "ADD TAB") {
log.Println("\tADD TAB TRY b.Action = ", b.Action)
log.Println("\tADD TAB TRY gui.ShowAccountTab(-1)")
gui.ShowAccountTab(-1)
gui.ShowAccountTab(wm, -1)
gui.Data.State = "done"
return
} else if (b.Action == "QUIT") {
@ -273,7 +282,7 @@ func mainMouseClick(b *gui.ButtonMap) {
config.Accounts = append(config.Accounts, acc)
}
if (gui.Data.State == "main") {
gui.ShowMainTab()
gui.ShowMainTab(wm)
gui.Data.State = "done"
return
}
@ -292,7 +301,7 @@ func mainMouseClick(b *gui.ButtonMap) {
time.Sleep(200 * time.Millisecond)
if (gui.Data.State == "NEW PROTOBUF") {
if (currentMessage == nil) {
gui.SocketError()
gui.SocketError(wm)
gui.Data.State = "done"
} else {
log.Println("LOGIN currentMessage =", currentMessage)
@ -309,7 +318,7 @@ func mainMouseClick(b *gui.ButtonMap) {
}
}
log.Println("\tLOGIN WAS OK!")
gui.MessageWindow("Login OK", msg)
gui.MessageWindow(wm, "Login OK", msg)
} else if (currentMessage.Type == pb.Event_FAIL) {
log.Println("\tLOGIN FAILED")
log.Println("\tLOGIN FAILED")
@ -319,7 +328,7 @@ func mainMouseClick(b *gui.ButtonMap) {
msg += "pb.Id = " + fmt.Sprintf("%d", currentMessage.Id) + "\n"
msg += "pb.Email = " + b.Account.Email + "\n"
msg += "pb.Username = " + b.Account.Username + "\n"
gui.ErrorWindow("Login Failed", msg)
gui.ErrorWindow(wm, "Login Failed", msg)
}
currentMessage = nil
gui.Data.State = "done"
@ -339,10 +348,10 @@ func mainMouseClick(b *gui.ButtonMap) {
gui.Data.CurrentVM = b.VM
if (gui.Data.Debug) {
log.Println("\tATTEMPTING TO SHOW VM IN WINDOW")
go gui.GoShowVM()
// go gui.GoShowVM()
} else {
log.Println("\tATTEMPTING TO SHOW VM TAB", b.T)
gui.CreateVmBox(b.T, b.VM)
gui.CreateVmBox(wm, b.T, b.VM)
}
} else if (b.Action == "SHOW") {
log.Println("\tTRIGGER DISPLAY ACCOUNT")
@ -358,7 +367,7 @@ func mainMouseClick(b *gui.ButtonMap) {
time.Sleep(200 * time.Millisecond)
if (gui.Data.State == "NEW PROTOBUF") {
if (currentMessage == nil) {
gui.SocketError()
gui.SocketError(wm)
gui.Data.State = "done"
} else {
count := countVMS(currentMessage)
@ -367,7 +376,7 @@ func mainMouseClick(b *gui.ButtonMap) {
// TODO: make sure login worked & the account really has zero VMs
// if (count != 0) {
name := "Virtual Machines (" + b.Account.Nick + ")"
mh := gui.AddVmsTab(name, count, b.Account)
mh := gui.AddVmsTab(wm, name, count, b.Account)
ReadReceivedData(currentMessage, mh, b.W, b.T)
// }
currentMessage = nil
@ -437,8 +446,8 @@ func watchGUI() {
onExit(nil)
} else if (gui.Data.State == "HIDE") {
time.Sleep(20 * time.Millisecond) // maybe required for macos & windows refresh to work?
gui.Data.Window1.Box1.Show()
gui.Data.Window1.Box2.Show()
gui.Data.Windows[0].Box1.Show()
gui.Data.Windows[0].Box2.Show()
gui.Data.State = "done"
}
}

View File

@ -3,13 +3,26 @@ package main
// import "os"
// import "log"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
import "git.wit.com/wit/gui"
import pb "git.wit.com/wit/witProtobuf"
func main() {
gui.Data.Window1 = new(gui.WindowMap)
gui.Data.Window1.AreaText = ui.NewAttributedString("Click to continue")
gui.GoMainWindow()
c := pb.MakeDefaultConfig()
for {
gui.InitNewWindow(c, "SPLASH")
// aWinMap := gui.InitGUI(c)
// aWinMap.Action = "SPLASH"
// log.Println("main() aWinMap =", aWinMap)
gui.ShowWindow()
gui.InitNewWindow(c, "BLAH")
// log.Println("main() bWinMap =", bWinMap)
// bWinMap.Action = "BLAH"
gui.ShowWindow()
}
// gui.Data.Window2 = aWinMap
// gui.GoMainWindow()
}