more dereference improvements

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-29 11:48:32 -07:00
parent 5f84f5d2c7
commit 131c5e4722
7 changed files with 40 additions and 63 deletions

32
area.go
View File

@ -1,7 +1,7 @@
package gui
import "log"
import "time"
// import "time"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
@ -11,9 +11,9 @@ import "github.com/davecgh/go-spew/spew"
func findFB(button *ButtonMap) *ButtonMap {
var a *ButtonMap
for key, foo := range Data.AllButtons {
log.Println("defaultButtonClick() Data.AllButtons =", key, foo)
// if Data.AllButtons[key] == *button {
log.Println("findFB() Data.AllButtons key, foo=", key, foo)
if &foo == button {
log.Println("findFB() FOUND BUTTON key, foo=", key, foo)
a = &foo
}
}
@ -24,35 +24,11 @@ func makeSplashArea(ah *AreaHandler) {
// make this button just to get the default font (but don't display the button)
// There should be another way to do this (?)
newB := CreateFontButton("AREA")
// ah.FontButton = newB.FB
time.Sleep(200 * time.Millisecond)
tmp := findFB(newB)
log.Println("makeSplashArea() newB =", newB)
log.Println("makeSplashArea() newB.AH =", newB.AH)
log.Println("makeSplashArea() newB =", newB)
// log.Println("makeSplashArea() newB.AH =", newB.AH)
log.Println("makeSplashArea() newB =", newB)
time.Sleep(200 * time.Millisecond)
tmp = findFB(newB)
log.Println("makeSplashArea() tmp =", tmp, "newB", newB)
Data.AllButtons[1].AH = ah
time.Sleep(200 * time.Millisecond)
tmp = findFB(newB)
log.Println("makeSplashArea() tmp =", tmp, "newB", newB)
// log.Println("makeSplashArea() ah =", ah)
// log.Println("makeSplashArea() ah.FontButton =", ah.FontButton)
// DefaultFont: ah.FontButton.Font(),
ah.Attrstr = makeAttributedString()
ah.Area = ui.NewArea(ah)
newB.A = ah.Area
Data.AllButtons[1].A = ah.Area
// ah.FontButton = Data.AllButtons[1].FB
ah.Button = &Data.AllButtons[1]
if (Data.Debug) {
@ -104,8 +80,6 @@ func (ah AreaHandler) MouseEvent(a *ui.Area, me *ui.AreaMouseEvent) {
}
if (me.Up == 1) {
log.Println("GOT MOUSE UP")
// log.Println("GOT MOUSE UP ah", ah)
// log.Println("GOT MOUSE UP ah.FontButton =", ah.FontButton)
log.Println("GOT MOUSE UP ah.Button =", ah.Button)
log.Println("GOT MOUSE UP ah.Button.FB =", ah.Button.FB)
mouseClick(ah.Button)

View File

@ -26,13 +26,13 @@ func setupCloudUI() {
return true
})
Data.cloudTab = ui.NewTab()
Data.cloudWindow.SetChild(Data.cloudTab)
window1.T = ui.NewTab()
Data.cloudWindow.SetChild(window1.T)
Data.cloudWindow.SetMargined(true)
Data.tabcount = 0
Data.cloudTab.Append("Cloud Info", makeCloudInfoBox())
Data.cloudTab.SetMargined(Data.tabcount, true)
window1.T.Append("Cloud Info", makeCloudInfoBox())
window1.T.SetMargined(Data.tabcount, true)
Data.cloudWindow.Show()
}
@ -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(Data.cloudTab, 1, "test seven", 7, parts, nil)
AddTableTab(window1.T, 1, "test seven", 7, parts, nil)
}
func addDebuggingButtons(vbox *ui.Box) {

8
gui.go
View File

@ -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(Data.cloudTab, "Create New Virtual Machine", b)
createAddVmBox(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(Data.cloudTab, b.VM)
CreateVmBox(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 = Data.cloudTab
newmap.T = window1.T
newmap.Account = a
newmap.VM = vm
newmap.Action = action
@ -237,7 +237,7 @@ func CreateFontButton(action string) *ButtonMap {
newB.OnChanged(func (*ui.FontButton) {
log.Println("FontButton.OnChanged() START mouseClick(&newBM)", &newBM)
// mouseClick(&newBM)
mouseClick(&newBM)
})
return &newBM
}

View File

@ -154,19 +154,19 @@ func AddVmsTab(name string, count int, a *pb.Account) *TableData {
parts = append(parts, tmp)
human += 1
mh := AddTableTab(Data.cloudTab, 1, name, count, parts, a)
mh := AddTableTab(window1.T, 1, name, count, parts, a)
return mh
}
func ShowAccountQuestionTab() {
Data.cloudTab.Delete(0)
window1.T.Delete(0)
log.Println("Sleep(200)")
time.Sleep(200 * time.Millisecond)
Data.smallBox = AddAccountQuestionBox()
Data.cloudTab.InsertAt("New Account?", 0, Data.smallBox)
Data.cloudTab.SetMargined(0, true)
window1.T.InsertAt("New Account?", 0, Data.smallBox)
window1.T.SetMargined(0, true)
}
func ShowAccountTab(i int) {
@ -179,34 +179,35 @@ func ShowAccountTab(i int) {
abox := AddAccountBox()
// Set the parents and data structure links
// aTab.me = Data.cloudTab
// aTab.me = window1.T
// aTab.parentWindow = Data.cloudWindow
// aTab.tabOffset = 0
if (i >= 0) {
log.Println("ShowAccountTab() InsertAt i=", i)
Data.cloudTab.Delete(0)
Data.cloudTab.InsertAt("Add Account", i, abox)
Data.cloudTab.SetMargined(0, true)
window1.T.Delete(0)
window1.T.InsertAt("Add Account", i, abox)
window1.T.SetMargined(0, true)
} else {
// TODO: After append try to discover the tab index #
log.Println("ShowAccountTab() Append")
AddBoxToTab("Create New Account", Data.cloudTab, abox)
AddBoxToTab("Create New Account", window1.T, abox)
}
}
func ShowMainTab() {
Data.cloudTab.Delete(0)
window1.T.Delete(0)
log.Println("Sleep(200)")
time.Sleep(200 * time.Millisecond)
Data.smallBox = makeCloudInfoBox()
Data.cloudTab.InsertAt("Main", 0, Data.smallBox)
Data.cloudTab.SetMargined(0, true)
window1.T.InsertAt("Main", 0, Data.smallBox)
window1.T.SetMargined(0, true)
}
func GoMainWindow() {
window1 = new(WindowMap)
ui.Main(makeCloudWindow)
}
@ -229,15 +230,15 @@ func makeCloudWindow() {
return true
})
Data.cloudTab = ui.NewTab()
Data.cloudWindow.SetChild(Data.cloudTab)
window1.T = ui.NewTab()
Data.cloudWindow.SetChild(window1.T)
Data.cloudWindow.SetMargined(true)
text := makeAttributedString()
Data.cloudBox = ShowSplashBox(text)
Data.cloudTab.Append("WIT Splash", Data.cloudBox)
Data.cloudTab.SetMargined(0, true)
window1.T.Append("WIT Splash", Data.cloudBox)
window1.T.SetMargined(0, true)
Data.cloudWindow.Show()
Data.State = "splash"
@ -245,7 +246,7 @@ func makeCloudWindow() {
/*
func AddVmConfigureTab(name string, pbVM *pb.Event_VM) {
CreateVmBox(Data.cloudTab, Data.CurrentVM)
CreateVmBox(window1.T, Data.CurrentVM)
}
*/

View File

View File

@ -13,7 +13,7 @@ import pb "git.wit.com/wit/witProtobuf"
// be the safe way to interact with the GUI
//
var Data GuiDataStructure
// var myAH *AreaHandler
var window1 *WindowMap
type GuiDataStructure struct {
State string
@ -59,15 +59,11 @@ type GuiDataStructure struct {
// stuff for the splash screen / setup tabs
cloudWindow *ui.Window
cloudTab *ui.Tab
cloudBox *ui.Box
smallBox *ui.Box
myAH *AreaHandler
tabcount int
// stuff for the 'area'
// fontButton *ui.FontButton
}
type TableColumnData struct {
@ -98,6 +94,14 @@ type EntryMap struct {
// custom func (*EntryMap)
}
type WindowMap struct {
W *ui.Window
T *ui.Tab
A *ui.Area
AH *AreaHandler
}
type ButtonMap struct {
B *ui.Button
FB *ui.FontButton
@ -119,8 +123,6 @@ type AreaHandler struct{
Button *ButtonMap
Attrstr *ui.AttributedString
Area *ui.Area
// FontButton *ui.FontButton
// FB func () *ButtonMap
}
// AREA STRUCTURES END

View File

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