summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--area.go4
-rw-r--r--debug.go58
-rw-r--r--gui.go29
-rw-r--r--structs.go1
4 files changed, 62 insertions, 30 deletions
diff --git a/area.go b/area.go
index 732b241..3c41f62 100644
--- a/area.go
+++ b/area.go
@@ -107,7 +107,7 @@ func (ah GuiArea) KeyEvent(a *ui.Area, ke *ui.AreaKeyEvent) (handled bool) {
return false
}
-func ShowTextBox(gw *GuiWindow, newText *ui.AttributedString, custom func(*GuiButton)) *GuiBox {
+func ShowTextBox(gw *GuiWindow, newText *ui.AttributedString, custom func(*GuiButton), name string) *GuiBox {
log.Println("ShowTextBox() START")
if (gw == nil) {
log.Println("ShowTextBox() ERROR gw = nil")
@@ -118,7 +118,7 @@ func ShowTextBox(gw *GuiWindow, newText *ui.AttributedString, custom func(*GuiBu
var newbox *GuiBox
newbox = new(GuiBox)
newbox.Window = gw
- newbox.Name = "Hbox1"
+ newbox.Name = name
hbox := ui.NewVerticalBox()
newbox.UiBox = hbox
diff --git a/debug.go b/debug.go
index 42937d1..1a20532 100644
--- a/debug.go
+++ b/debug.go
@@ -3,11 +3,11 @@ package gui
import "log"
import "time"
import "fmt"
-// import "reflect"
+import "reflect"
// import "github.com/andlabs/ui"
// import _ "github.com/andlabs/ui/winmanifest"
-// import "github.com/davecgh/go-spew/spew"
+import "github.com/davecgh/go-spew/spew"
// import pb "git.wit.com/wit/witProtobuf"
//
@@ -20,24 +20,8 @@ func WatchGUI() {
for {
if (count > 20) {
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 {
- log.Printf("\twatchGUI() BOX mapname=%-12s abox.Name=%-12s", name, abox.Name)
- /*
- if (name == "DEBUG") {
- log.Println("\t\twatchGUI() BOX abox =", reflect.TypeOf(abox))
- win := abox.Window
- log.Println("\t\twatchGUI() BOX win =", reflect.TypeOf(win))
- area := win.Area
- log.Println("\t\twatchGUI() BOX area =", reflect.TypeOf(area), area.UiArea)
- // spew.Dump(area.UiArea)
- // area.UiArea.Show()
- // time.Sleep(2000 * time.Millisecond)
- // os.Exit(0)
- }
- */
- }
+ if (Config.Debug) {
+ DumpBoxes()
}
count = 0
}
@@ -46,6 +30,40 @@ func WatchGUI() {
}
}
+func DumpBoxes() {
+ for name, window := range Data.WindowMap {
+ log.Println("gui.DumpBoxes()", name)
+ log.Println("gui.DumpBoxes()\tWindow.name =", window.Name)
+ log.Println("gui.DumpBoxes()\tWindow.UiWindow type =", reflect.TypeOf(window.UiWindow))
+ log.Println("gui.DumpBoxes()\tWindow.UiWindow =", window.UiWindow)
+ if (window.UiTab != nil) {
+ log.Println("gui.DumpBoxes()\tWindow.UiTab type =", reflect.TypeOf(window.UiTab))
+ log.Println("gui.DumpBoxes()\tWindow.UiTab =", window.UiTab)
+ log.Println("gui.DumpBoxes()\tWindow.UiTab.NumPages() =", window.UiTab.NumPages())
+ spew.Dump(window.UiTab)
+ }
+ }
+ for i, window := range Data.Windows {
+ log.Println("gui.DumpBoxes() Data.Windows", i, "Name =", window.Name)
+ for name, abox := range window.BoxMap {
+ log.Printf("gui.DumpBoxes() \tBOX mapname=%-12s abox.Name=%-12s", name, abox.Name)
+ /*
+ if (name == "DEBUG") {
+ log.Println("\t\twatchGUI() BOX abox =", reflect.TypeOf(abox))
+ win := abox.Window
+ log.Println("\t\twatchGUI() BOX win =", reflect.TypeOf(win))
+ area := win.Area
+ log.Println("\t\twatchGUI() BOX area =", reflect.TypeOf(area), area.UiArea)
+ // spew.Dump(area.UiArea)
+ // area.UiArea.Show()
+ // time.Sleep(2000 * time.Millisecond)
+ // os.Exit(0)
+ }
+ */
+ }
+ }
+}
+
func addTableTab() {
var parts []TableColumnData
diff --git a/gui.go b/gui.go
index 0bb6310..ef1ff49 100644
--- a/gui.go
+++ b/gui.go
@@ -12,25 +12,35 @@ const Yaxis = 1 // box that is vertical
func GuiInit() {
Data.buttonMap = make(map[*ui.Button]*GuiButton)
+ Data.WindowMap = make(map[string]*GuiWindow)
+
ui.OnShouldQuit(func() bool {
ui.Quit()
return true
})
}
-func InitGuiWindow(action string, gw *GuiWindow) *GuiWindow {
+func InitGuiWindow(name string, gw *GuiWindow) *GuiWindow {
log.Println("InitGuiWindow() START")
var newGuiWindow GuiWindow
newGuiWindow.Width = Config.Width
newGuiWindow.Height = Config.Height
-// newGuiWindow.Action = action
+ newGuiWindow.Name = name
newGuiWindow.MakeWindow = gw.MakeWindow
newGuiWindow.UiWindow = gw.UiWindow
newGuiWindow.UiTab = gw.UiTab
newGuiWindow.BoxMap = make(map[string]*GuiBox)
newGuiWindow.EntryMap = make(map[string]*GuiEntry)
- newGuiWindow.EntryMap["test"] = nil
- Data.Windows = append(Data.Windows, &newGuiWindow)
+ Data.Windows = append(Data.Windows, &newGuiWindow)
+
+ if (Data.WindowMap == nil) {
+ log.Println("gui.InitGuiWindow() making the Data.WindowMap here")
+ Data.WindowMap = make(map[string]*GuiWindow)
+ }
+ Data.WindowMap[name] = &newGuiWindow
+
+ // make a blank entry for testing
+ // newGuiWindow.EntryMap["test"] = nil
if (Data.buttonMap == nil) {
GuiInit()
@@ -40,12 +50,11 @@ func InitGuiWindow(action string, gw *GuiWindow) *GuiWindow {
}
-func StartNewWindow(bg bool, action string, callback func(*GuiWindow) *GuiBox) {
+func StartNewWindow(bg bool, name string, callback func(*GuiWindow) *GuiBox) {
log.Println("StartNewWindow() Create a new window")
var junk GuiWindow
junk.MakeWindow = callback
-// junk.Action = action
- window := InitGuiWindow(action, &junk)
+ window := InitGuiWindow(name, &junk)
if (bg) {
log.Println("StartNewWindow() START NEW GOROUTINE for ui.Main()")
go ui.Main(func() {
@@ -65,7 +74,7 @@ func StartNewWindow(bg bool, action string, callback func(*GuiWindow) *GuiBox) {
func InitTabWindow(gw *GuiWindow) {
log.Println("InitTabWindow() START. THIS WINDOW IS NOT YET SHOWN")
- gw.UiWindow = ui.NewWindow("InitTabWindow()", int(gw.Width), int(gw.Height), true)
+ gw.UiWindow = ui.NewWindow(gw.Name, int(gw.Width), int(gw.Height), true)
gw.UiWindow.SetBorderless(false)
gw.UiWindow.OnClosing(func(*ui.Window) bool {
@@ -120,9 +129,13 @@ func normalizeInt(s string) string {
}
func MessageWindow(gw *GuiWindow, msg1 string, msg2 string) {
+ log.Println("gui.MessageWindow() msg1 =", msg1)
+ log.Println("gui.MessageWindow() msg2 =", msg2)
ui.MsgBox(gw.UiWindow, msg1, msg2)
}
func ErrorWindow(gw *GuiWindow, msg1 string, msg2 string) {
+ log.Println("gui.ErrorWindow() msg1 =", msg1)
+ log.Println("gui.ErrorWindow() msg2 =", msg2)
ui.MsgBoxError(gw.UiWindow, msg1, msg2)
}
diff --git a/structs.go b/structs.go
index a074e56..aae0b7f 100644
--- a/structs.go
+++ b/structs.go
@@ -29,6 +29,7 @@ type GuiData struct {
// A map of all the entry boxes
AllEntries []*GuiEntry
Windows []*GuiWindow
+ WindowMap map[string]*GuiWindow
// A map of all buttons everywhere on all
// windows, all tabs, across all goroutines