From c9d46e19058068db9082d6f3554c2a2af0498851 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 1 Jun 2019 15:38:47 -0700 Subject: [PATCH] builds and works again Signed-off-by: Jeff Carr --- gui.go | 21 +++++++++++++++------ misc.go | 40 +++++++++++++++++++++++----------------- structs.go | 2 +- 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/gui.go b/gui.go index 4b44c54..49b9ab4 100644 --- a/gui.go +++ b/gui.go @@ -303,30 +303,39 @@ func AddEntry(box *GuiBox, name string) *GuiEntry { func HardHorizontalBreak(box *GuiBox) { log.Println("HardHorizontalBreak START") gw := box.Window - mainbox := gw.mainbox + mainbox := gw.BoxMap["MAIN"] + if (mainbox == nil) { + log.Println("HardHorizontalBreak ERROR MAIN box == nil") + return + } + uibox := mainbox.UiBox tmp := ui.NewHorizontalSeparator() - mainbox.Append(tmp, false) + uibox.Append(tmp, false) hbox := ui.NewVerticalBox() hbox.SetPadded(true) box.UiBox = hbox - mainbox.Append(hbox, true) + uibox.Append(hbox, true) log.Println("HardHorizontalBreak END") } func HardVerticalBreak(box *GuiBox) { log.Println("HardVerticalBreak START") gw := box.Window - mainbox := gw.mainbox + mainbox := gw.BoxMap["MAIN"] + if (mainbox == nil) { + log.Println("HardHorizontalBreak ERROR MAIN box == nil") + return + } tmp := ui.NewVerticalSeparator() - mainbox.Append(tmp, false) + mainbox.UiBox.Append(tmp, false) hbox := ui.NewVerticalBox() hbox.SetPadded(true) box.UiBox = hbox - mainbox.Append(hbox, false) + mainbox.UiBox.Append(hbox, false) log.Println("HardVerticalBreak END") } diff --git a/misc.go b/misc.go index a685b81..18d1f1a 100644 --- a/misc.go +++ b/misc.go @@ -43,26 +43,13 @@ func AddMainTab(gw *GuiWindow) *GuiBox { log.Println("ShowMainTab() gw.UiTab =", gw.UiTab) 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 = window - -// box.EntryMap = make(map[string]*GuiEntry) -// box.EntryMap["test"] = nil - - hbox := ui.NewHorizontalBox() - hbox.SetPadded(true) - box.UiBox = hbox - gw.mainbox = hbox + box := InitGuiBox(window, nil, ui.NewHorizontalBox(), "MAIN") if (Data.Debug) { log.Println("makeCloudInfoBox() add debugging buttons") addDebuggingButtons(box) - hbox.Append(ui.NewVerticalSeparator(), false) + box.UiBox.Append(ui.NewVerticalSeparator(), false) } // box := gw.MakeWindow(gw) @@ -73,11 +60,30 @@ func AddMainTab(gw *GuiWindow) *GuiBox { func ShowMainTabShowBox(gw *GuiWindow, box *GuiBox) { log.Println("gui.ShowMainTabShowBox() box =", box) // gw.UiTab.Delete(0) - gw.BoxMap["Box3"] = box - gw.UiTab.InsertAt("Main", 0, gw.mainbox) + gw.BoxMap["MAIN3"] = box + // gw.UiTab.InsertAt("Main", 0, box.UiBox) gw.UiTab.SetMargined(0, true) } +func InitGuiBox(gw *GuiWindow, box *GuiBox, uiBox *ui.Box, name string) *GuiBox { + log.Println("InitGuiBox() START") + var newGuiBox GuiBox + newGuiBox.UiBox = uiBox + newGuiBox.Window = gw + uiBox.SetPadded(true) + + if (box != nil) { + log.Println("InitGuiBox() APPEND NEW BOX TO OLD BOX") + box.UiBox.Append(uiBox, false) + } else { + log.Println("InitGuiBox() APPEND NEW BOX TO TAB") + gw.UiTab.Append(name, uiBox) + } + gw.BoxMap[name] = &newGuiBox + log.Println("InitGuiBox() END") + return &newGuiBox +} + 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 diff --git a/structs.go b/structs.go index 5be2162..b036d83 100644 --- a/structs.go +++ b/structs.go @@ -82,7 +82,7 @@ type GuiWindow struct { Width int Height int - mainbox *ui.Box +// mainbox *ui.Box // the callback function to make the window contents MakeWindow func(*GuiWindow) *GuiBox