more tab tracking

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-27 10:55:10 -07:00
parent 5c707c2f85
commit 63c818217a
3 changed files with 40 additions and 30 deletions

View File

@ -20,10 +20,11 @@ func AddAccountQuestionBox() *ui.Box {
return newbox return newbox
} }
func AddAccountBox(aTab *GuiTabStructure) { // func AddAccountBox(aTab *GuiTabStructure) {
func AddAccountBox() *ui.Box {
vbox := ui.NewVerticalBox() vbox := ui.NewVerticalBox()
vbox.SetPadded(true) vbox.SetPadded(true)
aTab.firstBox = vbox // aTab.firstBox = vbox
hboxAccount := ui.NewHorizontalBox() hboxAccount := ui.NewHorizontalBox()
hboxAccount.SetPadded(true) hboxAccount.SetPadded(true)
@ -68,13 +69,13 @@ func AddAccountBox(aTab *GuiTabStructure) {
vboxN.SetPadded(true) vboxN.SetPadded(true)
vboxN.Append(ui.NewLabel("Account Nickname:"), false) vboxN.Append(ui.NewLabel("Account Nickname:"), false)
aTab.EntryNick = ui.NewEntry() Data.EntryNick = ui.NewEntry()
aTab.EntryNick.SetReadOnly(false) Data.EntryNick.SetReadOnly(false)
vboxN.Append(aTab.EntryNick, false) vboxN.Append(Data.EntryNick, false)
aTab.EntryNick.OnChanged(func(*ui.Entry) { Data.EntryNick.OnChanged(func(*ui.Entry) {
log.Println("OK. nickname =", aTab.EntryNick.Text()) log.Println("OK. nickname =", Data.EntryNick.Text())
// Data.AccNick = entryNick.Text() // Data.AccNick = entryNick.Text()
}) })
hboxAccount.Append(vboxN, false) hboxAccount.Append(vboxN, false)
@ -85,13 +86,13 @@ func AddAccountBox(aTab *GuiTabStructure) {
vboxU.SetPadded(true) vboxU.SetPadded(true)
vboxU.Append(ui.NewLabel("Account Username:"), false) vboxU.Append(ui.NewLabel("Account Username:"), false)
aTab.EntryUser = ui.NewEntry() Data.EntryUser = ui.NewEntry()
aTab.EntryUser.SetReadOnly(false) Data.EntryUser.SetReadOnly(false)
vboxU.Append(aTab.EntryUser, false) vboxU.Append(Data.EntryUser, false)
aTab.EntryUser.OnChanged(func(*ui.Entry) { Data.EntryUser.OnChanged(func(*ui.Entry) {
log.Println("OK. username =", aTab.EntryUser.Text()) log.Println("OK. username =", Data.EntryUser.Text())
// Data.AccUser = entryUser.Text() // Data.AccUser = entryUser.Text()
}) })
hboxAccount.Append(vboxU, false) hboxAccount.Append(vboxU, false)
@ -102,13 +103,13 @@ func AddAccountBox(aTab *GuiTabStructure) {
vboxP.SetPadded(true) vboxP.SetPadded(true)
vboxP.Append(ui.NewLabel("Account Password:"), false) vboxP.Append(ui.NewLabel("Account Password:"), false)
aTab.EntryPass = ui.NewEntry() Data.EntryPass = ui.NewEntry()
aTab.EntryPass.SetReadOnly(false) Data.EntryPass.SetReadOnly(false)
vboxP.Append(aTab.EntryPass, false) vboxP.Append(Data.EntryPass, false)
aTab.EntryPass.OnChanged(func(*ui.Entry) { Data.EntryPass.OnChanged(func(*ui.Entry) {
log.Println("OK. password =", aTab.EntryPass.Text()) log.Println("OK. password =", Data.EntryPass.Text())
// Data.AccPass = entryPass.Text() // Data.AccPass = entryPass.Text()
}) })
hboxAccount.Append(vboxP, false) hboxAccount.Append(vboxP, false)
@ -125,4 +126,6 @@ func AddAccountBox(aTab *GuiTabStructure) {
backButton := CreateButton(nil, nil, "Back", "BACK", nil) backButton := CreateButton(nil, nil, "Back", "BACK", nil)
hboxButtons.Append(backButton, false) hboxButtons.Append(backButton, false)
return vbox
} }

View File

@ -170,22 +170,27 @@ func ShowAccountQuestionTab() {
Data.cloudTab.SetMargined(0, true) Data.cloudTab.SetMargined(0, true)
} }
func ShowAccountTab() { func ShowAccountTab(i int) {
Data.cloudTab.Delete(0) Data.cloudTab.Delete(0)
log.Println("Sleep(200)") log.Println("Sleep(200)")
time.Sleep(200 * time.Millisecond) time.Sleep(200 * time.Millisecond)
// Create the things for the Account Tab // Create the things for the Account Tab
var aTab GuiTabStructure abox := AddAccountBox()
AddAccountBox(&aTab)
// Set the parents and data structure links // Set the parents and data structure links
aTab.me = Data.cloudTab // aTab.me = Data.cloudTab
aTab.parentWindow = Data.cloudWindow // aTab.parentWindow = Data.cloudWindow
aTab.tabOffset = 0 // aTab.tabOffset = 0
Data.cloudTab.InsertAt("Add Account", 0, aTab.firstBox) if (i >= 0) {
Data.cloudTab.InsertAt("Add Account", 0, abox)
} else {
// this is going to crash, see TODO. This means index is -1
// TODO: Do append here and discover tab index #
Data.cloudTab.InsertAt("Add Account", 0, abox)
}
Data.cloudTab.SetMargined(0, true) Data.cloudTab.SetMargined(0, true)
} }
@ -374,7 +379,7 @@ func createAddVmBox(tab *ui.Tab, name string, b *ButtonMap) {
hboxButtons.SetPadded(true) hboxButtons.SetPadded(true)
vbox.Append(hboxButtons, false) vbox.Append(hboxButtons, false)
hboxButtons.Append(CreateButton(nil, nil, "Add Virtual Machine","ADD", nil), false) hboxButtons.Append(CreateButton(nil, nil, "Add Virtual Machine","CREATE",nil), false)
hboxButtons.Append(CreateButton(nil, nil, "Cancel", "CLOSE", nil), false) hboxButtons.Append(CreateButton(nil, nil, "Cancel", "CLOSE", nil), false)
name += " (" + b.Account.Nick + ")" name += " (" + b.Account.Nick + ")"

View File

@ -15,16 +15,13 @@ import pb "git.wit.com/wit/witProtobuf"
var Data GuiDataStructure var Data GuiDataStructure
var myAH areaHandler var myAH areaHandler
/*
type GuiTabStructure struct { type GuiTabStructure struct {
me *ui.Tab me *ui.Tab
parentWindow *ui.Window parentWindow *ui.Window
firstBox *ui.Box firstBox *ui.Box
tabOffset int tabOffset int
EntryNick *ui.Entry
EntryUser *ui.Entry
EntryPass *ui.Entry
// this means only one table per tab // this means only one table per tab
mh *TableData mh *TableData
@ -34,6 +31,7 @@ type GuiTabStructure struct {
attrstr *ui.AttributedString attrstr *ui.AttributedString
splashArea *ui.Area splashArea *ui.Area
} }
*/
type GuiDataStructure struct { type GuiDataStructure struct {
State string State string
@ -71,7 +69,11 @@ type GuiDataStructure struct {
CurrentVM *pb.Event_VM CurrentVM *pb.Event_VM
// All the tabs // All the tabs
Tabs []GuiTabStructure // Tabs []GuiTabStructure
EntryNick *ui.Entry
EntryUser *ui.Entry
EntryPass *ui.Entry
// stuff for the splash screen / setup tabs // stuff for the splash screen / setup tabs
cloudWindow *ui.Window cloudWindow *ui.Window