start fixing variable names

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-30 08:52:28 -07:00
parent 49e3887aa6
commit 58e76c3b8e
8 changed files with 57 additions and 89 deletions

View File

@ -7,7 +7,7 @@ import _ "github.com/andlabs/ui/winmanifest"
var subdomain *ui.Entry var subdomain *ui.Entry
func AddAccountQuestionBox(wm *WindowMap) *ui.Box { func AddAccountQuestionBox(wm *GuiWindow) *ui.Box {
vbox := ui.NewVerticalBox() vbox := ui.NewVerticalBox()
vbox.SetPadded(true) vbox.SetPadded(true)
wm.Box1 = vbox wm.Box1 = vbox
@ -18,7 +18,7 @@ func AddAccountQuestionBox(wm *WindowMap) *ui.Box {
hbox.Append(ui.NewLabel("Enter your Subdomain or"), false) hbox.Append(ui.NewLabel("Enter your Subdomain or"), false)
generate := CreateButton(wm, nil, nil, "Make me a Subdomain", "SUBDOMAIN", generateSubdomain) generate := CreateButton(wm, nil, nil, "Generate", "SUBDOMAIN", generateSubdomain)
hbox.Append(generate, false) hbox.Append(generate, false)
subdomain = ui.NewEntry() subdomain = ui.NewEntry()
@ -49,7 +49,7 @@ func addSubdomain(b *ButtonMap) {
log.Println("generateSubdomain END") log.Println("generateSubdomain END")
} }
func AddAccountBox(wm *WindowMap) *ui.Box { func AddAccountBox(wm *GuiWindow) *ui.Box {
vbox := ui.NewVerticalBox() vbox := ui.NewVerticalBox()
vbox.SetPadded(true) vbox.SetPadded(true)

View File

@ -20,7 +20,7 @@ func findFB(button *ButtonMap) *ButtonMap {
return a return a
} }
func makeSplashArea(wm *WindowMap, ah *AreaHandler) { func makeSplashArea(wm *GuiWindow, 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(wm, "AREA") newB := CreateFontButton(wm, "AREA")

View File

@ -56,7 +56,7 @@ func addTableTab() {
// AddTableTab(Data.Window1.T, 1, "test seven", 7, parts, nil) // AddTableTab(Data.Window1.T, 1, "test seven", 7, parts, nil)
} }
func addDebuggingButtons(wm *WindowMap, vbox *ui.Box) { func addDebuggingButtons(wm *GuiWindow, vbox *ui.Box) {
vbox.Append(ui.NewLabel("Debugging:"), false) vbox.Append(ui.NewLabel("Debugging:"), false)
vbox.Append(ui.NewColorButton(), false) vbox.Append(ui.NewColorButton(), false)

36
gui.go
View File

@ -41,7 +41,7 @@ func InitColumns(mh *TableData, parts []TableColumnData) {
} }
} }
func AddTableTab(wm *WindowMap, mytab *ui.Tab, junk int, name string, rowcount int, parts []TableColumnData, account *pb.Account) *TableData { func AddTableTab(wm *GuiWindow, mytab *ui.Tab, junk int, name string, rowcount int, parts []TableColumnData, account *pb.Account) *TableData {
mh := new(TableData) mh := new(TableData)
mh.RowCount = rowcount mh.RowCount = rowcount
@ -98,17 +98,17 @@ func AddTableTab(wm *WindowMap, mytab *ui.Tab, junk int, name string, rowcount i
return mh return mh
} }
func SocketError(wm *WindowMap) { func SocketError(wm *GuiWindow) {
ui.MsgBoxError(wm.W, ui.MsgBoxError(wm.W,
"There was a socket error", "There was a socket error",
"More detailed information can be shown here.") "More detailed information can be shown here.")
} }
func MessageWindow(wm *WindowMap, msg1 string, msg2 string) { func MessageWindow(wm *GuiWindow, msg1 string, msg2 string) {
ui.MsgBox(wm.W, msg1, msg2) ui.MsgBox(wm.W, msg1, msg2)
} }
func ErrorWindow(wm *WindowMap, msg1 string, msg2 string) { func ErrorWindow(wm *GuiWindow, msg1 string, msg2 string) {
ui.MsgBoxError(wm.W, msg1, msg2) ui.MsgBoxError(wm.W, msg1, msg2)
} }
@ -209,25 +209,25 @@ func AddButton(b *ButtonMap, name string) *ui.Button {
return newB return newB
} }
func CreateButton(wm *WindowMap, a *pb.Account, vm *pb.Event_VM, func CreateButton(wm *GuiWindow, a *pb.Account, vm *pb.Event_VM,
name string, action string, custom func(*ButtonMap)) *ui.Button { name string, action string, custom func(*ButtonMap)) *ui.Button {
newB := ui.NewButton(name) newUiB := ui.NewButton(name)
newB.OnClicked(defaultButtonClick) newUiB.OnClicked(defaultButtonClick)
var newmap ButtonMap var newB ButtonMap
newmap.B = newB newB.B = newUiB
newmap.T = wm.T newB.T = wm.T
newmap.Account = a newB.Account = a
newmap.VM = vm newB.VM = vm
newmap.WM = wm newB.WM = wm
newmap.Action = action newB.Action = action
newmap.custom = custom newB.custom = custom
Data.AllButtons = append(Data.AllButtons, newmap) Data.AllButtons = append(Data.AllButtons, newB)
return newB return newUiB
} }
func CreateFontButton(wm *WindowMap, action string) *ButtonMap { func CreateFontButton(wm *GuiWindow, action string) *ButtonMap {
newB := ui.NewFontButton() newB := ui.NewFontButton()
// create a 'fake' button entry for the mouse clicks // create a 'fake' button entry for the mouse clicks

View File

@ -13,7 +13,7 @@ import pb "git.wit.com/wit/witProtobuf"
// import "github.com/davecgh/go-spew/spew" // import "github.com/davecgh/go-spew/spew"
func makeCloudInfoBox(wm *WindowMap) *ui.Box { func makeCloudInfoBox(wm *GuiWindow) *ui.Box {
hbox := ui.NewHorizontalBox() hbox := ui.NewHorizontalBox()
hbox.SetPadded(true) hbox.SetPadded(true)
@ -103,7 +103,7 @@ func makeCloudInfoBox(wm *WindowMap) *ui.Box {
// which could be anything since TEXTCOLOR, TEXT, BG, etc // which could be anything since TEXTCOLOR, TEXT, BG, etc
// fields use between 1 and 3 values internally // fields use between 1 and 3 values internally
// //
func AddVmsTab(wm *WindowMap, name string, count int, a *pb.Account) *TableData { func AddVmsTab(wm *GuiWindow, name string, count int, a *pb.Account) *TableData {
var parts []TableColumnData var parts []TableColumnData
human := 0 human := 0
@ -161,7 +161,7 @@ func AddVmsTab(wm *WindowMap, name string, count int, a *pb.Account) *TableData
return mh return mh
} }
func ShowAccountQuestionTab(wm *WindowMap) { func ShowAccountQuestionTab(wm *GuiWindow) {
log.Println("ShowAccountQuestionTab() wm =", wm) log.Println("ShowAccountQuestionTab() wm =", wm)
if (wm.T == nil) { if (wm.T == nil) {
log.Println("ShowAccountQuestionTab() wm.T = nil THIS IS BAD") log.Println("ShowAccountQuestionTab() wm.T = nil THIS IS BAD")
@ -177,7 +177,7 @@ func ShowAccountQuestionTab(wm *WindowMap) {
wm.T.SetMargined(0, true) wm.T.SetMargined(0, true)
} }
func ShowAccountTab(wm *WindowMap, i int) { func ShowAccountTab(wm *GuiWindow, i int) {
log.Println("ShowAccountTab() START") log.Println("ShowAccountTab() START")
log.Println("Sleep(200)") log.Println("Sleep(200)")
@ -203,7 +203,7 @@ func ShowAccountTab(wm *WindowMap, i int) {
} }
} }
func ShowMainTab(wm *WindowMap) { func ShowMainTab(wm *GuiWindow) {
log.Println("ShowMainTab() wm =", wm) log.Println("ShowMainTab() wm =", wm)
log.Println("ShowMainTab() wm.T =", wm.T) log.Println("ShowMainTab() wm.T =", wm.T)
log.Println("ShowMainTab() wm.T =", wm.T) log.Println("ShowMainTab() wm.T =", wm.T)
@ -219,10 +219,10 @@ func ShowMainTab(wm *WindowMap) {
func StartNewWindow(c *pb.Config, bg bool, action string) { func StartNewWindow(c *pb.Config, bg bool, action string) {
log.Println("InitNewWindow() Create a new window") log.Println("InitNewWindow() Create a new window")
var newWindowMap WindowMap var newGuiWindow GuiWindow
newWindowMap.C = c newGuiWindow.C = c
newWindowMap.Action = action newGuiWindow.Action = action
Data.Windows = append(Data.Windows, &newWindowMap) Data.Windows = append(Data.Windows, &newGuiWindow)
ui.OnShouldQuit(func() bool { ui.OnShouldQuit(func() bool {
// mouseClick(&newBM) // mouseClick(&newBM)
@ -233,13 +233,13 @@ func StartNewWindow(c *pb.Config, bg bool, action string) {
if (bg) { if (bg) {
log.Println("ShowWindow() IN NEW GOROUTINE") log.Println("ShowWindow() IN NEW GOROUTINE")
go ui.Main(func() { go ui.Main(func() {
InitWindow(&newWindowMap) InitWindow(&newGuiWindow)
}) })
time.Sleep(2000 * time.Millisecond) time.Sleep(2000 * time.Millisecond)
} else { } else {
log.Println("ShowWindow() WAITING for ui.Main()") log.Println("ShowWindow() WAITING for ui.Main()")
ui.Main(func() { ui.Main(func() {
InitWindow(&newWindowMap) InitWindow(&newGuiWindow)
}) })
} }
} }
@ -251,7 +251,7 @@ func getSplashText(a string) *ui.AttributedString {
} }
func InitWindow(wm *WindowMap) { func InitWindow(wm *GuiWindow) {
log.Println("InitWindow() THIS WINDOW IS NOT YET SHOWN") log.Println("InitWindow() THIS WINDOW IS NOT YET SHOWN")
c := wm.C c := wm.C
@ -295,7 +295,7 @@ func InitWindow(wm *WindowMap) {
} }
// makeEntryBox(box, "hostname:", "blah.foo.org") { // makeEntryBox(box, "hostname:", "blah.foo.org") {
func makeEntryVbox(hbox *ui.Box, a string, startValue string, edit bool, action string) *EntryMap { func makeEntryVbox(hbox *ui.Box, a string, startValue string, edit bool, action string) *GuiEntry {
// Start 'Nickname' vertical box // Start 'Nickname' vertical box
vboxN := ui.NewVerticalBox() vboxN := ui.NewVerticalBox()
vboxN.SetPadded(true) vboxN.SetPadded(true)
@ -365,7 +365,7 @@ func defaultEntryChange(e *ui.Entry) {
log.Println("defaultEntryChange() ERROR. MISSING ENTRY MAP. e.Text() =", e.Text()) log.Println("defaultEntryChange() ERROR. MISSING ENTRY MAP. e.Text() =", e.Text())
} }
func defaultMakeEntry(startValue string, edit bool, action string) *EntryMap { func defaultMakeEntry(startValue string, edit bool, action string) *GuiEntry {
e := ui.NewEntry() e := ui.NewEntry()
e.SetText(startValue) e.SetText(startValue)
if (edit == false) { if (edit == false) {
@ -374,19 +374,19 @@ func defaultMakeEntry(startValue string, edit bool, action string) *EntryMap {
e.OnChanged(defaultEntryChange) e.OnChanged(defaultEntryChange)
// add the entry field to the global map // add the entry field to the global map
var newEntryMap EntryMap var newEntry GuiEntry
newEntryMap.E = e newEntry.E = e
newEntryMap.Edit = edit newEntry.Edit = edit
newEntryMap.Action = action newEntry.Action = action
if (action == "Memory") { if (action == "Memory") {
newEntryMap.Normalize = normalizeInt newEntry.Normalize = normalizeInt
} }
Data.AllEntries = append(Data.AllEntries, newEntryMap) Data.AllEntries = append(Data.AllEntries, &newEntry)
return &newEntryMap return &newEntry
} }
func makeEntryHbox(hbox *ui.Box, a string, startValue string, edit bool, action string) *EntryMap { func makeEntryHbox(hbox *ui.Box, a string, startValue string, edit bool, action string) *GuiEntry {
// Start 'Nickname' vertical box // Start 'Nickname' vertical box
hboxN := ui.NewHorizontalBox() hboxN := ui.NewHorizontalBox()
hboxN.SetPadded(true) hboxN.SetPadded(true)

View File

@ -11,7 +11,7 @@ import "runtime"
import "github.com/andlabs/ui" import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest" import _ "github.com/andlabs/ui/winmanifest"
func ShowSplashBox(wm *WindowMap, newText *ui.AttributedString) *ui.Box { func ShowSplashBox(wm *GuiWindow, newText *ui.AttributedString) *ui.Box {
log.Println("ShowSplashBox() START") log.Println("ShowSplashBox() START")
log.Println("ShowSplashBox() START wm =", wm) log.Println("ShowSplashBox() START wm =", wm)
if (wm == nil) { if (wm == nil) {

View File

@ -46,9 +46,9 @@ type GuiData struct {
AllButtons []ButtonMap AllButtons []ButtonMap
// A map of all the entry boxes // A map of all the entry boxes
AllEntries []EntryMap AllEntries []*GuiEntry
Windows []*WindowMap Windows []*GuiWindow
EntryNick *ui.Entry EntryNick *ui.Entry
EntryUser *ui.Entry EntryUser *ui.Entry
@ -62,7 +62,7 @@ type TableColumnData struct {
Color string Color string
} }
type EntryMap struct { type GuiEntry struct {
E *ui.Entry E *ui.Entry
Edit bool Edit bool
Last string // the last value Last string // the last value
@ -80,12 +80,14 @@ type EntryMap struct {
Action string // what type of button Action string // what type of button
} }
type WindowMap struct { type GuiWindow struct {
W *ui.Window W *ui.Window
T *ui.Tab T *ui.Tab
Box1 *ui.Box Box1 *ui.Box
Box2 *ui.Box Box2 *ui.Box
EntryMap map[string][]*GuiEntry
C *pb.Config C *pb.Config
AH *AreaHandler AH *AreaHandler
@ -110,7 +112,7 @@ type ButtonMap struct {
AH *AreaHandler AH *AreaHandler
// git.wit.com/wit/gui stuff // git.wit.com/wit/gui stuff
WM *WindowMap WM *GuiWindow
Account *pb.Account Account *pb.Account
VM *pb.Event_VM VM *pb.Event_VM
Action string // what type of button Action string // what type of button
@ -125,7 +127,7 @@ type AreaHandler struct{
Button *ButtonMap Button *ButtonMap
Attrstr *ui.AttributedString Attrstr *ui.AttributedString
Area *ui.Area Area *ui.Area
WM *WindowMap WM *GuiWindow
} }
// AREA STRUCTURES END // AREA STRUCTURES END

View File

@ -10,45 +10,11 @@ import pb "git.wit.com/wit/witProtobuf"
import "github.com/davecgh/go-spew/spew" import "github.com/davecgh/go-spew/spew"
/* func AddVmConfigureTab(wm *GuiWindow, name string, pbVM *pb.Event_VM) {
func GoShowVM() {
ui.Main(ShowVM)
}
func ShowVM() {
name := Data.CurrentVM.Name
log.Println("ShowVM() START Data.CurrentVM=", Data.CurrentVM)
VMwin := ui.NewWindow("VM " + name, 500, 300, false)
// create a 'fake' button entry for the mouse clicks
var newButtonMap ButtonMap
newButtonMap.Action = "WINDOW CLOSE"
newButtonMap.W = VMwin
Data.AllButtons = append(Data.AllButtons, newButtonMap)
VMwin.OnClosing(func(*ui.Window) bool {
mouseClick(&newButtonMap)
return true
})
ui.OnShouldQuit(func() bool {
mouseClick(&newButtonMap)
return true
})
VMtab := ui.NewTab()
VMwin.SetChild(VMtab)
VMwin.SetMargined(true)
CreateVmBox(VMtab, Data.CurrentVM)
VMwin.Show()
}
*/
func AddVmConfigureTab(wm *WindowMap, name string, pbVM *pb.Event_VM) {
CreateVmBox(wm, wm.T, pbVM) CreateVmBox(wm, wm.T, pbVM)
} }
func CreateVmBox(wm *WindowMap, tab *ui.Tab, vm *pb.Event_VM) { func CreateVmBox(wm *GuiWindow, tab *ui.Tab, vm *pb.Event_VM) {
log.Println("CreateVmBox() START") log.Println("CreateVmBox() START")
log.Println("CreateVmBox() vm.Name", vm.Name) log.Println("CreateVmBox() vm.Name", vm.Name)
spew.Dump(vm) spew.Dump(vm)
@ -87,7 +53,7 @@ func CreateVmBox(wm *WindowMap, tab *ui.Tab, vm *pb.Event_VM) {
AddBoxToTab(vm.Name, tab, vbox) AddBoxToTab(vm.Name, tab, vbox)
} }
func createAddVmBox(wm *WindowMap, tab *ui.Tab, name string, b *ButtonMap) { func createAddVmBox(wm *GuiWindow, tab *ui.Tab, name string, b *ButtonMap) {
log.Println("createAddVmBox() START") log.Println("createAddVmBox() START")
vbox := ui.NewVerticalBox() vbox := ui.NewVerticalBox()
vbox.SetPadded(true) vbox.SetPadded(true)