This might be stable enough to leave alone.
Up to this point it's been needing 10 patches a day. Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
f79fe8be57
commit
abd061ae58
29
button.go
29
button.go
|
@ -3,7 +3,6 @@ package gui
|
|||
import "log"
|
||||
import "github.com/andlabs/ui"
|
||||
import _ "github.com/andlabs/ui/winmanifest"
|
||||
import pb "git.wit.com/wit/witProtobuf"
|
||||
// import "github.com/davecgh/go-spew/spew"
|
||||
|
||||
// This is the default mouse click handler
|
||||
|
@ -38,7 +37,7 @@ func defaultButtonClick(button *ui.Button) {
|
|||
}
|
||||
|
||||
func guiButtonClick(button *GuiButton) {
|
||||
log.Println("\tgui.guiButtonClick() button.Action =", button.Action)
|
||||
log.Println("\tgui.guiButtonClick() button.Name =", button.Name)
|
||||
if button.Custom != nil {
|
||||
log.Println("\tgui.guiButtonClick() DOING CUSTOM FUNCTION")
|
||||
button.Custom(button)
|
||||
|
@ -51,28 +50,6 @@ func guiButtonClick(button *GuiButton) {
|
|||
}
|
||||
}
|
||||
|
||||
func CreateButton(box *GuiBox, a *pb.Account, vm *pb.Event_VM, name string, action string, custom func(*GuiButton)) *GuiButton {
|
||||
newUiB := ui.NewButton(name)
|
||||
newUiB.OnClicked(defaultButtonClick)
|
||||
|
||||
var newB *GuiButton
|
||||
newB = new(GuiButton)
|
||||
newB.B = newUiB
|
||||
if (box.Window == nil) {
|
||||
log.Println("CreateButton() box.Window == nil")
|
||||
panic("crap")
|
||||
}
|
||||
newB.Account = a
|
||||
newB.VM = vm
|
||||
newB.Box = box
|
||||
newB.Action = action
|
||||
newB.Custom = custom
|
||||
Data.AllButtons = append(Data.AllButtons, newB)
|
||||
|
||||
box.UiBox.Append(newB.B, false)
|
||||
return newB
|
||||
}
|
||||
|
||||
func NewCreateButton(box *GuiBox, custom func(*GuiButton), name string, values interface {}) *GuiButton {
|
||||
newUiB := ui.NewButton(name)
|
||||
newUiB.OnClicked(defaultButtonClick)
|
||||
|
@ -82,7 +59,8 @@ func NewCreateButton(box *GuiBox, custom func(*GuiButton), name string, values i
|
|||
newB.B = newUiB
|
||||
if (box.Window == nil) {
|
||||
log.Println("CreateButton() box.Window == nil")
|
||||
panic("crap")
|
||||
// ErrorWindow(box.Window, "Login Failed", msg) // can't even do this
|
||||
panic("maybe print an error and return nil? or make a fake button?")
|
||||
}
|
||||
newB.Box = box
|
||||
newB.Custom = custom
|
||||
|
@ -98,7 +76,6 @@ func CreateFontButton(box *GuiBox, action string) *GuiButton {
|
|||
// create a 'fake' button entry for the mouse clicks
|
||||
var newGB GuiButton
|
||||
newGB.Name = "FONT"
|
||||
newGB.Action = action
|
||||
newGB.FB = ui.NewFontButton()
|
||||
newGB.Box = box
|
||||
Data.AllButtons = append(Data.AllButtons, &newGB)
|
||||
|
|
|
@ -6,8 +6,6 @@ import "golang.org/x/image/font"
|
|||
import "github.com/andlabs/ui"
|
||||
import _ "github.com/andlabs/ui/winmanifest"
|
||||
|
||||
import pb "git.wit.com/wit/witProtobuf"
|
||||
|
||||
//
|
||||
// All GUI Data Structures and functions that are external
|
||||
// If you need cross platform support, these might only
|
||||
|
@ -101,9 +99,7 @@ type GuiButton struct {
|
|||
Custom func (*GuiButton)
|
||||
Values interface {}
|
||||
|
||||
Action string // what type of button
|
||||
Account *pb.Account // associated with what account?
|
||||
VM *pb.Event_VM // associated with which VM?
|
||||
// Action string // what type of button
|
||||
|
||||
// andlabs/ui abstraction mapping
|
||||
B *ui.Button
|
||||
|
|
Loading…
Reference in New Issue