more structural cleanups

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-31 13:15:38 -07:00
parent c3ad3ce793
commit 1ca8ef5f0d
6 changed files with 55 additions and 37 deletions

View File

@ -35,7 +35,7 @@ func AddAccountQuestionBox(gw *GuiWindow) *GuiBox {
vbox := ui.NewVerticalBox() vbox := ui.NewVerticalBox()
vbox.SetPadded(true) vbox.SetPadded(true)
gw.Box1 = vbox // gw.Box1 = vbox
gb.UiBox = vbox gb.UiBox = vbox
hbox := ui.NewHorizontalBox() hbox := ui.NewHorizontalBox()
@ -91,7 +91,7 @@ func AddAccountBox(gw *GuiWindow) *GuiBox {
vbox := ui.NewVerticalBox() vbox := ui.NewVerticalBox()
vbox.SetPadded(true) vbox.SetPadded(true)
gw.Box1 = vbox // gw.Box1 = vbox
gb.UiBox = vbox gb.UiBox = vbox
hboxAccount := ui.NewHorizontalBox() hboxAccount := ui.NewHorizontalBox()

2
gui.go
View File

@ -220,7 +220,7 @@ func CreateButton(gw *GuiWindow, a *pb.Account, vm *pb.Event_VM,
var newB *GuiButton var newB *GuiButton
newB = new(GuiButton) newB = new(GuiButton)
newB.B = newUiB newB.B = newUiB
newB.T = gw.T newB.T = gw.UiTab
newB.Account = a newB.Account = a
newB.VM = vm newB.VM = vm
newB.WM = gw newB.WM = gw

View File

@ -13,9 +13,17 @@ import pb "git.wit.com/wit/witProtobuf"
// import "github.com/davecgh/go-spew/spew" // import "github.com/davecgh/go-spew/spew"
func makeCloudInfoBox(gw *GuiWindow) *ui.Box { func makeCloudInfoBox(gw *GuiWindow) *GuiBox {
var gb *GuiBox
gb = new(GuiBox)
gb.EntryMap = make(map[string]*GuiEntry)
gb.EntryMap["test"] = nil
hbox := ui.NewHorizontalBox() hbox := ui.NewHorizontalBox()
hbox.SetPadded(true) hbox.SetPadded(true)
// gw.Box1 = hbox
gb.UiBox = hbox
if (Data.Debug) { if (Data.Debug) {
log.Println("makeCloudInfoBox() add debugging buttons") log.Println("makeCloudInfoBox() add debugging buttons")
@ -90,7 +98,7 @@ func makeCloudInfoBox(gw *GuiWindow) *ui.Box {
agrid.Append(q.B, 5, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill) agrid.Append(q.B, 5, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
vbox.Append(agrid, false) vbox.Append(agrid, false)
return hbox return gb
} }
// //
@ -156,26 +164,26 @@ func AddVmsTab(gw *GuiWindow, name string, count int, a *pb.Account) *TableData
parts = append(parts, tmp) parts = append(parts, tmp)
human += 1 human += 1
mh := AddTableTab(gw, gw.T, 1, name, count, parts, a) mh := AddTableTab(gw, gw.UiTab, 1, name, count, parts, a)
return mh return mh
} }
func ShowAccountQuestionTab(gw *GuiWindow) { func ShowAccountQuestionTab(gw *GuiWindow) {
log.Println("ShowAccountQuestionTab() gw =", gw) log.Println("ShowAccountQuestionTab() gw =", gw)
if (gw.T == nil) { if (gw.UiTab == nil) {
log.Println("ShowAccountQuestionTab() gw.T = nil THIS IS BAD") log.Println("ShowAccountQuestionTab() gw.UiTab = nil THIS IS BAD")
os.Exit(-1) os.Exit(-1)
} }
gw.T.Delete(0) gw.UiTab.Delete(0)
log.Println("Sleep(200)") log.Println("Sleep(200)")
time.Sleep(200 * time.Millisecond) time.Sleep(200 * time.Millisecond)
abox := AddAccountQuestionBox(gw) abox := AddAccountQuestionBox(gw)
gw.BoxMap["MAIN"] = abox gw.BoxMap["Box2"] = abox
// gw.Box2 = AddAccountQuestionBox(gw) // gw.Box2 = AddAccountQuestionBox(gw)
gw.T.InsertAt("New Account?", 0, abox.UiBox) gw.UiTab.InsertAt("New Account?", 0, abox.UiBox)
gw.T.SetMargined(0, true) gw.UiTab.SetMargined(0, true)
} }
func ShowAccountTab(gw *GuiWindow, i int) { func ShowAccountTab(gw *GuiWindow, i int) {
@ -188,33 +196,34 @@ func ShowAccountTab(gw *GuiWindow, i int) {
abox := AddAccountBox(gw) abox := AddAccountBox(gw)
// Set the parents and data structure links // Set the parents and data structure links
// aTab.me = gw.T // aTab.me = gw.UiTab
// aTab.parentWindow = Data.Window1.W // aTab.parentWindow = Data.Window1.W
// aTab.tabOffset = 0 // aTab.tabOffset = 0
if (i >= 0) { if (i >= 0) {
log.Println("ShowAccountTab() InsertAt i=", i) log.Println("ShowAccountTab() InsertAt i=", i)
gw.T.Delete(0) gw.UiTab.Delete(0)
gw.T.InsertAt("Add Account", i, abox.UiBox) gw.UiTab.InsertAt("Add Account", i, abox.UiBox)
gw.T.SetMargined(0, true) gw.UiTab.SetMargined(0, true)
} else { } else {
// TODO: After append try to discover the tab index # // TODO: After append try to discover the tab index #
log.Println("ShowAccountTab() Append") log.Println("ShowAccountTab() Append")
AddBoxToTab("Create New Account", gw.T, abox.UiBox) AddBoxToTab("Create New Account", gw.UiTab, abox.UiBox)
} }
} }
func ShowMainTab(gw *GuiWindow) { func ShowMainTab(gw *GuiWindow) {
log.Println("ShowMainTab() gw =", gw) log.Println("ShowMainTab() gw =", gw)
log.Println("ShowMainTab() gw.T =", gw.T) log.Println("ShowMainTab() gw.UiTab =", gw.UiTab)
gw.T.Delete(0) gw.UiTab.Delete(0)
log.Println("Sleep(200)") log.Println("Sleep(200)")
time.Sleep(200 * time.Millisecond) time.Sleep(200 * time.Millisecond)
gw.Box2 = makeCloudInfoBox(gw) abox := makeCloudInfoBox(gw)
gw.T.InsertAt("Main", 0, gw.Box2) gw.BoxMap["Box3"] = abox
gw.T.SetMargined(0, true) gw.UiTab.InsertAt("Main", 0, abox.UiBox)
gw.UiTab.SetMargined(0, true)
} }
func GuiInit() { func GuiInit() {
@ -277,8 +286,8 @@ func InitWindow(gw *GuiWindow) {
return true return true
}) })
gw.T = ui.NewTab() gw.UiTab = ui.NewTab()
gw.W.SetChild(gw.T) gw.W.SetChild(gw.UiTab)
gw.W.SetMargined(true) gw.W.SetMargined(true)
log.Println("InitWindow() gw =", gw) log.Println("InitWindow() gw =", gw)
@ -289,10 +298,10 @@ func InitWindow(gw *GuiWindow) {
damnit := "click" + string(c.Hostname) damnit := "click" + string(c.Hostname)
tmp := getSplashText(damnit) tmp := getSplashText(damnit)
log.Println("InitWindow() TRYING SPLASH tmp =", tmp) log.Println("InitWindow() TRYING SPLASH tmp =", tmp)
gw.Box1 = ShowSplashBox(gw, tmp) abox := ShowSplashBox(gw, tmp)
gw.T.Append("WIT Splash", gw.Box1) gw.UiTab.Append("WIT Splash", abox.UiBox)
gw.T.SetMargined(0, true) gw.UiTab.SetMargined(0, true)
} }
Data.State = "splash" Data.State = "splash"

View File

@ -11,7 +11,7 @@ import "runtime"
import "github.com/andlabs/ui" import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest" import _ "github.com/andlabs/ui/winmanifest"
func ShowSplashBox(wm *GuiWindow, newText *ui.AttributedString) *ui.Box { func ShowSplashBox(wm *GuiWindow, newText *ui.AttributedString) *GuiBox {
log.Println("ShowSplashBox() START") log.Println("ShowSplashBox() START")
log.Println("ShowSplashBox() START wm =", wm) log.Println("ShowSplashBox() START wm =", wm)
if (wm == nil) { if (wm == nil) {
@ -19,14 +19,23 @@ func ShowSplashBox(wm *GuiWindow, newText *ui.AttributedString) *ui.Box {
os.Exit(0) os.Exit(0)
return nil return nil
} }
var gb *GuiBox
gb = new(GuiBox)
gb.EntryMap = make(map[string]*GuiEntry)
gb.EntryMap["test"] = nil
newbox := ui.NewVerticalBox() newbox := ui.NewVerticalBox()
newbox.SetPadded(true) newbox.SetPadded(true)
// gw.Box1 = hbox
gb.UiBox = newbox
// initialize the GuiArea{} // initialize the GuiArea{}
wm.Area = new(GuiArea) wm.Area = new(GuiArea)
wm.Area.Window = wm wm.Area.Window = wm
wm.Area.UiAttrstr = newText wm.Area.UiAttrstr = newText
makeSplashArea(wm, wm.Area) makeSplashArea(wm, wm.Area)
gb.Area = wm.Area
newbox.Append(wm.Area.UiArea, true) newbox.Append(wm.Area.UiArea, true)
@ -65,5 +74,5 @@ func ShowSplashBox(wm *GuiWindow, newText *ui.AttributedString) *ui.Box {
newbox.Append(okButton.B, false) newbox.Append(okButton.B, false)
// os.Exit(0) // os.Exit(0)
return newbox return gb
} }

View File

@ -76,10 +76,10 @@ type GuiWindow struct {
C *pb.Config C *pb.Config
W *ui.Window W *ui.Window
T *ui.Tab // if this != nil, the window is 'tabbed' UiTab *ui.Tab // if this != nil, the window is 'tabbed'
BoxMap map[string]*GuiBox BoxMap map[string]*GuiBox
Box1 *ui.Box // Box1 *ui.Box
Box2 *ui.Box // Box2 *ui.Box
} }

View File

@ -11,7 +11,7 @@ import pb "git.wit.com/wit/witProtobuf"
import "github.com/davecgh/go-spew/spew" import "github.com/davecgh/go-spew/spew"
func AddVmConfigureTab(wm *GuiWindow, name string, pbVM *pb.Event_VM) { func AddVmConfigureTab(wm *GuiWindow, name string, pbVM *pb.Event_VM) {
CreateVmBox(wm, wm.T, pbVM) CreateVmBox(wm, wm.UiTab, pbVM)
} }
func CreateVmBox(wm *GuiWindow, tab *ui.Tab, vm *pb.Event_VM) { func CreateVmBox(wm *GuiWindow, tab *ui.Tab, vm *pb.Event_VM) {