more button debugging

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-24 01:51:37 -07:00
parent 9949a02b3e
commit 9b29c265b2
8 changed files with 38 additions and 23 deletions

View File

@ -5,7 +5,7 @@ import "log"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
func AddAccountQuestionBox(junk *ui.Box, custom func(int, string)) *ui.Box {
func AddAccountQuestionBox(junk *ui.Box, custom func(*ButtonMap, string)) *ui.Box {
newbox := ui.NewVerticalBox()
newbox.SetPadded(true)
@ -20,7 +20,7 @@ func AddAccountQuestionBox(junk *ui.Box, custom func(int, string)) *ui.Box {
return newbox
}
func AddAccountBox(custom func(int, string)) *ui.Box {
func AddAccountBox(custom func(*ButtonMap, string)) *ui.Box {
vbox := ui.NewVerticalBox()
vbox.SetPadded(true)

View File

@ -7,7 +7,7 @@ import _ "github.com/andlabs/ui/winmanifest"
import "github.com/davecgh/go-spew/spew"
func makeSplashArea(custom func(int, string)) *ui.Area {
func makeSplashArea(custom func(*ButtonMap, string)) *ui.Area {
// make this button just to get the default font (but don't display the button)
// There should be another way to do this (?)
Data.fontButton = CreateFontButton("SplashFont", "DONE", custom)
@ -75,8 +75,8 @@ func (ah areaHandler) Draw(a *ui.Area, p *ui.AreaDrawParams) {
}
func (ah areaHandler) MouseEvent(a *ui.Area, me *ui.AreaMouseEvent) {
log.Println("GOT MouseEvent()")
if (Data.Debug) {
log.Println("GOT MouseEvent()")
spew.Dump(me)
}
if (me.Down == 1) {

View File

@ -53,7 +53,7 @@ func addTableTab() {
AddTableTab(Data.cloudTab, 1, "test seven", 7, parts)
}
func addDebuggingButtons(vbox *ui.Box, custom func(int, string)) {
func addDebuggingButtons(vbox *ui.Box, custom func(*ButtonMap, string)) {
vbox.Append(ui.NewLabel("Debugging:"), false)
vbox.Append(ui.NewColorButton(), false)

12
gui.go
View File

@ -70,7 +70,7 @@ type ButtonMap struct {
FB *ui.FontButton
onClick func (int, string)
onChanged func (int, string)
custom func (int, string)
custom func (*ButtonMap, string)
Name string // the text on the button
Note string // what type of button
AccNick string // what account this button is for
@ -188,7 +188,7 @@ func defaultButtonClick(button *ui.Button) {
if (Data.ButtonClick != nil) {
Data.ButtonClick( &Data.allButtons[key])
} else if Data.allButtons[key].custom != nil {
Data.allButtons[key].custom(42, "BUTTON DOES NOTHING")
Data.allButtons[key].custom(nil, "BUTTON DOES NOTHING")
}
return
}
@ -203,7 +203,7 @@ func defaultFontButtonClick(button *ui.FontButton) {
}
}
func CreateButton(name string, note string, custom func(int, string)) *ui.Button {
func CreateButton(name string, note string, custom func(*ButtonMap, string)) *ui.Button {
newB := ui.NewButton(name)
newB.OnClicked(defaultButtonClick)
@ -218,7 +218,7 @@ func CreateButton(name string, note string, custom func(int, string)) *ui.Button
return newB
}
func CreateAccountButton(account string, custom func(int, string)) *ui.Button {
func CreateAccountButton(account string, custom func(*ButtonMap, string)) *ui.Button {
name := "Show " + account
newB := ui.NewButton(name)
@ -235,7 +235,7 @@ func CreateAccountButton(account string, custom func(int, string)) *ui.Button {
return newB
}
func CreateLoginButton(account string, custom func(int, string)) *ui.Button {
func CreateLoginButton(account string, custom func(*ButtonMap, string)) *ui.Button {
name := "Login " + account
newB := ui.NewButton(name)
@ -252,7 +252,7 @@ func CreateLoginButton(account string, custom func(int, string)) *ui.Button {
return newB
}
func CreateFontButton(name string, note string, custom func(int, string)) *ui.FontButton {
func CreateFontButton(name string, note string, custom func(*ButtonMap, string)) *ui.FontButton {
newB := ui.NewFontButton()
newB.OnChanged(defaultFontButtonClick)

View File

@ -11,7 +11,7 @@ import _ "github.com/andlabs/ui/winmanifest"
// import "github.com/davecgh/go-spew/spew"
func makeCloudInfoBox(custom func(int, string)) *ui.Box {
func makeCloudInfoBox(custom func(*ButtonMap, string)) *ui.Box {
hbox := ui.NewHorizontalBox()
hbox.SetPadded(true)

View File

@ -10,7 +10,7 @@ import "runtime"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
func ShowSplashBox(vbox *ui.Box, atest chan int, custom func(int, string)) *ui.Box {
func ShowSplashBox(vbox *ui.Box, atest chan int, custom func(*ButtonMap, string)) *ui.Box {
newbox := ui.NewVerticalBox()
newbox.SetPadded(true)

View File

@ -8,8 +8,8 @@ import _ "github.com/andlabs/ui/winmanifest"
// import "github.com/davecgh/go-spew/spew"
func buttonClick(i int, s string) {
log.Println("gui.buttonClick() i, s =", i, s)
func buttonClick(b *ButtonMap, s string) {
log.Println("gui.buttonClick() b, s =", b, s)
log.Println("Figure out what to do here")
log.Println("Figure out what to do here")
log.Println("Figure out what to do here")

View File

@ -22,20 +22,22 @@ func ShowVM() {
VMwin.SetChild(VMtab)
VMwin.SetMargined(true)
vmBox := createVmBox(buttonClick)
VMtab.Append(Data.CurrentVM, vmBox)
VMtab.SetMargined(0, true)
createVmBox(VMtab, buttonVmClick)
// vmBox := createVmBox(buttonVmClick)
// VMtab.Append(Data.CurrentVM, vmBox)
// VMtab.SetMargined(0, true)
VMwin.Show()
}
func AddVmConfigureTab(name string) {
vmBox := createVmBox(buttonClick)
Data.cloudTab.Append(name, vmBox)
Data.cloudTab.SetMargined(0, true)
createVmBox(Data.cloudTab, buttonVmClick)
// vmBox := createVmBox(Data.cloudTab, buttonVmClick)
// Data.cloudTab.Append(name, vmBox)
// Data.cloudTab.SetMargined(0, true)
}
func createVmBox(custom func(int, string)) *ui.Box {
func createVmBox(tab *ui.Tab, custom func(b *ButtonMap,s string)) {
vbox := ui.NewVerticalBox()
vbox.SetPadded(true)
@ -140,5 +142,18 @@ func createVmBox(custom func(int, string)) *ui.Box {
backButton := CreateButton("Back", "BACK", custom)
hboxButtons.Append(backButton, false)
return vbox
hboxButtons.Append(CreateButton("Power On", "POWERON", custom), false)
hboxButtons.Append(CreateButton("Power Off", "POWEROFF", custom), false)
hboxButtons.Append(CreateButton("Destroy", "DESTROY", custom), false)
tab.Append(Data.CurrentVM, vbox)
tab.SetMargined(0, true)
}
func buttonVmClick(b *ButtonMap, s string) {
log.Println("gui.buttonVmClick() START")
if (Data.ButtonClick != nil) {
log.Println("Data.ButtonClick() START")
Data.ButtonClick(nil)
}
}