diff options
| author | Jeff Carr <[email protected]> | 2019-05-24 01:51:37 -0700 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2019-05-24 01:51:37 -0700 |
| commit | 9b29c265b26d1231cf9ddb7abf51e390197dabf1 (patch) | |
| tree | bf9465bc361dd5260f573c155bf29e7551f15902 | |
| parent | 9949a02b3e0d953824568fc5085009243c92cc86 (diff) | |
more button debugging
Signed-off-by: Jeff Carr <[email protected]>
| -rw-r--r-- | addAccount.go | 4 | ||||
| -rw-r--r-- | area.go | 4 | ||||
| -rw-r--r-- | debug.go | 2 | ||||
| -rw-r--r-- | gui.go | 12 | ||||
| -rw-r--r-- | mainCloudBox.go | 2 | ||||
| -rw-r--r-- | splash.go | 2 | ||||
| -rw-r--r-- | tabWindow.go | 4 | ||||
| -rw-r--r-- | vmWindow.go | 31 |
8 files changed, 38 insertions, 23 deletions
diff --git a/addAccount.go b/addAccount.go index e90e5be..8b9f395 100644 --- a/addAccount.go +++ b/addAccount.go @@ -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) @@ -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) { @@ -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) @@ -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) diff --git a/mainCloudBox.go b/mainCloudBox.go index fd4fb75..1e1292a 100644 --- a/mainCloudBox.go +++ b/mainCloudBox.go @@ -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) @@ -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) diff --git a/tabWindow.go b/tabWindow.go index dd82af2..e08b4cf 100644 --- a/tabWindow.go +++ b/tabWindow.go @@ -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") diff --git a/vmWindow.go b/vmWindow.go index 3f7bcdc..aff1e57 100644 --- a/vmWindow.go +++ b/vmWindow.go @@ -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) + } } |
