more dereferencing of *ui.Area

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-29 12:21:10 -07:00
parent 131c5e4722
commit 9ec2ec7f9e
6 changed files with 51 additions and 50 deletions

View File

@ -16,25 +16,25 @@ import "github.com/davecgh/go-spew/spew"
// can not pass any args to this (?)
func setupCloudUI() {
Data.cloudWindow = ui.NewWindow("Cloud Control Panel", Data.Width, Data.Height, false)
Data.cloudWindow.OnClosing(func(*ui.Window) bool {
Data.Window1.W = ui.NewWindow("Cloud Control Panel", Data.Width, Data.Height, false)
Data.Window1.W.OnClosing(func(*ui.Window) bool {
ui.Quit()
return true
})
ui.OnShouldQuit(func() bool {
Data.cloudWindow.Destroy()
Data.Window1.W.Destroy()
return true
})
window1.T = ui.NewTab()
Data.cloudWindow.SetChild(window1.T)
Data.cloudWindow.SetMargined(true)
Data.Window1.T = ui.NewTab()
Data.Window1.W.SetChild(Data.Window1.T)
Data.Window1.W.SetMargined(true)
Data.tabcount = 0
window1.T.Append("Cloud Info", makeCloudInfoBox())
window1.T.SetMargined(Data.tabcount, true)
Data.Window1.T.Append("Cloud Info", makeCloudInfoBox())
Data.Window1.T.SetMargined(Data.tabcount, true)
Data.cloudWindow.Show()
Data.Window1.W.Show()
}
func addTableTab() {
@ -51,7 +51,7 @@ func addTableTab() {
log.Println("Sleep for 2 seconds, then try to add new tabs")
time.Sleep(1 * 1000 * 1000 * 1000)
AddTableTab(window1.T, 1, "test seven", 7, parts, nil)
AddTableTab(Data.Window1.T, 1, "test seven", 7, parts, nil)
}
func addDebuggingButtons(vbox *ui.Box) {

14
gui.go
View File

@ -99,17 +99,17 @@ func AddTableTab(mytab *ui.Tab, mytabcount int, name string, rowcount int, parts
}
func SocketError() {
ui.MsgBoxError(Data.cloudWindow,
ui.MsgBoxError(Data.Window1.W,
"There was a socket error",
"More detailed information can be shown here.")
}
func MessageWindow(msg1 string, msg2 string) {
ui.MsgBox(Data.cloudWindow, msg1, msg2)
ui.MsgBox(Data.Window1.W, msg1, msg2)
}
func ErrorWindow(msg1 string, msg2 string) {
ui.MsgBoxError(Data.cloudWindow, msg1, msg2)
ui.MsgBoxError(Data.Window1.W, msg1, msg2)
}
// This is the default mouse click handler
@ -131,7 +131,7 @@ func mouseClick(b *ButtonMap) {
log.Println("\tgui.mouseClick() START b.Action =", b.Action)
if (b.Action == "createAddVmBox") {
log.Println("\tgui.mouseClick() createAddVmBox for b =", b)
createAddVmBox(window1.T, "Create New Virtual Machine", b)
createAddVmBox(Data.Window1.T, "Create New Virtual Machine", b)
return
}
/*
@ -140,7 +140,7 @@ func mouseClick(b *ButtonMap) {
if (Data.Debug) {
go ui.Main(ShowVM)
} else {
CreateVmBox(window1.T, b.VM)
CreateVmBox(Data.Window1.T, b.VM)
}
}
*/
@ -215,7 +215,7 @@ func CreateButton(a *pb.Account, vm *pb.Event_VM,
var newmap ButtonMap
newmap.B = newB
newmap.T = window1.T
newmap.T = Data.Window1.T
newmap.Account = a
newmap.VM = vm
newmap.Action = action
@ -232,7 +232,7 @@ func CreateFontButton(action string) *ButtonMap {
var newBM ButtonMap
newBM.Action = action
newBM.FB = newB
newBM.AH = Data.myAH
newBM.AH = Data.Window1.AH
Data.AllButtons = append(Data.AllButtons, newBM)
newB.OnChanged(func (*ui.FontButton) {

View File

@ -154,19 +154,19 @@ func AddVmsTab(name string, count int, a *pb.Account) *TableData {
parts = append(parts, tmp)
human += 1
mh := AddTableTab(window1.T, 1, name, count, parts, a)
mh := AddTableTab(Data.Window1.T, 1, name, count, parts, a)
return mh
}
func ShowAccountQuestionTab() {
window1.T.Delete(0)
Data.Window1.T.Delete(0)
log.Println("Sleep(200)")
time.Sleep(200 * time.Millisecond)
Data.smallBox = AddAccountQuestionBox()
window1.T.InsertAt("New Account?", 0, Data.smallBox)
window1.T.SetMargined(0, true)
Data.Window1.T.InsertAt("New Account?", 0, Data.smallBox)
Data.Window1.T.SetMargined(0, true)
}
func ShowAccountTab(i int) {
@ -179,49 +179,49 @@ func ShowAccountTab(i int) {
abox := AddAccountBox()
// Set the parents and data structure links
// aTab.me = window1.T
// aTab.parentWindow = Data.cloudWindow
// aTab.me = Data.Window1.T
// aTab.parentWindow = Data.Window1.W
// aTab.tabOffset = 0
if (i >= 0) {
log.Println("ShowAccountTab() InsertAt i=", i)
window1.T.Delete(0)
window1.T.InsertAt("Add Account", i, abox)
window1.T.SetMargined(0, true)
Data.Window1.T.Delete(0)
Data.Window1.T.InsertAt("Add Account", i, abox)
Data.Window1.T.SetMargined(0, true)
} else {
// TODO: After append try to discover the tab index #
log.Println("ShowAccountTab() Append")
AddBoxToTab("Create New Account", window1.T, abox)
AddBoxToTab("Create New Account", Data.Window1.T, abox)
}
}
func ShowMainTab() {
window1.T.Delete(0)
Data.Window1.T.Delete(0)
log.Println("Sleep(200)")
time.Sleep(200 * time.Millisecond)
Data.smallBox = makeCloudInfoBox()
window1.T.InsertAt("Main", 0, Data.smallBox)
window1.T.SetMargined(0, true)
Data.Window1.T.InsertAt("Main", 0, Data.smallBox)
Data.Window1.T.SetMargined(0, true)
}
func GoMainWindow() {
window1 = new(WindowMap)
Data.Window1 = new(WindowMap)
ui.Main(makeCloudWindow)
}
func makeCloudWindow() {
Data.cloudWindow = ui.NewWindow("", Data.Width, Data.Height, true)
// cloudWindow.SetBorderless(true)
Data.Window1.W = ui.NewWindow("", Data.Width, Data.Height, true)
// Window1.W.SetBorderless(true)
// create a 'fake' button entry for the mouse clicks
var newBM ButtonMap
newBM.Action = "QUIT"
newBM.W = Data.cloudWindow
newBM.W = Data.Window1.W
Data.AllButtons = append(Data.AllButtons, newBM)
Data.cloudWindow.OnClosing(func(*ui.Window) bool {
Data.Window1.W.OnClosing(func(*ui.Window) bool {
mouseClick(&newBM)
return true
})
@ -230,23 +230,23 @@ func makeCloudWindow() {
return true
})
window1.T = ui.NewTab()
Data.cloudWindow.SetChild(window1.T)
Data.cloudWindow.SetMargined(true)
Data.Window1.T = ui.NewTab()
Data.Window1.W.SetChild(Data.Window1.T)
Data.Window1.W.SetMargined(true)
text := makeAttributedString()
Data.cloudBox = ShowSplashBox(text)
window1.T.Append("WIT Splash", Data.cloudBox)
window1.T.SetMargined(0, true)
Data.Window1.T.Append("WIT Splash", Data.cloudBox)
Data.Window1.T.SetMargined(0, true)
Data.cloudWindow.Show()
Data.Window1.W.Show()
Data.State = "splash"
}
/*
func AddVmConfigureTab(name string, pbVM *pb.Event_VM) {
CreateVmBox(window1.T, Data.CurrentVM)
CreateVmBox(Data.Window1.T, Data.CurrentVM)
}
*/

View File

@ -15,11 +15,11 @@ func ShowSplashBox(newText *ui.AttributedString) *ui.Box {
newbox.SetPadded(true)
// initialize the AreaHandler{}
Data.myAH = new(AreaHandler)
Data.myAH.Attrstr = newText
makeSplashArea(Data.myAH)
Data.Window1.AH = new(AreaHandler)
Data.Window1.AH.Attrstr = newText
makeSplashArea(Data.Window1.AH)
newbox.Append(Data.myAH.Area, true)
newbox.Append(Data.Window1.AH.Area, true)
if runtime.GOOS == "linux" {
newbox.Append(ui.NewLabel("OS: Linux"), false)

View File

@ -13,7 +13,6 @@ import pb "git.wit.com/wit/witProtobuf"
// be the safe way to interact with the GUI
//
var Data GuiDataStructure
var window1 *WindowMap
type GuiDataStructure struct {
State string
@ -53,15 +52,17 @@ type GuiDataStructure struct {
// pass it in
CurrentVM *pb.Event_VM
Window1 *WindowMap
Window2 *WindowMap
EntryNick *ui.Entry
EntryUser *ui.Entry
EntryPass *ui.Entry
// stuff for the splash screen / setup tabs
cloudWindow *ui.Window
cloudBox *ui.Box
smallBox *ui.Box
myAH *AreaHandler
// myAH *AreaHandler
tabcount int
}

View File

@ -43,7 +43,7 @@ func ShowVM() {
}
func AddVmConfigureTab(name string, pbVM *pb.Event_VM) {
CreateVmBox(window1.T, Data.CurrentVM)
CreateVmBox(Data.Window1.T, Data.CurrentVM)
}
func CreateVmBox(tab *ui.Tab, vm *pb.Event_VM) {