summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2019-06-01 14:10:12 -0700
committerJeff Carr <[email protected]>2019-06-01 14:10:12 -0700
commita6886866a9c70b9dae58e5811c68e3824ce40a43 (patch)
treef92495beb3384c76d1b4f3ca1697020f804ad83b
parent7d72ca3561fefd4c89f553448810eee545a47880 (diff)
compiles again
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--area.go4
-rw-r--r--gui.go40
-rw-r--r--misc.go54
-rw-r--r--structs.go4
4 files changed, 63 insertions, 39 deletions
diff --git a/area.go b/area.go
index 7087534..c841219 100644
--- a/area.go
+++ b/area.go
@@ -119,8 +119,8 @@ func ShowTextBox(gw *GuiWindow, newText *ui.AttributedString) *GuiBox {
var gb *GuiBox
gb = new(GuiBox)
- gb.EntryMap = make(map[string]*GuiEntry)
- gb.EntryMap["test"] = nil
+// gw.EntryMap = make(map[string]*GuiEntry)
+// gw.EntryMap["test"] = nil
newbox := ui.NewVerticalBox()
newbox.SetPadded(true)
diff --git a/gui.go b/gui.go
index f60fee1..4b44c54 100644
--- a/gui.go
+++ b/gui.go
@@ -84,8 +84,8 @@ func AddTableTab(gw *GuiWindow, name string, rowcount int, parts []TableColumnDa
var gb *GuiBox
gb = new(GuiBox)
- gb.EntryMap = make(map[string]*GuiEntry)
- gb.EntryMap["test"] = nil
+// gb.EntryMap = make(map[string]*GuiEntry)
+// gb.EntryMap["test"] = nil
vbox := ui.NewVerticalBox()
vbox.SetPadded(true)
@@ -214,17 +214,17 @@ func GetText(box *GuiBox, name string) string {
log.Println("gui.GetText() ERROR box == nil")
return ""
}
- if (box.EntryMap == nil) {
- log.Println("gui.GetText() ERROR b.Box.EntryMap == nil")
+ if (box.Window.EntryMap == nil) {
+ log.Println("gui.GetText() ERROR b.Box.Window.EntryMap == nil")
return ""
}
- spew.Dump(box.EntryMap)
- if (box.EntryMap[name] == nil) {
- log.Println("gui.GetText() ERROR box.EntryMap[", name, "] == nil ")
+ spew.Dump(box.Window.EntryMap)
+ if (box.Window.EntryMap[name] == nil) {
+ log.Println("gui.GetText() ERROR box.Window.EntryMap[", name, "] == nil ")
return ""
}
- e := box.EntryMap[name]
- log.Println("gui.GetText() box.EntryMap[", name, "] = ", e.UiEntry.Text())
+ e := box.Window.EntryMap[name]
+ log.Println("gui.GetText() box.Window.EntryMap[", name, "] = ", e.UiEntry.Text())
log.Println("gui.GetText() END")
return e.UiEntry.Text()
}
@@ -233,17 +233,17 @@ func SetText(box *GuiBox, name string, value string) error {
if (box == nil) {
return fmt.Errorf("gui.SetText() ERROR box == nil")
}
- if (box.EntryMap == nil) {
- return fmt.Errorf("gui.SetText() ERROR b.Box.EntryMap == nil")
+ if (box.Window.EntryMap == nil) {
+ return fmt.Errorf("gui.SetText() ERROR b.Box.Window.EntryMap == nil")
}
- spew.Dump(box.EntryMap)
- if (box.EntryMap[name] == nil) {
- return fmt.Errorf("gui.SetText() ERROR box.EntryMap[", name, "] == nil ")
+ spew.Dump(box.Window.EntryMap)
+ if (box.Window.EntryMap[name] == nil) {
+ return fmt.Errorf("gui.SetText() ERROR box.Window.EntryMap[", name, "] == nil ")
}
- e := box.EntryMap[name]
- log.Println("gui.SetText() box.EntryMap[", name, "] = ", e.UiEntry.Text())
+ e := box.Window.EntryMap[name]
+ log.Println("gui.SetText() box.Window.EntryMap[", name, "] = ", e.UiEntry.Text())
e.UiEntry.SetText(value)
- log.Println("gui.SetText() box.EntryMap[", name, "] = ", e.UiEntry.Text())
+ log.Println("gui.SetText() box.Window.EntryMap[", name, "] = ", e.UiEntry.Text())
log.Println("gui.SetText() END")
return nil
}
@@ -295,7 +295,7 @@ func AddEntry(box *GuiBox, name string) *GuiEntry {
box.UiBox.Append(ue, false)
ge.UiEntry = ue
- box.EntryMap[name] = ge
+ box.Window.EntryMap[name] = ge
return ge
}
@@ -344,8 +344,8 @@ func AddGenericBox(gw *GuiWindow) *GuiBox {
var gb *GuiBox
gb = new(GuiBox)
- gb.EntryMap = make(map[string]*GuiEntry)
- gb.EntryMap["test"] = nil
+// gb.EntryMap = make(map[string]*GuiEntry)
+// gb.EntryMap["test"] = nil
vbox := ui.NewVerticalBox()
vbox.SetPadded(true)
diff --git a/misc.go b/misc.go
index 6a617e8..ed6a180 100644
--- a/misc.go
+++ b/misc.go
@@ -40,16 +40,17 @@ func AddMainTab(gw *GuiWindow) *GuiBox {
log.Println("ShowMainTab() gw =", gw)
log.Println("ShowMainTab() gw.UiTab =", gw.UiTab)
- newWindow := new(GuiWindow)
- newWindow.UiWindow = gw.UiWindow
- Data.Windows = append(Data.Windows, newWindow)
+ window := InitGuiWindow(Data.Config, "MAIN", nil, gw.UiWindow, gw.UiTab)
+// newWindow := new(GuiWindow)
+// newWindow.UiWindow = gw.UiWindow
+// Data.Windows = append(Data.Windows, newWindow)
var box *GuiBox
box = new(GuiBox)
- box.Window = gw
+ box.Window = window
- box.EntryMap = make(map[string]*GuiEntry)
- box.EntryMap["test"] = nil
+// box.EntryMap = make(map[string]*GuiEntry)
+// box.EntryMap["test"] = nil
hbox := ui.NewHorizontalBox()
hbox.SetPadded(true)
@@ -75,28 +76,49 @@ func ShowMainTabShowBox(gw *GuiWindow, box *GuiBox) {
gw.UiTab.SetMargined(0, true)
}
-func StartNewWindow(c *pb.Config, bg bool, action string, maketab func(*GuiWindow) *GuiBox) {
- log.Println("InitNewWindow() Create a new window")
+func InitGuiWindow(c *pb.Config, action string, maketab func(*GuiWindow) *GuiBox, uiW *ui.Window, uiT *ui.Tab) *GuiWindow {
+ log.Println("InitGuiWindow() START")
var newGuiWindow GuiWindow
- newGuiWindow.Width = int(c.Width)
- newGuiWindow.Height = int(c.Height)
- newGuiWindow.Action = action
- newGuiWindow.MakeWindow = maketab
- newGuiWindow.BoxMap = make(map[string]*GuiBox)
+ newGuiWindow.Width = int(c.Width)
+ newGuiWindow.Height = int(c.Height)
+ newGuiWindow.Action = action
+ newGuiWindow.MakeWindow = maketab
+ newGuiWindow.UiWindow = uiW
+ newGuiWindow.UiTab = uiT
+ newGuiWindow.BoxMap = make(map[string]*GuiBox)
+ newGuiWindow.EntryMap = make(map[string]*GuiEntry)
+ newGuiWindow.EntryMap["test"] = nil
Data.Windows = append(Data.Windows, &newGuiWindow)
- // make(newGuiWindow.BoxMap)
+ log.Println("InitGuiWindow() END *GuiWindow =", &newGuiWindow)
+ return &newGuiWindow
+}
+
+
+func StartNewWindow(c *pb.Config, bg bool, action string, maketab func(*GuiWindow) *GuiBox) {
+ log.Println("InitNewWindow() Create a new window")
+ window := InitGuiWindow(c, action, maketab, nil, nil)
+ /*
+ newGuiWindow.Width = int(c.Width)
+ newGuiWindow.Height = int(c.Height)
+ newGuiWindow.Action = action
+ newGuiWindow.MakeWindow = maketab
+ newGuiWindow.BoxMap = make(map[string]*GuiBox)
+ newGuiWindow.EntryMap = make(map[string]*GuiEntry)
+ newGuiWindow.EntryMap["test"] = nil
+ Data.Windows = append(Data.Windows, &newGuiWindow)
+ */
if (bg) {
log.Println("ShowWindow() IN NEW GOROUTINE")
go ui.Main(func() {
- InitTabWindow(&newGuiWindow)
+ InitTabWindow(window)
})
time.Sleep(2000 * time.Millisecond)
} else {
log.Println("ShowWindow() WAITING for ui.Main()")
ui.Main(func() {
- InitTabWindow(&newGuiWindow)
+ InitTabWindow(window)
})
}
}
diff --git a/structs.go b/structs.go
index 6370705..5be2162 100644
--- a/structs.go
+++ b/structs.go
@@ -119,9 +119,11 @@ type GuiButton struct {
FB *ui.FontButton
}
+// GuiBox is any type of ui.Hbox or ui.Vbox
+// There can be lots of these for each GuiWindow
type GuiBox struct {
Window *GuiWindow
- EntryMap map[string]*GuiEntry
+// EntryMap map[string]*GuiEntry
// andlabs/ui abstraction mapping
UiBox *ui.Box