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 "log"
|
||||||
import "github.com/andlabs/ui"
|
import "github.com/andlabs/ui"
|
||||||
import _ "github.com/andlabs/ui/winmanifest"
|
import _ "github.com/andlabs/ui/winmanifest"
|
||||||
import pb "git.wit.com/wit/witProtobuf"
|
|
||||||
// import "github.com/davecgh/go-spew/spew"
|
// import "github.com/davecgh/go-spew/spew"
|
||||||
|
|
||||||
// This is the default mouse click handler
|
// This is the default mouse click handler
|
||||||
|
@ -38,7 +37,7 @@ func defaultButtonClick(button *ui.Button) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func guiButtonClick(button *GuiButton) {
|
func guiButtonClick(button *GuiButton) {
|
||||||
log.Println("\tgui.guiButtonClick() button.Action =", button.Action)
|
log.Println("\tgui.guiButtonClick() button.Name =", button.Name)
|
||||||
if button.Custom != nil {
|
if button.Custom != nil {
|
||||||
log.Println("\tgui.guiButtonClick() DOING CUSTOM FUNCTION")
|
log.Println("\tgui.guiButtonClick() DOING CUSTOM FUNCTION")
|
||||||
button.Custom(button)
|
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 {
|
func NewCreateButton(box *GuiBox, custom func(*GuiButton), name string, values interface {}) *GuiButton {
|
||||||
newUiB := ui.NewButton(name)
|
newUiB := ui.NewButton(name)
|
||||||
newUiB.OnClicked(defaultButtonClick)
|
newUiB.OnClicked(defaultButtonClick)
|
||||||
|
@ -82,7 +59,8 @@ func NewCreateButton(box *GuiBox, custom func(*GuiButton), name string, values i
|
||||||
newB.B = newUiB
|
newB.B = newUiB
|
||||||
if (box.Window == nil) {
|
if (box.Window == nil) {
|
||||||
log.Println("CreateButton() 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.Box = box
|
||||||
newB.Custom = custom
|
newB.Custom = custom
|
||||||
|
@ -98,7 +76,6 @@ func CreateFontButton(box *GuiBox, action string) *GuiButton {
|
||||||
// create a 'fake' button entry for the mouse clicks
|
// create a 'fake' button entry for the mouse clicks
|
||||||
var newGB GuiButton
|
var newGB GuiButton
|
||||||
newGB.Name = "FONT"
|
newGB.Name = "FONT"
|
||||||
newGB.Action = action
|
|
||||||
newGB.FB = ui.NewFontButton()
|
newGB.FB = ui.NewFontButton()
|
||||||
newGB.Box = box
|
newGB.Box = box
|
||||||
Data.AllButtons = append(Data.AllButtons, &newGB)
|
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"
|
||||||
import _ "github.com/andlabs/ui/winmanifest"
|
import _ "github.com/andlabs/ui/winmanifest"
|
||||||
|
|
||||||
import pb "git.wit.com/wit/witProtobuf"
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// All GUI Data Structures and functions that are external
|
// All GUI Data Structures and functions that are external
|
||||||
// If you need cross platform support, these might only
|
// If you need cross platform support, these might only
|
||||||
|
@ -101,9 +99,7 @@ type GuiButton struct {
|
||||||
Custom func (*GuiButton)
|
Custom func (*GuiButton)
|
||||||
Values interface {}
|
Values interface {}
|
||||||
|
|
||||||
Action string // what type of button
|
// Action string // what type of button
|
||||||
Account *pb.Account // associated with what account?
|
|
||||||
VM *pb.Event_VM // associated with which VM?
|
|
||||||
|
|
||||||
// andlabs/ui abstraction mapping
|
// andlabs/ui abstraction mapping
|
||||||
B *ui.Button
|
B *ui.Button
|
||||||
|
|
Loading…
Reference in New Issue