more dereference improvements
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
5f84f5d2c7
commit
131c5e4722
32
area.go
32
area.go
|
@ -1,7 +1,7 @@
|
||||||
package gui
|
package gui
|
||||||
|
|
||||||
import "log"
|
import "log"
|
||||||
import "time"
|
// import "time"
|
||||||
|
|
||||||
import "github.com/andlabs/ui"
|
import "github.com/andlabs/ui"
|
||||||
import _ "github.com/andlabs/ui/winmanifest"
|
import _ "github.com/andlabs/ui/winmanifest"
|
||||||
|
@ -11,9 +11,9 @@ import "github.com/davecgh/go-spew/spew"
|
||||||
func findFB(button *ButtonMap) *ButtonMap {
|
func findFB(button *ButtonMap) *ButtonMap {
|
||||||
var a *ButtonMap
|
var a *ButtonMap
|
||||||
for key, foo := range Data.AllButtons {
|
for key, foo := range Data.AllButtons {
|
||||||
log.Println("defaultButtonClick() Data.AllButtons =", key, foo)
|
log.Println("findFB() Data.AllButtons key, foo=", key, foo)
|
||||||
// if Data.AllButtons[key] == *button {
|
|
||||||
if &foo == button {
|
if &foo == button {
|
||||||
|
log.Println("findFB() FOUND BUTTON key, foo=", key, foo)
|
||||||
a = &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)
|
// make this button just to get the default font (but don't display the button)
|
||||||
// There should be another way to do this (?)
|
// There should be another way to do this (?)
|
||||||
newB := CreateFontButton("AREA")
|
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.Attrstr = makeAttributedString()
|
||||||
ah.Area = ui.NewArea(ah)
|
ah.Area = ui.NewArea(ah)
|
||||||
newB.A = ah.Area
|
newB.A = ah.Area
|
||||||
Data.AllButtons[1].A = ah.Area
|
Data.AllButtons[1].A = ah.Area
|
||||||
// ah.FontButton = Data.AllButtons[1].FB
|
|
||||||
ah.Button = &Data.AllButtons[1]
|
ah.Button = &Data.AllButtons[1]
|
||||||
|
|
||||||
if (Data.Debug) {
|
if (Data.Debug) {
|
||||||
|
@ -104,8 +80,6 @@ func (ah AreaHandler) MouseEvent(a *ui.Area, me *ui.AreaMouseEvent) {
|
||||||
}
|
}
|
||||||
if (me.Up == 1) {
|
if (me.Up == 1) {
|
||||||
log.Println("GOT MOUSE UP")
|
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 =", ah.Button)
|
||||||
log.Println("GOT MOUSE UP ah.Button.FB =", ah.Button.FB)
|
log.Println("GOT MOUSE UP ah.Button.FB =", ah.Button.FB)
|
||||||
mouseClick(ah.Button)
|
mouseClick(ah.Button)
|
||||||
|
|
10
debug.go
10
debug.go
|
@ -26,13 +26,13 @@ func setupCloudUI() {
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
Data.cloudTab = ui.NewTab()
|
window1.T = ui.NewTab()
|
||||||
Data.cloudWindow.SetChild(Data.cloudTab)
|
Data.cloudWindow.SetChild(window1.T)
|
||||||
Data.cloudWindow.SetMargined(true)
|
Data.cloudWindow.SetMargined(true)
|
||||||
|
|
||||||
Data.tabcount = 0
|
Data.tabcount = 0
|
||||||
Data.cloudTab.Append("Cloud Info", makeCloudInfoBox())
|
window1.T.Append("Cloud Info", makeCloudInfoBox())
|
||||||
Data.cloudTab.SetMargined(Data.tabcount, true)
|
window1.T.SetMargined(Data.tabcount, true)
|
||||||
|
|
||||||
Data.cloudWindow.Show()
|
Data.cloudWindow.Show()
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ func addTableTab() {
|
||||||
|
|
||||||
log.Println("Sleep for 2 seconds, then try to add new tabs")
|
log.Println("Sleep for 2 seconds, then try to add new tabs")
|
||||||
time.Sleep(1 * 1000 * 1000 * 1000)
|
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) {
|
func addDebuggingButtons(vbox *ui.Box) {
|
||||||
|
|
8
gui.go
8
gui.go
|
@ -131,7 +131,7 @@ func mouseClick(b *ButtonMap) {
|
||||||
log.Println("\tgui.mouseClick() START b.Action =", b.Action)
|
log.Println("\tgui.mouseClick() START b.Action =", b.Action)
|
||||||
if (b.Action == "createAddVmBox") {
|
if (b.Action == "createAddVmBox") {
|
||||||
log.Println("\tgui.mouseClick() createAddVmBox for b =", b)
|
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
|
return
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -140,7 +140,7 @@ func mouseClick(b *ButtonMap) {
|
||||||
if (Data.Debug) {
|
if (Data.Debug) {
|
||||||
go ui.Main(ShowVM)
|
go ui.Main(ShowVM)
|
||||||
} else {
|
} 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
|
var newmap ButtonMap
|
||||||
newmap.B = newB
|
newmap.B = newB
|
||||||
newmap.T = Data.cloudTab
|
newmap.T = window1.T
|
||||||
newmap.Account = a
|
newmap.Account = a
|
||||||
newmap.VM = vm
|
newmap.VM = vm
|
||||||
newmap.Action = action
|
newmap.Action = action
|
||||||
|
@ -237,7 +237,7 @@ func CreateFontButton(action string) *ButtonMap {
|
||||||
|
|
||||||
newB.OnChanged(func (*ui.FontButton) {
|
newB.OnChanged(func (*ui.FontButton) {
|
||||||
log.Println("FontButton.OnChanged() START mouseClick(&newBM)", &newBM)
|
log.Println("FontButton.OnChanged() START mouseClick(&newBM)", &newBM)
|
||||||
// mouseClick(&newBM)
|
mouseClick(&newBM)
|
||||||
})
|
})
|
||||||
return &newBM
|
return &newBM
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,19 +154,19 @@ func AddVmsTab(name string, count int, a *pb.Account) *TableData {
|
||||||
parts = append(parts, tmp)
|
parts = append(parts, tmp)
|
||||||
human += 1
|
human += 1
|
||||||
|
|
||||||
mh := AddTableTab(Data.cloudTab, 1, name, count, parts, a)
|
mh := AddTableTab(window1.T, 1, name, count, parts, a)
|
||||||
return mh
|
return mh
|
||||||
}
|
}
|
||||||
|
|
||||||
func ShowAccountQuestionTab() {
|
func ShowAccountQuestionTab() {
|
||||||
Data.cloudTab.Delete(0)
|
window1.T.Delete(0)
|
||||||
|
|
||||||
log.Println("Sleep(200)")
|
log.Println("Sleep(200)")
|
||||||
time.Sleep(200 * time.Millisecond)
|
time.Sleep(200 * time.Millisecond)
|
||||||
|
|
||||||
Data.smallBox = AddAccountQuestionBox()
|
Data.smallBox = AddAccountQuestionBox()
|
||||||
Data.cloudTab.InsertAt("New Account?", 0, Data.smallBox)
|
window1.T.InsertAt("New Account?", 0, Data.smallBox)
|
||||||
Data.cloudTab.SetMargined(0, true)
|
window1.T.SetMargined(0, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ShowAccountTab(i int) {
|
func ShowAccountTab(i int) {
|
||||||
|
@ -179,34 +179,35 @@ func ShowAccountTab(i int) {
|
||||||
abox := AddAccountBox()
|
abox := AddAccountBox()
|
||||||
|
|
||||||
// Set the parents and data structure links
|
// Set the parents and data structure links
|
||||||
// aTab.me = Data.cloudTab
|
// aTab.me = window1.T
|
||||||
// aTab.parentWindow = Data.cloudWindow
|
// aTab.parentWindow = Data.cloudWindow
|
||||||
// aTab.tabOffset = 0
|
// aTab.tabOffset = 0
|
||||||
|
|
||||||
if (i >= 0) {
|
if (i >= 0) {
|
||||||
log.Println("ShowAccountTab() InsertAt i=", i)
|
log.Println("ShowAccountTab() InsertAt i=", i)
|
||||||
Data.cloudTab.Delete(0)
|
window1.T.Delete(0)
|
||||||
Data.cloudTab.InsertAt("Add Account", i, abox)
|
window1.T.InsertAt("Add Account", i, abox)
|
||||||
Data.cloudTab.SetMargined(0, true)
|
window1.T.SetMargined(0, true)
|
||||||
} else {
|
} else {
|
||||||
// TODO: After append try to discover the tab index #
|
// TODO: After append try to discover the tab index #
|
||||||
log.Println("ShowAccountTab() Append")
|
log.Println("ShowAccountTab() Append")
|
||||||
AddBoxToTab("Create New Account", Data.cloudTab, abox)
|
AddBoxToTab("Create New Account", window1.T, abox)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ShowMainTab() {
|
func ShowMainTab() {
|
||||||
Data.cloudTab.Delete(0)
|
window1.T.Delete(0)
|
||||||
|
|
||||||
log.Println("Sleep(200)")
|
log.Println("Sleep(200)")
|
||||||
time.Sleep(200 * time.Millisecond)
|
time.Sleep(200 * time.Millisecond)
|
||||||
|
|
||||||
Data.smallBox = makeCloudInfoBox()
|
Data.smallBox = makeCloudInfoBox()
|
||||||
Data.cloudTab.InsertAt("Main", 0, Data.smallBox)
|
window1.T.InsertAt("Main", 0, Data.smallBox)
|
||||||
Data.cloudTab.SetMargined(0, true)
|
window1.T.SetMargined(0, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GoMainWindow() {
|
func GoMainWindow() {
|
||||||
|
window1 = new(WindowMap)
|
||||||
ui.Main(makeCloudWindow)
|
ui.Main(makeCloudWindow)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,15 +230,15 @@ func makeCloudWindow() {
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
Data.cloudTab = ui.NewTab()
|
window1.T = ui.NewTab()
|
||||||
Data.cloudWindow.SetChild(Data.cloudTab)
|
Data.cloudWindow.SetChild(window1.T)
|
||||||
Data.cloudWindow.SetMargined(true)
|
Data.cloudWindow.SetMargined(true)
|
||||||
|
|
||||||
text := makeAttributedString()
|
text := makeAttributedString()
|
||||||
Data.cloudBox = ShowSplashBox(text)
|
Data.cloudBox = ShowSplashBox(text)
|
||||||
|
|
||||||
Data.cloudTab.Append("WIT Splash", Data.cloudBox)
|
window1.T.Append("WIT Splash", Data.cloudBox)
|
||||||
Data.cloudTab.SetMargined(0, true)
|
window1.T.SetMargined(0, true)
|
||||||
|
|
||||||
Data.cloudWindow.Show()
|
Data.cloudWindow.Show()
|
||||||
Data.State = "splash"
|
Data.State = "splash"
|
||||||
|
@ -245,7 +246,7 @@ func makeCloudWindow() {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
func AddVmConfigureTab(name string, pbVM *pb.Event_VM) {
|
func AddVmConfigureTab(name string, pbVM *pb.Event_VM) {
|
||||||
CreateVmBox(Data.cloudTab, Data.CurrentVM)
|
CreateVmBox(window1.T, Data.CurrentVM)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
16
structs.go
16
structs.go
|
@ -13,7 +13,7 @@ import pb "git.wit.com/wit/witProtobuf"
|
||||||
// be the safe way to interact with the GUI
|
// be the safe way to interact with the GUI
|
||||||
//
|
//
|
||||||
var Data GuiDataStructure
|
var Data GuiDataStructure
|
||||||
// var myAH *AreaHandler
|
var window1 *WindowMap
|
||||||
|
|
||||||
type GuiDataStructure struct {
|
type GuiDataStructure struct {
|
||||||
State string
|
State string
|
||||||
|
@ -59,15 +59,11 @@ type GuiDataStructure struct {
|
||||||
|
|
||||||
// stuff for the splash screen / setup tabs
|
// stuff for the splash screen / setup tabs
|
||||||
cloudWindow *ui.Window
|
cloudWindow *ui.Window
|
||||||
cloudTab *ui.Tab
|
|
||||||
cloudBox *ui.Box
|
cloudBox *ui.Box
|
||||||
smallBox *ui.Box
|
smallBox *ui.Box
|
||||||
myAH *AreaHandler
|
myAH *AreaHandler
|
||||||
|
|
||||||
tabcount int
|
tabcount int
|
||||||
|
|
||||||
// stuff for the 'area'
|
|
||||||
// fontButton *ui.FontButton
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type TableColumnData struct {
|
type TableColumnData struct {
|
||||||
|
@ -98,6 +94,14 @@ type EntryMap struct {
|
||||||
// custom func (*EntryMap)
|
// custom func (*EntryMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type WindowMap struct {
|
||||||
|
W *ui.Window
|
||||||
|
T *ui.Tab
|
||||||
|
A *ui.Area
|
||||||
|
|
||||||
|
AH *AreaHandler
|
||||||
|
}
|
||||||
|
|
||||||
type ButtonMap struct {
|
type ButtonMap struct {
|
||||||
B *ui.Button
|
B *ui.Button
|
||||||
FB *ui.FontButton
|
FB *ui.FontButton
|
||||||
|
@ -119,8 +123,6 @@ type AreaHandler struct{
|
||||||
Button *ButtonMap
|
Button *ButtonMap
|
||||||
Attrstr *ui.AttributedString
|
Attrstr *ui.AttributedString
|
||||||
Area *ui.Area
|
Area *ui.Area
|
||||||
// FontButton *ui.FontButton
|
|
||||||
// FB func () *ButtonMap
|
|
||||||
}
|
}
|
||||||
// AREA STRUCTURES END
|
// AREA STRUCTURES END
|
||||||
|
|
||||||
|
|
2
vmBox.go
2
vmBox.go
|
@ -43,7 +43,7 @@ func ShowVM() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddVmConfigureTab(name string, pbVM *pb.Event_VM) {
|
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) {
|
func CreateVmBox(tab *ui.Tab, vm *pb.Event_VM) {
|
||||||
|
|
Loading…
Reference in New Issue