change CreateButton to rerturn *GuiButton

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-30 11:41:23 -07:00
parent 30fc964c5e
commit 403e7d089c
6 changed files with 54 additions and 32 deletions

View File

@ -41,14 +41,14 @@ func AddAccountQuestionBox(wm *GuiWindow) *ui.Box {
hbox.Append(ui.NewLabel("Enter your Subdomain or"), false)
generate := CreateButton(wm, nil, nil, "Generate", "SUBDOMAIN", generateSubdomain)
hbox.Append(generate, false)
hbox.Append(generate.B, false)
AddEntry(gb, "SUBDOMAIN")
vbox.Append(ui.NewHorizontalSeparator(), false)
okButton := CreateButton(wm, nil, nil, "Create Subdomain Account", "SUBDOMAIN", addSubdomain)
vbox.Append(okButton, false)
vbox.Append(okButton.B, false)
return vbox
}
@ -179,10 +179,10 @@ func AddAccountBox(wm *GuiWindow) *ui.Box {
vbox.Append(hboxButtons, false)
okButton := CreateButton(wm, nil, nil, "Add Account", "ADD", nil)
hboxButtons.Append(okButton, false)
hboxButtons.Append(okButton.B, false)
backButton := CreateButton(wm, nil, nil, "Back", "BACK", nil)
hboxButtons.Append(backButton, false)
hboxButtons.Append(backButton.B, false)
return vbox
}

View File

@ -60,8 +60,10 @@ func addDebuggingButtons(wm *GuiWindow, vbox *ui.Box) {
vbox.Append(ui.NewLabel("Debugging:"), false)
vbox.Append(ui.NewColorButton(), false)
vbox.Append(CreateButton(wm, nil, nil, "Add Account", "ADD", nil), false)
vbox.Append(CreateButton(wm, nil, nil, "Quit", "QUIT", nil), false)
a := CreateButton(wm, nil, nil, "Add Account", "ADD", nil)
vbox.Append(a.B, false)
a = CreateButton(wm, nil, nil, "Quit", "QUIT", nil)
vbox.Append(a.B, false)
// ATTEMPT TO ADD THE TABLE HERE
add2button := ui.NewButton("Add a Test Table")
@ -72,12 +74,17 @@ func addDebuggingButtons(wm *GuiWindow, vbox *ui.Box) {
vbox.Append(add2button, false)
// ATTEMPT TO ADD THE TABLE HERE END
vbox.Append(CreateButton(wm, nil, nil, "Hide & Show Box1&2", "HIDE", runTestHide), false)
a = CreateButton(wm, nil, nil, "Hide & Show Box1&2", "HIDE", runTestHide)
vbox.Append(a.B, false)
vbox.Append(CreateButton(wm, nil, nil, "Close GUI", "QUIT", nil), false)
vbox.Append(CreateButton(wm, nil, nil, "DEBUG goroutines", "DEBUG", nil), false)
vbox.Append(CreateButton(wm, nil, nil, "xterm", "XTERM", runTestExecClick), false)
vbox.Append(CreateButton(wm, nil, nil, "Load test.json config file", "CONFIG", nil), false)
a = CreateButton(wm, nil, nil, "Close GUI", "QUIT", nil)
vbox.Append(a.B, false)
a = CreateButton(wm, nil, nil, "DEBUG goroutines", "DEBUG", nil)
vbox.Append(a.B, false)
a = CreateButton(wm, nil, nil, "xterm", "XTERM", runTestExecClick)
vbox.Append(a.B, false)
a = CreateButton(wm, nil, nil, "Load test.json config file", "CONFIG", nil)
vbox.Append(a.B, false)
}
func runTestHide(b *GuiButton) {

15
gui.go
View File

@ -90,8 +90,10 @@ func AddTableTab(wm *GuiWindow, mytab *ui.Tab, junk int, name string, rowcount i
hbox := ui.NewHorizontalBox()
hbox.SetPadded(true)
hbox.Append(CreateButton(wm, account, nil, "Add Virtual Machine", "createAddVmBox", nil), false)
hbox.Append(CreateButton(wm, account, nil, "Close", "CLOSE", nil), false)
a := CreateButton(wm, account, nil, "Add Virtual Machine", "createAddVmBox", nil)
hbox.Append(a.B, false)
b := CreateButton(wm, account, nil, "Add Virtual Machine", "createAddVmBox", nil)
hbox.Append(b.B, false)
vbox.Append(hbox, false)
@ -210,11 +212,12 @@ func AddButton(b *GuiButton, name string) *ui.Button {
}
func CreateButton(wm *GuiWindow, a *pb.Account, vm *pb.Event_VM,
name string, action string, custom func(*GuiButton)) *ui.Button {
name string, action string, custom func(*GuiButton)) *GuiButton {
newUiB := ui.NewButton(name)
newUiB.OnClicked(defaultButtonClick)
var newB GuiButton
var newB *GuiButton
newB = new(GuiButton)
newB.B = newUiB
newB.T = wm.T
newB.Account = a
@ -222,9 +225,9 @@ func CreateButton(wm *GuiWindow, a *pb.Account, vm *pb.Event_VM,
newB.WM = wm
newB.Action = action
newB.custom = custom
Data.AllButtons = append(Data.AllButtons, newB)
Data.AllButtons = append(Data.AllButtons, *newB)
return newUiB
return newB
}
func CreateFontButton(wm *GuiWindow, action string) *GuiButton {

View File

@ -46,7 +46,8 @@ func makeCloudInfoBox(wm *GuiWindow) *ui.Box {
hostnameEntry.SetText(tmp)
hostnameEntry.SetReadOnly(true)
hostnamebox.Append(CreateButton(wm, nil, nil, "Edit", "EDIT", nil), false)
anew := CreateButton(wm, nil, nil, "Edit", "EDIT", nil)
hostnamebox.Append(anew.B, false)
vbox.Append(ui.NewHorizontalSeparator(), false)
@ -73,11 +74,11 @@ func makeCloudInfoBox(wm *GuiWindow) *ui.Box {
name := "Login " + Data.Config.Accounts[key].Nick
l := CreateButton(wm, Data.Config.Accounts[key], nil, name, "LOGIN", nil)
agrid.Append(l, 4, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
agrid.Append(l.B, 4, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
name = "Show " + Data.Config.Accounts[key].Nick
b := CreateButton(wm, Data.Config.Accounts[key], nil, name, "SHOW", nil)
agrid.Append(b, 5, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
agrid.Append(b.B, 5, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
row += 1
}
@ -86,9 +87,9 @@ func makeCloudInfoBox(wm *GuiWindow) *ui.Box {
agrid.Append(ui.NewLabel(""), 1, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
row += 1
a := CreateButton(wm, nil, nil, "Add Account", "ADD TAB", nil)
agrid.Append(a, 4, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
agrid.Append(a.B, 4, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
q := CreateButton(wm, nil, nil, "Quit", "QUIT", nil)
agrid.Append(q, 5, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
agrid.Append(q.B, 5, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
vbox.Append(agrid, false)
return hbox

View File

@ -57,9 +57,12 @@ func ShowSplashBox(wm *GuiWindow, newText *ui.AttributedString) *ui.Box {
}
log.Println("ShowSplashBox() START wm =", wm)
okButton := CreateButton(wm, nil, nil, "OK", "AREA", nil)
newbox.Append(okButton, false)
newbox.Append(CreateButton(wm, nil, nil, "NEWTEXT", "NEWTEXT", nil), false)
newbox.Append(okButton.B, false)
okButton = CreateButton(wm, nil, nil, "NEWTEXT", "NEWTEXT", nil)
newbox.Append(okButton.B, false)
// os.Exit(0)
return newbox

View File

@ -42,13 +42,20 @@ func CreateVmBox(wm *GuiWindow, tab *ui.Tab, vm *pb.Event_VM) {
hboxButtons.SetPadded(true)
vbox.Append(hboxButtons, false)
hboxButtons.Append(CreateButton(wm, nil, vm, "Power On", "POWERON", nil), false)
hboxButtons.Append(CreateButton(wm, nil, vm, "Power Off", "POWEROFF", nil), false)
hboxButtons.Append(CreateButton(wm, nil, vm, "Destroy", "DESTROY", nil), false)
hboxButtons.Append(CreateButton(wm, nil, vm, "ping", "PING", runPingClick), false)
hboxButtons.Append(CreateButton(wm, nil, vm, "Console", "XTERM", runTestExecClick), false)
hboxButtons.Append(CreateButton(wm, nil, vm, "Save", "SAVE", nil), false)
hboxButtons.Append(CreateButton(wm, nil, vm, "Done", "DONE", nil), false)
a := CreateButton(wm, nil, vm, "Power On", "POWERON", nil)
hboxButtons.Append(a.B, false)
a = CreateButton(wm, nil, vm, "Power Off", "POWEROFF", nil)
hboxButtons.Append(a.B, false)
a = CreateButton(wm, nil, vm, "Destroy", "DESTROY", nil)
hboxButtons.Append(a.B, false)
a = CreateButton(wm, nil, vm, "ping", "PING", runPingClick)
hboxButtons.Append(a.B, false)
a = CreateButton(wm, nil, vm, "Console", "XTERM", runTestExecClick)
hboxButtons.Append(a.B, false)
a = CreateButton(wm, nil, vm, "Save", "SAVE", nil)
hboxButtons.Append(a.B, false)
a = CreateButton(wm, nil, vm, "Done", "DONE", nil)
hboxButtons.Append(a.B, false)
AddBoxToTab(vm.Name, tab, vbox)
}
@ -86,7 +93,8 @@ func createAddVmBox(wm *GuiWindow, tab *ui.Tab, name string, b *GuiButton) {
hboxButtons.Append(AddButton(&newb, "Add Virtual Machine"), false)
// hboxButtons.Append(CreateButton(nil, nil, "Add Virtual Machine","CREATE",nil), false)
hboxButtons.Append(CreateButton(wm, nil, nil, "Cancel", "CLOSE", nil), false)
a := CreateButton(wm, nil, nil, "Cancel", "CLOSE", nil)
hboxButtons.Append(a.B, false)
name += " (" + b.Account.Nick + ")"
AddBoxToTab(name, tab, vbox)