summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2019-06-02 22:22:04 -0700
committerJeff Carr <[email protected]>2019-06-02 22:22:04 -0700
commit5336ee2444a831e10600f8573d4460e7d7e3f9e8 (patch)
treeb4839dbc86267fbf46ef2bbbe04fa62be1d6391b
parent4c76bfac47ff1ac0a9901e489e11c97b537168d7 (diff)
make a buttonMap
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--button.go2
-rw-r--r--debug.go2
-rw-r--r--gui.go4
-rw-r--r--structs.go5
4 files changed, 7 insertions, 6 deletions
diff --git a/button.go b/button.go
index d605fd9..bf36f23 100644
--- a/button.go
+++ b/button.go
@@ -50,7 +50,7 @@ func guiButtonClick(button *GuiButton) {
}
}
-func NewCreateButton(box *GuiBox, custom func(*GuiButton), name string, values interface {}) *GuiButton {
+func CreateButton(box *GuiBox, custom func(*GuiButton), name string, values interface {}) *GuiButton {
newUiB := ui.NewButton(name)
newUiB.OnClicked(defaultButtonClick)
diff --git a/debug.go b/debug.go
index e3bdc97..42937d1 100644
--- a/debug.go
+++ b/debug.go
@@ -19,7 +19,7 @@ func WatchGUI() {
for {
if (count > 20) {
- log.Println("Sleep() in watchGUI() Data.State =", Data.State)
+ log.Println("Sleep() in watchGUI()")
for i, window := range Data.Windows {
log.Println("watchGUI() Data.Windows", i, "Name =", window.Name)
for name, abox := range window.BoxMap {
diff --git a/gui.go b/gui.go
index 5784a9d..fb8408b 100644
--- a/gui.go
+++ b/gui.go
@@ -11,6 +11,7 @@ const Xaxis = 0
const Yaxis = 1
func GuiInit() {
+ Data.buttonMap = make(map[*ui.Button]*GuiButton)
ui.OnShouldQuit(func() bool {
ui.Quit()
return true
@@ -31,6 +32,9 @@ func InitGuiWindow(action string, gw *GuiWindow) *GuiWindow {
newGuiWindow.EntryMap["test"] = nil
Data.Windows = append(Data.Windows, &newGuiWindow)
+ if (Data.buttonMap == nil) {
+ GuiInit()
+ }
log.Println("InitGuiWindow() END *GuiWindow =", &newGuiWindow)
return &newGuiWindow
}
diff --git a/structs.go b/structs.go
index ec5c04e..af5264c 100644
--- a/structs.go
+++ b/structs.go
@@ -22,8 +22,6 @@ type GuiConfig struct {
}
type GuiData struct {
- State string // used like a state machine
-
// a fallback default function to handle mouse events
// if nothing else is defined to handle them
MouseClick func(*GuiButton)
@@ -39,6 +37,7 @@ type GuiData struct {
// This has to work this way because of how
// andlabs/ui & andlabs/libui work
AllButtons []*GuiButton
+ buttonMap map[*ui.Button]*GuiButton
}
//
@@ -61,7 +60,6 @@ type GuiData struct {
//
type GuiWindow struct {
Name string // field for human readable name
-// Action string
Width int
Height int
@@ -108,7 +106,6 @@ type GuiButton struct {
// text entry fields
type GuiEntry struct {
Name string // field for human readable name
-// Action string // what type of button
Edit bool
Last string // the last value
Normalize func (string) string // function to 'normalize' the data