lots of changes to track windows and tabs

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-31 17:37:53 -07:00
parent 1ca8ef5f0d
commit b5fe8f0684
8 changed files with 149 additions and 98 deletions

View File

@ -37,6 +37,7 @@ func AddAccountQuestionBox(gw *GuiWindow) *GuiBox {
vbox.SetPadded(true) vbox.SetPadded(true)
// gw.Box1 = vbox // gw.Box1 = vbox
gb.UiBox = vbox gb.UiBox = vbox
gb.W = gw
hbox := ui.NewHorizontalBox() hbox := ui.NewHorizontalBox()
hbox.SetPadded(true) hbox.SetPadded(true)
@ -44,7 +45,7 @@ func AddAccountQuestionBox(gw *GuiWindow) *GuiBox {
hbox.Append(ui.NewLabel("Enter your Subdomain or"), false) hbox.Append(ui.NewLabel("Enter your Subdomain or"), false)
button1 := CreateButton(gw, nil, nil, "Generate", "SUBDOMAIN", generateSubdomain) button1 := CreateButton(gb, nil, nil, "Generate", "SUBDOMAIN", generateSubdomain)
button1.Box = gb button1.Box = gb
hbox.Append(button1.B, false) hbox.Append(button1.B, false)
@ -53,7 +54,7 @@ func AddAccountQuestionBox(gw *GuiWindow) *GuiBox {
vbox.Append(ui.NewHorizontalSeparator(), false) vbox.Append(ui.NewHorizontalSeparator(), false)
button2 := CreateButton(gw, nil, nil, "Create Subdomain Account", "ADD", nil) button2 := CreateButton(gb, nil, nil, "Create Subdomain Account", "ADD", nil)
button2.Box = gb button2.Box = gb
vbox.Append(button2.B, false) vbox.Append(button2.B, false)
@ -189,10 +190,10 @@ func AddAccountBox(gw *GuiWindow) *GuiBox {
hboxButtons.SetPadded(true) hboxButtons.SetPadded(true)
vbox.Append(hboxButtons, false) vbox.Append(hboxButtons, false)
okButton := CreateButton(gw, nil, nil, "Add Account", "ADD", nil) okButton := CreateButton(gb, nil, nil, "Add Account", "ADD", nil)
hboxButtons.Append(okButton.B, false) hboxButtons.Append(okButton.B, false)
backButton := CreateButton(gw, nil, nil, "Back", "BACK", nil) backButton := CreateButton(gb, nil, nil, "Back", "BACK", nil)
hboxButtons.Append(backButton.B, false) hboxButtons.Append(backButton.B, false)
return gb return gb

23
area.go
View File

@ -20,24 +20,31 @@ func findFB(button *GuiButton) *GuiButton {
return a return a
} }
func makeSplashArea(wm *GuiWindow, ah *GuiArea) { func makeSplashArea(gb *GuiBox, newText *ui.AttributedString) {
// make this button just to get the default font (but don't display the button) // make this button just to get the default font (but don't display the button)
// There should be another way to do this (?) // There should be another way to do this (?)
newB := CreateFontButton(wm, "AREA") var newB *GuiButton
newB = CreateFontButton(gb, "AREA")
// initialize the GuiArea{}
gb.Area = new(GuiArea)
gb.Area.Window = gb.W
gb.Area.UiAttrstr = newText
// ah.UiAttrstr = makeAttributedString() // ah.UiAttrstr = makeAttributedString()
ah.UiArea = ui.NewArea(ah) gb.Area.UiArea = ui.NewArea(gb.Area)
newB.A = ah.UiArea newB.A = gb.Area.UiArea
newB.WM = wm newB.GW = gb.W
newB.Box = gb
// Data.AllButtons[1].A = ah.UiArea // Data.AllButtons[1].A = ah.UiArea
// ah.Button = &Data.AllButtons[1] // ah.Button = &Data.AllButtons[1]
ah.Button = newB gb.Area.Button = newB
if (Data.Debug) { if (Data.Debug) {
spew.Dump(ah.UiArea) spew.Dump(gb.Area.UiArea)
log.Println("DEBUGGING", Data.Debug) log.Println("DEBUGGING", Data.Debug)
} else { } else {
log.Println("NOT DEBUGGING AREA mhAH.Button =", ah.Button) log.Println("NOT DEBUGGING AREA mhAH.Button =", gb.Area.Button)
} }
} }

View File

@ -56,13 +56,17 @@ func addTableTab() {
// AddTableTab(Data.Window1.T, 1, "test seven", 7, parts, nil) // AddTableTab(Data.Window1.T, 1, "test seven", 7, parts, nil)
} }
func addDebuggingButtons(wm *GuiWindow, vbox *ui.Box) { func addDebuggingButtons(box *GuiBox) {
vbox := ui.NewVerticalBox()
vbox.SetPadded(true)
box.UiBox.Append(vbox, false)
vbox.Append(ui.NewLabel("Debugging:"), false) vbox.Append(ui.NewLabel("Debugging:"), false)
vbox.Append(ui.NewColorButton(), false) vbox.Append(ui.NewColorButton(), false)
a := CreateButton(wm, nil, nil, "Add Account", "ADD", nil) a := CreateButton(box, nil, nil, "Add Account", "ADD", nil)
vbox.Append(a.B, false) vbox.Append(a.B, false)
a = CreateButton(wm, nil, nil, "Quit", "QUIT", nil) a = CreateButton(box, nil, nil, "Quit", "QUIT", nil)
vbox.Append(a.B, false) vbox.Append(a.B, false)
// ATTEMPT TO ADD THE TABLE HERE // ATTEMPT TO ADD THE TABLE HERE
@ -74,16 +78,16 @@ func addDebuggingButtons(wm *GuiWindow, vbox *ui.Box) {
vbox.Append(add2button, false) vbox.Append(add2button, false)
// ATTEMPT TO ADD THE TABLE HERE END // ATTEMPT TO ADD THE TABLE HERE END
a = CreateButton(wm, nil, nil, "Hide & Show Box1&2", "HIDE", runTestHide) a = CreateButton(box, nil, nil, "Hide & Show Box1&2", "HIDE", runTestHide)
vbox.Append(a.B, false) vbox.Append(a.B, false)
a = CreateButton(wm, nil, nil, "Close GUI", "QUIT", nil) a = CreateButton(box, nil, nil, "Close GUI", "QUIT", nil)
vbox.Append(a.B, false) vbox.Append(a.B, false)
a = CreateButton(wm, nil, nil, "DEBUG goroutines", "DEBUG", nil) a = CreateButton(box, nil, nil, "DEBUG goroutines", "DEBUG", nil)
vbox.Append(a.B, false) vbox.Append(a.B, false)
a = CreateButton(wm, nil, nil, "xterm", "XTERM", runTestExecClick) a = CreateButton(box, nil, nil, "xterm", "XTERM", runTestExecClick)
vbox.Append(a.B, false) vbox.Append(a.B, false)
a = CreateButton(wm, nil, nil, "Load test.json config file", "CONFIG", nil) a = CreateButton(box, nil, nil, "Load test.json config file", "CONFIG", nil)
vbox.Append(a.B, false) vbox.Append(a.B, false)
} }

58
gui.go
View File

@ -42,7 +42,7 @@ func InitColumns(mh *TableData, parts []TableColumnData) {
} }
} }
func AddTableTab(gw *GuiWindow, mytab *ui.Tab, junk int, name string, rowcount int, parts []TableColumnData, account *pb.Account) *TableData { func AddTableTab(gw *GuiWindow, junk int, name string, rowcount int, parts []TableColumnData, account *pb.Account) *TableData {
mh := new(TableData) mh := new(TableData)
mh.RowCount = rowcount mh.RowCount = rowcount
@ -79,11 +79,20 @@ func AddTableTab(gw *GuiWindow, mytab *ui.Tab, junk int, name string, rowcount i
} }
} }
var gb *GuiBox
gb = new(GuiBox)
gb.EntryMap = make(map[string]*GuiEntry)
gb.EntryMap["test"] = nil
vbox := ui.NewVerticalBox() vbox := ui.NewVerticalBox()
vbox.SetPadded(true) vbox.SetPadded(true)
gb.UiBox = vbox
gb.W = gw
gw.BoxMap[name] = gb
vbox.Append(table, true) vbox.Append(table, true)
mytab.Append(name, vbox) gw.UiTab.Append(name, vbox)
// mytab.SetMargined(mytabcount, true) // mytab.SetMargined(mytabcount, true)
vbox.Append(ui.NewVerticalSeparator(), false) vbox.Append(ui.NewVerticalSeparator(), false)
@ -91,10 +100,8 @@ func AddTableTab(gw *GuiWindow, mytab *ui.Tab, junk int, name string, rowcount i
hbox := ui.NewHorizontalBox() hbox := ui.NewHorizontalBox()
hbox.SetPadded(true) hbox.SetPadded(true)
a := CreateButton(gw, account, nil, "Add Virtual Machine", "createAddVmBox", nil) a := CreateButton(gb, account, nil, "Add Virtual Machine", "createAddVmBox", nil)
hbox.Append(a.B, false) hbox.Append(a.B, false)
b := CreateButton(gw, account, nil, "Add Virtual Machine", "createAddVmBox", nil)
hbox.Append(b.B, false)
vbox.Append(hbox, false) vbox.Append(hbox, false)
@ -102,17 +109,17 @@ func AddTableTab(gw *GuiWindow, mytab *ui.Tab, junk int, name string, rowcount i
} }
func SocketError(gw *GuiWindow) { func SocketError(gw *GuiWindow) {
ui.MsgBoxError(gw.W, ui.MsgBoxError(gw.UiWindow,
"There was a socket error", "There was a socket error",
"More detailed information can be shown here.") "More detailed information can be shown here.")
} }
func MessageWindow(gw *GuiWindow, msg1 string, msg2 string) { func MessageWindow(gw *GuiWindow, msg1 string, msg2 string) {
ui.MsgBox(gw.W, msg1, msg2) ui.MsgBox(gw.UiWindow, msg1, msg2)
} }
func ErrorWindow(gw *GuiWindow, msg1 string, msg2 string) { func ErrorWindow(gw *GuiWindow, msg1 string, msg2 string) {
ui.MsgBoxError(gw.W, msg1, msg2) ui.MsgBoxError(gw.UiWindow, msg1, msg2)
} }
// This is the default mouse click handler // This is the default mouse click handler
@ -134,7 +141,7 @@ func mouseClick(b *GuiButton) {
log.Println("\tgui.mouseClick() START b.Action =", b.Action) log.Println("\tgui.mouseClick() START b.Action =", b.Action)
if (b.Action == "createAddVmBox") { if (b.Action == "createAddVmBox") {
log.Println("\tgui.mouseClick() createAddVmBox for b =", b) log.Println("\tgui.mouseClick() createAddVmBox for b =", b)
createAddVmBox(b.WM, b.T, "Create New Virtual Machine", b) createAddVmBox(b.GW, b.T, "Create New Virtual Machine", b)
return return
} }
/* /*
@ -212,7 +219,7 @@ func AddButton(b *GuiButton, name string) *ui.Button {
return newB return newB
} }
func CreateButton(gw *GuiWindow, a *pb.Account, vm *pb.Event_VM, func CreateButton(box *GuiBox, a *pb.Account, vm *pb.Event_VM,
name string, action string, custom func(*GuiButton)) *GuiButton { name string, action string, custom func(*GuiButton)) *GuiButton {
newUiB := ui.NewButton(name) newUiB := ui.NewButton(name)
newUiB.OnClicked(defaultButtonClick) newUiB.OnClicked(defaultButtonClick)
@ -220,10 +227,15 @@ 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.UiTab if (box.W == nil) {
log.Println("CreateButton() box.W == nil")
panic("crap")
}
newB.GW = box.W
newB.T = box.W.UiTab
newB.Account = a newB.Account = a
newB.VM = vm newB.VM = vm
newB.WM = gw newB.Box = box
newB.Action = action newB.Action = action
newB.custom = custom newB.custom = custom
Data.AllButtons = append(Data.AllButtons, newB) Data.AllButtons = append(Data.AllButtons, newB)
@ -231,21 +243,21 @@ func CreateButton(gw *GuiWindow, a *pb.Account, vm *pb.Event_VM,
return newB return newB
} }
func CreateFontButton(gw *GuiWindow, action string) *GuiButton { func CreateFontButton(box *GuiBox, action string) *GuiButton {
newB := ui.NewFontButton()
// create a 'fake' button entry for the mouse clicks // create a 'fake' button entry for the mouse clicks
var newBM GuiButton var newGB GuiButton
newBM.Action = action newGB.Action = action
newBM.FB = newB newGB.FB = ui.NewFontButton()
newBM.Area = gw.Area newGB.Box = box
Data.AllButtons = append(Data.AllButtons, &newBM) newGB.Area = box.Area
Data.AllButtons = append(Data.AllButtons, &newGB)
newB.OnChanged(func (*ui.FontButton) { newGB.FB.OnChanged(func (*ui.FontButton) {
log.Println("FontButton.OnChanged() START mouseClick(&newBM)", newBM) log.Println("FontButton.OnChanged() START mouseClick(&newBM)", newGB)
mouseClick(&newBM) mouseClick(&newGB)
}) })
return &newBM return &newGB
} }
func GetText(box *GuiBox, name string) string { func GetText(box *GuiBox, name string) string {

View File

@ -16,6 +16,7 @@ import pb "git.wit.com/wit/witProtobuf"
func makeCloudInfoBox(gw *GuiWindow) *GuiBox { func makeCloudInfoBox(gw *GuiWindow) *GuiBox {
var gb *GuiBox var gb *GuiBox
gb = new(GuiBox) gb = new(GuiBox)
gb.W = gw
gb.EntryMap = make(map[string]*GuiEntry) gb.EntryMap = make(map[string]*GuiEntry)
gb.EntryMap["test"] = nil gb.EntryMap["test"] = nil
@ -27,11 +28,13 @@ func makeCloudInfoBox(gw *GuiWindow) *GuiBox {
if (Data.Debug) { if (Data.Debug) {
log.Println("makeCloudInfoBox() add debugging buttons") log.Println("makeCloudInfoBox() add debugging buttons")
/*
vbox := ui.NewVerticalBox() vbox := ui.NewVerticalBox()
vbox.SetPadded(true) vbox.SetPadded(true)
hbox.Append(vbox, false) hbox.Append(vbox, false)
*/
addDebuggingButtons(gw, vbox) addDebuggingButtons(gb)
hbox.Append(ui.NewVerticalSeparator(), false) hbox.Append(ui.NewVerticalSeparator(), false)
} }
@ -54,7 +57,7 @@ func makeCloudInfoBox(gw *GuiWindow) *GuiBox {
hostnameEntry.SetText(tmp) hostnameEntry.SetText(tmp)
hostnameEntry.SetReadOnly(true) hostnameEntry.SetReadOnly(true)
anew := CreateButton(gw, nil, nil, "Edit", "EDIT", nil) anew := CreateButton(gb, nil, nil, "Edit", "EDIT", nil)
hostnamebox.Append(anew.B, false) hostnamebox.Append(anew.B, false)
vbox.Append(ui.NewHorizontalSeparator(), false) vbox.Append(ui.NewHorizontalSeparator(), false)
@ -79,11 +82,11 @@ func makeCloudInfoBox(gw *GuiWindow) *GuiBox {
agrid.Append(ui.NewLabel(Data.Config.Accounts[key].Email), 2, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill) agrid.Append(ui.NewLabel(Data.Config.Accounts[key].Email), 2, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
name := "Login " + Data.Config.Accounts[key].Nick name := "Login " + Data.Config.Accounts[key].Nick
l := CreateButton(gw, Data.Config.Accounts[key], nil, name, "LOGIN", nil) l := CreateButton(gb, Data.Config.Accounts[key], nil, name, "LOGIN", nil)
agrid.Append(l.B, 3, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill) agrid.Append(l.B, 3, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
name = "Show " + Data.Config.Accounts[key].Nick name = "Show " + Data.Config.Accounts[key].Nick
b := CreateButton(gw, Data.Config.Accounts[key], nil, name, "SHOW", nil) b := CreateButton(gb, Data.Config.Accounts[key], nil, name, "SHOW", nil)
agrid.Append(b.B, 4, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill) agrid.Append(b.B, 4, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
row += 1 row += 1
@ -92,9 +95,9 @@ func makeCloudInfoBox(gw *GuiWindow) *GuiBox {
row += 1 row += 1
agrid.Append(ui.NewLabel(""), 1, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill) agrid.Append(ui.NewLabel(""), 1, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
row += 1 row += 1
a := CreateButton(gw, nil, nil, "Add Account", "ADD TAB", nil) a := CreateButton(gb, nil, nil, "Add Account", "ADD TAB", nil)
agrid.Append(a.B, 4, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill) agrid.Append(a.B, 4, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
q := CreateButton(gw, nil, nil, "Quit", "QUIT", nil) q := CreateButton(gb, nil, nil, "Quit", "QUIT", nil)
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)
@ -164,7 +167,7 @@ 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.UiTab, 1, name, count, parts, a) mh := AddTableTab(gw, 1, name, count, parts, a)
return mh return mh
} }
@ -237,7 +240,8 @@ func GuiInit() {
func StartNewWindow(c *pb.Config, bg bool, action string) { func StartNewWindow(c *pb.Config, bg bool, action string) {
log.Println("InitNewWindow() Create a new window") log.Println("InitNewWindow() Create a new window")
var newGuiWindow GuiWindow var newGuiWindow GuiWindow
newGuiWindow.C = c newGuiWindow.Width = int(c.Width)
newGuiWindow.Height = int(c.Height)
newGuiWindow.Action = action newGuiWindow.Action = action
Data.Windows = append(Data.Windows, &newGuiWindow) Data.Windows = append(Data.Windows, &newGuiWindow)
@ -264,22 +268,20 @@ func getSplashText(a string) *ui.AttributedString {
return aText return aText
} }
func InitWindow(gw *GuiWindow) { func InitWindow(gw *GuiWindow) {
log.Println("InitWindow() THIS WINDOW IS NOT YET SHOWN") log.Println("InitWindow() THIS WINDOW IS NOT YET SHOWN")
c := gw.C gw.UiWindow = ui.NewWindow("", int(gw.Width), int(gw.Height), true)
gw.W = ui.NewWindow("", int(c.Width), int(c.Height), true) gw.UiWindow.SetBorderless(false)
gw.W.SetBorderless(false)
// create a 'fake' button entry for the mouse clicks // create a 'fake' button entry for the mouse clicks
var newBM GuiButton var newBM GuiButton
newBM.Action = "QUIT" newBM.Action = "QUIT"
newBM.W = gw.W newBM.W = gw.UiWindow
newBM.WM = gw newBM.GW = gw
Data.AllButtons = append(Data.AllButtons, &newBM) Data.AllButtons = append(Data.AllButtons, &newBM)
gw.W.OnClosing(func(*ui.Window) bool { gw.UiWindow.OnClosing(func(*ui.Window) bool {
log.Println("InitWindow() OnClosing() THIS WINDOW IS CLOSING gw=", gw) log.Println("InitWindow() OnClosing() THIS WINDOW IS CLOSING gw=", gw)
// mouseClick(&newBM) // mouseClick(&newBM)
ui.Quit() ui.Quit()
@ -287,15 +289,15 @@ func InitWindow(gw *GuiWindow) {
}) })
gw.UiTab = ui.NewTab() gw.UiTab = ui.NewTab()
gw.W.SetChild(gw.UiTab) gw.UiWindow.SetChild(gw.UiTab)
gw.W.SetMargined(true) gw.UiWindow.SetMargined(true)
log.Println("InitWindow() gw =", gw) log.Println("InitWindow() gw =", gw)
log.Println("InitWindow() gw.Action =", gw.Action) log.Println("InitWindow() gw.Action =", gw.Action)
if (gw.Action == "SPLASH") { if (gw.Action == "SPLASH") {
log.Println("InitWindow() TRYING SPLASH") log.Println("InitWindow() TRYING SPLASH")
damnit := "click" + string(c.Hostname) damnit := "click" + string(Data.Config.Hostname)
tmp := getSplashText(damnit) tmp := getSplashText(damnit)
log.Println("InitWindow() TRYING SPLASH tmp =", tmp) log.Println("InitWindow() TRYING SPLASH tmp =", tmp)
abox := ShowSplashBox(gw, tmp) abox := ShowSplashBox(gw, tmp)
@ -305,7 +307,7 @@ func InitWindow(gw *GuiWindow) {
} }
Data.State = "splash" Data.State = "splash"
gw.W.Show() gw.UiWindow.Show()
} }
// makeEntryBox(box, "hostname:", "blah.foo.org") { // makeEntryBox(box, "hostname:", "blah.foo.org") {

View File

@ -11,10 +11,10 @@ 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) *GuiBox { func ShowSplashBox(gw *GuiWindow, newText *ui.AttributedString) *GuiBox {
log.Println("ShowSplashBox() START") log.Println("ShowSplashBox() START")
log.Println("ShowSplashBox() START wm =", wm) log.Println("ShowSplashBox() START gw =", gw)
if (wm == nil) { if (gw == nil) {
log.Println("ShowSplashBox() WE ARE FUCKED BECAUSE WE DON'T KNOW WHAT WINDOW TO DO THIS IN") log.Println("ShowSplashBox() WE ARE FUCKED BECAUSE WE DON'T KNOW WHAT WINDOW TO DO THIS IN")
os.Exit(0) os.Exit(0)
return nil return nil
@ -29,15 +29,19 @@ func ShowSplashBox(wm *GuiWindow, newText *ui.AttributedString) *GuiBox {
newbox.SetPadded(true) newbox.SetPadded(true)
// gw.Box1 = hbox // gw.Box1 = hbox
gb.UiBox = newbox gb.UiBox = newbox
gb.W = gw
gw.BoxMap["Splash"] = gb
/*
// initialize the GuiArea{} // initialize the GuiArea{}
wm.Area = new(GuiArea) gb.Area = new(GuiArea)
wm.Area.Window = wm gb.Area.Window = gw
wm.Area.UiAttrstr = newText gb.Area.UiAttrstr = newText
makeSplashArea(wm, wm.Area) */
gb.Area = wm.Area
newbox.Append(wm.Area.UiArea, true) makeSplashArea(gb, newText)
newbox.Append(gb.Area.UiArea, true)
if runtime.GOOS == "linux" { if runtime.GOOS == "linux" {
newbox.Append(ui.NewLabel("OS: Linux"), false) newbox.Append(ui.NewLabel("OS: Linux"), false)
@ -65,12 +69,12 @@ func ShowSplashBox(wm *GuiWindow, newText *ui.AttributedString) *GuiBox {
} }
} }
log.Println("ShowSplashBox() START wm =", wm) log.Println("ShowSplashBox() START gb =", gb)
okButton := CreateButton(wm, nil, nil, "OK", "AREA", nil) okButton := CreateButton(gb, nil, nil, "OK", "AREA", nil)
newbox.Append(okButton.B, false) newbox.Append(okButton.B, false)
okButton = CreateButton(wm, nil, nil, "NEWTEXT", "NEWTEXT", nil) okButton = CreateButton(gb, nil, nil, "NEWTEXT", "NEWTEXT", nil)
newbox.Append(okButton.B, false) newbox.Append(okButton.B, false)
// os.Exit(0) // os.Exit(0)

View File

@ -71,15 +71,13 @@ type GuiData struct {
// //
type GuiWindow struct { type GuiWindow struct {
Action string Action string
Area *GuiArea // should be moved to GuiBox // Area *GuiArea // should be moved to GuiBox
C *pb.Config
W *ui.Window
UiTab *ui.Tab // if this != nil, the window is 'tabbed'
BoxMap map[string]*GuiBox BoxMap map[string]*GuiBox
// Box1 *ui.Box Width int
// Box2 *ui.Box Height int
UiWindow *ui.Window
UiTab *ui.Tab // if this != nil, the window is 'tabbed'
} }
@ -91,7 +89,7 @@ type GuiButton struct {
Action string // what type of button Action string // what type of button
Box *GuiBox // what box the button click was in Box *GuiBox // what box the button click was in
Area *GuiArea // indicates the button click was in an Area Area *GuiArea // indicates the button click was in an Area
WM *GuiWindow // what window the button click was in (redundant?) GW *GuiWindow // what window the button click was in (redundant?)
Account *pb.Account // associated with what account? Account *pb.Account // associated with what account?
VM *pb.Event_VM // associated with which VM? VM *pb.Event_VM // associated with which VM?

View File

@ -14,15 +14,27 @@ func AddVmConfigureTab(wm *GuiWindow, name string, pbVM *pb.Event_VM) {
CreateVmBox(wm, wm.UiTab, pbVM) CreateVmBox(wm, wm.UiTab, pbVM)
} }
func CreateVmBox(wm *GuiWindow, tab *ui.Tab, vm *pb.Event_VM) { func CreateVmBox(gw *GuiWindow, junk *ui.Tab, vm *pb.Event_VM) {
log.Println("CreateVmBox() START") log.Println("CreateVmBox() START")
log.Println("CreateVmBox() vm.Name", vm.Name) log.Println("CreateVmBox() vm.Name", vm.Name)
var gb *GuiBox
gb = new(GuiBox)
vbox := ui.NewVerticalBox()
vbox.SetPadded(true)
gb.UiBox = vbox
gb.W = gw
gw.BoxMap[vm.Name] = gb
// gw.UiTab.Append(vm.Name, vbox)
spew.Dump(vm) spew.Dump(vm)
if (Data.Debug) { if (Data.Debug) {
spew.Dump(vm) spew.Dump(vm)
} }
vbox := ui.NewVerticalBox()
vbox.SetPadded(true)
hboxAccount := ui.NewHorizontalBox() hboxAccount := ui.NewHorizontalBox()
hboxAccount.SetPadded(true) hboxAccount.SetPadded(true)
@ -42,28 +54,39 @@ func CreateVmBox(wm *GuiWindow, tab *ui.Tab, vm *pb.Event_VM) {
hboxButtons.SetPadded(true) hboxButtons.SetPadded(true)
vbox.Append(hboxButtons, false) vbox.Append(hboxButtons, false)
a := CreateButton(wm, nil, vm, "Power On", "POWERON", nil) a := CreateButton(gb, nil, vm, "Power On", "POWERON", nil)
hboxButtons.Append(a.B, false) hboxButtons.Append(a.B, false)
a = CreateButton(wm, nil, vm, "Power Off", "POWEROFF", nil) a = CreateButton(gb, nil, vm, "Power Off", "POWEROFF", nil)
hboxButtons.Append(a.B, false) hboxButtons.Append(a.B, false)
a = CreateButton(wm, nil, vm, "Destroy", "DESTROY", nil) a = CreateButton(gb, nil, vm, "Destroy", "DESTROY", nil)
hboxButtons.Append(a.B, false) hboxButtons.Append(a.B, false)
a = CreateButton(wm, nil, vm, "ping", "PING", runPingClick) a = CreateButton(gb, nil, vm, "ping", "PING", runPingClick)
hboxButtons.Append(a.B, false) hboxButtons.Append(a.B, false)
a = CreateButton(wm, nil, vm, "Console", "XTERM", runTestExecClick) a = CreateButton(gb, nil, vm, "Console", "XTERM", runTestExecClick)
hboxButtons.Append(a.B, false) hboxButtons.Append(a.B, false)
a = CreateButton(wm, nil, vm, "Save", "SAVE", nil) a = CreateButton(gb, nil, vm, "Save", "SAVE", nil)
hboxButtons.Append(a.B, false) hboxButtons.Append(a.B, false)
a = CreateButton(wm, nil, vm, "Done", "DONE", nil) a = CreateButton(gb, nil, vm, "Done", "DONE", nil)
hboxButtons.Append(a.B, false) hboxButtons.Append(a.B, false)
AddBoxToTab(vm.Name, tab, vbox) AddBoxToTab(vm.Name, gw.UiTab, vbox)
} }
func createAddVmBox(wm *GuiWindow, tab *ui.Tab, name string, b *GuiButton) { func createAddVmBox(gw *GuiWindow, junk *ui.Tab, name string, b *GuiButton) {
log.Println("createAddVmBox() START") log.Println("createAddVmBox() START")
var gb *GuiBox
gb = new(GuiBox)
vbox := ui.NewVerticalBox() vbox := ui.NewVerticalBox()
vbox.SetPadded(true) vbox.SetPadded(true)
gb.UiBox = vbox
gb.W = gw
gw.BoxMap[name] = gb
// gw.UiTab.Append(vm.Name, vbox)
hbox := ui.NewHorizontalBox() hbox := ui.NewHorizontalBox()
hbox.SetPadded(true) hbox.SetPadded(true)
@ -86,16 +109,16 @@ func createAddVmBox(wm *GuiWindow, tab *ui.Tab, name string, b *GuiButton) {
newb.Action = "CREATE" newb.Action = "CREATE"
newb.VM = b.VM newb.VM = b.VM
newb.Account = b.Account newb.Account = b.Account
newb.T = tab newb.T = gw.UiTab
hostname.B = &newb hostname.B = &newb
memory.B = &newb memory.B = &newb
disk.B = &newb disk.B = &newb
hboxButtons.Append(AddButton(&newb, "Add Virtual Machine"), false) hboxButtons.Append(AddButton(&newb, "Add Virtual Machine"), false)
// hboxButtons.Append(CreateButton(nil, nil, "Add Virtual Machine","CREATE",nil), false) // hboxButtons.Append(CreateButton(nil, nil, "Add Virtual Machine","CREATE",nil), false)
a := CreateButton(wm, nil, nil, "Cancel", "CLOSE", nil) a := CreateButton(gb, nil, nil, "Cancel", "CLOSE", nil)
hboxButtons.Append(a.B, false) hboxButtons.Append(a.B, false)
name += " (" + b.Account.Nick + ")" name += " (" + b.Account.Nick + ")"
AddBoxToTab(name, tab, vbox) AddBoxToTab(name, gw.UiTab, vbox)
} }