compiles again

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-06-01 14:10:12 -07:00
parent a941c5a0f1
commit 6a0467f5a8
4 changed files with 63 additions and 39 deletions

View File

@ -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)

40
gui.go
View File

@ -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)

54
misc.go
View File

@ -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)
})
}
}

View File

@ -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