summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2019-05-31 06:58:23 -0700
committerJeff Carr <[email protected]>2019-05-31 06:58:23 -0700
commit64401667b62a7621c2e71bc0f47c9f0d47c4106f (patch)
tree87c6c16928a548fed0953c40e3eaccfc2256ee55
parentaec7fc3b5780d396641f4f26df55009976d6449f (diff)
continue variable and structure improvements
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--gui.go2
-rw-r--r--mainCloudBox.go113
-rw-r--r--splash.go10
-rw-r--r--structs.go70
4 files changed, 97 insertions, 98 deletions
diff --git a/gui.go b/gui.go
index f9b6875..4aa9886 100644
--- a/gui.go
+++ b/gui.go
@@ -237,7 +237,7 @@ func CreateFontButton(wm *GuiWindow, action string) *GuiButton {
var newBM GuiButton
newBM.Action = action
newBM.FB = newB
- newBM.AH = wm.AH
+ newBM.Area = wm.Area
Data.AllButtons = append(Data.AllButtons, &newBM)
newB.OnChanged(func (*ui.FontButton) {
diff --git a/mainCloudBox.go b/mainCloudBox.go
index 3b9cef7..019e628 100644
--- a/mainCloudBox.go
+++ b/mainCloudBox.go
@@ -13,7 +13,7 @@ import pb "git.wit.com/wit/witProtobuf"
// import "github.com/davecgh/go-spew/spew"
-func makeCloudInfoBox(wm *GuiWindow) *ui.Box {
+func makeCloudInfoBox(gw *GuiWindow) *ui.Box {
hbox := ui.NewHorizontalBox()
hbox.SetPadded(true)
@@ -23,7 +23,7 @@ func makeCloudInfoBox(wm *GuiWindow) *ui.Box {
vbox.SetPadded(true)
hbox.Append(vbox, false)
- addDebuggingButtons(wm, vbox)
+ addDebuggingButtons(gw, vbox)
hbox.Append(ui.NewVerticalSeparator(), false)
}
@@ -46,7 +46,7 @@ func makeCloudInfoBox(wm *GuiWindow) *ui.Box {
hostnameEntry.SetText(tmp)
hostnameEntry.SetReadOnly(true)
- anew := CreateButton(wm, nil, nil, "Edit", "EDIT", nil)
+ anew := CreateButton(gw, nil, nil, "Edit", "EDIT", nil)
hostnamebox.Append(anew.B, false)
vbox.Append(ui.NewHorizontalSeparator(), false)
@@ -71,11 +71,11 @@ func makeCloudInfoBox(wm *GuiWindow) *ui.Box {
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
- l := CreateButton(wm, Data.Config.Accounts[key], nil, name, "LOGIN", nil)
+ l := CreateButton(gw, Data.Config.Accounts[key], nil, name, "LOGIN", nil)
agrid.Append(l.B, 3, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
name = "Show " + Data.Config.Accounts[key].Nick
- b := CreateButton(wm, Data.Config.Accounts[key], nil, name, "SHOW", nil)
+ b := CreateButton(gw, Data.Config.Accounts[key], nil, name, "SHOW", nil)
agrid.Append(b.B, 4, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
row += 1
@@ -84,9 +84,9 @@ func makeCloudInfoBox(wm *GuiWindow) *ui.Box {
row += 1
agrid.Append(ui.NewLabel(""), 1, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
row += 1
- a := CreateButton(wm, nil, nil, "Add Account", "ADD TAB", nil)
+ a := CreateButton(gw, nil, nil, "Add Account", "ADD TAB", nil)
agrid.Append(a.B, 4, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
- q := CreateButton(wm, nil, nil, "Quit", "QUIT", nil)
+ q := CreateButton(gw, nil, nil, "Quit", "QUIT", nil)
agrid.Append(q.B, 5, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
vbox.Append(agrid, false)
@@ -102,7 +102,7 @@ func makeCloudInfoBox(wm *GuiWindow) *ui.Box {
// which could be anything since TEXTCOLOR, TEXT, BG, etc
// fields use between 1 and 3 values internally
//
-func AddVmsTab(wm *GuiWindow, name string, count int, a *pb.Account) *TableData {
+func AddVmsTab(gw *GuiWindow, name string, count int, a *pb.Account) *TableData {
var parts []TableColumnData
human := 0
@@ -156,64 +156,71 @@ func AddVmsTab(wm *GuiWindow, name string, count int, a *pb.Account) *TableData
parts = append(parts, tmp)
human += 1
- mh := AddTableTab(wm, wm.T, 1, name, count, parts, a)
+ mh := AddTableTab(gw, gw.T, 1, name, count, parts, a)
return mh
}
-func ShowAccountQuestionTab(wm *GuiWindow) {
- log.Println("ShowAccountQuestionTab() wm =", wm)
- if (wm.T == nil) {
- log.Println("ShowAccountQuestionTab() wm.T = nil THIS IS BAD")
+func ShowAccountQuestionTab(gw *GuiWindow) {
+ log.Println("ShowAccountQuestionTab() gw =", gw)
+ if (gw.T == nil) {
+ log.Println("ShowAccountQuestionTab() gw.T = nil THIS IS BAD")
os.Exit(-1)
}
- wm.T.Delete(0)
+ gw.T.Delete(0)
log.Println("Sleep(200)")
time.Sleep(200 * time.Millisecond)
- wm.Box2 = AddAccountQuestionBox(wm)
- wm.T.InsertAt("New Account?", 0, wm.Box2)
- wm.T.SetMargined(0, true)
+ gw.Box2 = AddAccountQuestionBox(gw)
+ gw.T.InsertAt("New Account?", 0, gw.Box2)
+ gw.T.SetMargined(0, true)
}
-func ShowAccountTab(wm *GuiWindow, i int) {
+func ShowAccountTab(gw *GuiWindow, i int) {
log.Println("ShowAccountTab() START")
log.Println("Sleep(200)")
time.Sleep(200 * time.Millisecond)
// Create the things for the Account Tab
- abox := AddAccountBox(wm)
+ abox := AddAccountBox(gw)
// Set the parents and data structure links
- // aTab.me = wm.T
+ // aTab.me = gw.T
// aTab.parentWindow = Data.Window1.W
// aTab.tabOffset = 0
if (i >= 0) {
log.Println("ShowAccountTab() InsertAt i=", i)
- wm.T.Delete(0)
- wm.T.InsertAt("Add Account", i, abox)
- wm.T.SetMargined(0, true)
+ gw.T.Delete(0)
+ gw.T.InsertAt("Add Account", i, abox)
+ gw.T.SetMargined(0, true)
} else {
// TODO: After append try to discover the tab index #
log.Println("ShowAccountTab() Append")
- AddBoxToTab("Create New Account", wm.T, abox)
+ AddBoxToTab("Create New Account", gw.T, abox)
}
}
-func ShowMainTab(wm *GuiWindow) {
- log.Println("ShowMainTab() wm =", wm)
- log.Println("ShowMainTab() wm.T =", wm.T)
- log.Println("ShowMainTab() wm.T =", wm.T)
- wm.T.Delete(0)
+func ShowMainTab(gw *GuiWindow) {
+ log.Println("ShowMainTab() gw =", gw)
+ log.Println("ShowMainTab() gw.T =", gw.T)
+ gw.T.Delete(0)
log.Println("Sleep(200)")
time.Sleep(200 * time.Millisecond)
- wm.Box2 = makeCloudInfoBox(wm)
- wm.T.InsertAt("Main", 0, wm.Box2)
- wm.T.SetMargined(0, true)
+ gw.Box2 = makeCloudInfoBox(gw)
+ gw.T.InsertAt("Main", 0, gw.Box2)
+ gw.T.SetMargined(0, true)
+}
+
+func GuiInit() {
+ ui.OnShouldQuit(func() bool {
+ // mouseClick(&newBM)
+ ui.Quit()
+ return true
+ })
}
func StartNewWindow(c *pb.Config, bg bool, action string) {
@@ -223,12 +230,6 @@ func StartNewWindow(c *pb.Config, bg bool, action string) {
newGuiWindow.Action = action
Data.Windows = append(Data.Windows, &newGuiWindow)
- ui.OnShouldQuit(func() bool {
- // mouseClick(&newBM)
- ui.Quit()
- return true
- })
-
if (bg) {
log.Println("ShowWindow() IN NEW GOROUTINE")
go ui.Main(func() {
@@ -250,47 +251,47 @@ func getSplashText(a string) *ui.AttributedString {
}
-func InitWindow(wm *GuiWindow) {
+func InitWindow(gw *GuiWindow) {
log.Println("InitWindow() THIS WINDOW IS NOT YET SHOWN")
- c := wm.C
- wm.W = ui.NewWindow("", int(c.Width), int(c.Height), true)
- wm.W.SetBorderless(false)
+ c := gw.C
+ gw.W = ui.NewWindow("", int(c.Width), int(c.Height), true)
+ gw.W.SetBorderless(false)
// create a 'fake' button entry for the mouse clicks
var newBM GuiButton
newBM.Action = "QUIT"
- newBM.W = wm.W
- newBM.WM = wm
+ newBM.W = gw.W
+ newBM.WM = gw
Data.AllButtons = append(Data.AllButtons, &newBM)
- wm.W.OnClosing(func(*ui.Window) bool {
- log.Println("InitWindow() OnClosing() THIS WINDOW IS CLOSING wm=", wm)
+ gw.W.OnClosing(func(*ui.Window) bool {
+ log.Println("InitWindow() OnClosing() THIS WINDOW IS CLOSING gw=", gw)
// mouseClick(&newBM)
ui.Quit()
return true
})
- wm.T = ui.NewTab()
- wm.W.SetChild(wm.T)
- wm.W.SetMargined(true)
+ gw.T = ui.NewTab()
+ gw.W.SetChild(gw.T)
+ gw.W.SetMargined(true)
- log.Println("InitWindow() wm =", wm)
- log.Println("InitWindow() wm.Action =", wm.Action)
+ log.Println("InitWindow() gw =", gw)
+ log.Println("InitWindow() gw.Action =", gw.Action)
- if (wm.Action == "SPLASH") {
+ if (gw.Action == "SPLASH") {
log.Println("InitWindow() TRYING SPLASH")
damnit := "click" + string(c.Hostname)
tmp := getSplashText(damnit)
log.Println("InitWindow() TRYING SPLASH tmp =", tmp)
- wm.Box1 = ShowSplashBox(wm, tmp)
+ gw.Box1 = ShowSplashBox(gw, tmp)
- wm.T.Append("WIT Splash", wm.Box1)
- wm.T.SetMargined(0, true)
+ gw.T.Append("WIT Splash", gw.Box1)
+ gw.T.SetMargined(0, true)
}
Data.State = "splash"
- wm.W.Show()
+ gw.W.Show()
}
// makeEntryBox(box, "hostname:", "blah.foo.org") {
diff --git a/splash.go b/splash.go
index 92f154d..397430e 100644
--- a/splash.go
+++ b/splash.go
@@ -23,12 +23,12 @@ func ShowSplashBox(wm *GuiWindow, newText *ui.AttributedString) *ui.Box {
newbox.SetPadded(true)
// initialize the GuiArea{}
- wm.AH = new(GuiArea)
- wm.AH.WM = wm
- wm.AH.UiAttrstr = newText
- makeSplashArea(wm, wm.AH)
+ wm.Area = new(GuiArea)
+ wm.Area.Window = wm
+ wm.Area.UiAttrstr = newText
+ makeSplashArea(wm, wm.Area)
- newbox.Append(wm.AH.UiArea, true)
+ newbox.Append(wm.Area.UiArea, true)
if runtime.GOOS == "linux" {
newbox.Append(ui.NewLabel("OS: Linux"), false)
diff --git a/structs.go b/structs.go
index e78b39c..abd7707 100644
--- a/structs.go
+++ b/structs.go
@@ -22,10 +22,11 @@ type GuiData struct {
// if nothing else is defined to handle them
MouseClick func(*GuiButton)
- // account entry textboxes
+ // passes in all the User accounts from the cloud-control-panel config file
Config *pb.Config
// general information on the App
+ // move all this to Config (?)
Version string
GitCommit string
GoVersion string
@@ -35,20 +36,20 @@ type GuiData struct {
DebugTable bool
// official hostname and IPv6 address for this box
+ // also move all this to Config (?)
Hostname string
IPv6 string
+ // A map of all the entry boxes
+ AllEntries []*GuiEntry
+ Windows []*GuiWindow
+
// A map of all buttons everywhere on all
// windows, all tabs, across all goroutines
// This is "GLOBAL"
AllButtons []*GuiButton
ButtonMap map[*GuiButton][]func (*GuiButton)
- // A map of all the entry boxes
- AllEntries []*GuiEntry
-
- Windows []*GuiWindow
-
EntryNick *ui.Entry
EntryUser *ui.Entry
EntryPass *ui.Entry
@@ -59,62 +60,59 @@ type GuiData struct {
// the user clicks it. You could probably
// call this 'GuiMouseClick'
type GuiButton struct {
- // andlabs/ui stuff
- B *ui.Button
- FB *ui.FontButton
- A *ui.Area
- W *ui.Window
- T *ui.Tab
+ Action string // what type of button
+ Box *GuiBox // what box the button click was in
+ Area *GuiArea // indicates the button click was in an Area
+ WM *GuiWindow // what window the button click was in (redundant?)
- Box *GuiBox
- AH *GuiArea
-
- // git.wit.com/wit/gui stuff
- WM *GuiWindow
- Account *pb.Account
- VM *pb.Event_VM
- Action string // what type of button
+ Account *pb.Account // associated with what account?
+ VM *pb.Event_VM // associated with which VM?
// a callback function for the main application
custom func (*GuiButton)
+
+ // andlabs/ui abstraction mapping
+ B *ui.Button
+ FB *ui.FontButton
+ A *ui.Area // should be deprecated
+ W *ui.Window // should be deprecated
+ T *ui.Tab // should be deprecated
}
type GuiBox struct {
W *GuiWindow
EntryMap map[string]*GuiEntry
- A *GuiArea
+ Area *GuiArea
UiBox *ui.Box
}
type GuiEntry struct {
- E *ui.Entry
+ Action string // what type of button
Edit bool
Last string // the last value
Normalize func (string) string // function to 'normalize' the data
+ B *GuiButton
Account *pb.Account
VM *pb.Event_VM
- B *GuiButton
- FB *ui.FontButton
- A *ui.Area
- W *ui.Window
- T *ui.Tab
+ E *ui.Entry
+ W *ui.Window // should be moved to *GuiWindow or GuiBox
+ T *ui.Tab // should be moved to *GuiWindow or GuiBox
- Action string // what type of button
}
type GuiWindow struct {
+ Action string
+ Area *GuiArea // should be moved to GuiBox
+
+ C *pb.Config
+
W *ui.Window
T *ui.Tab
Box1 *ui.Box
Box2 *ui.Box
-
- C *pb.Config
-
- AH *GuiArea
- Action string
}
//
@@ -123,8 +121,8 @@ type GuiWindow struct {
// AREA STRUCTURES START
//
type GuiArea struct{
- WM *GuiWindow
- Button *GuiButton
+ Window *GuiWindow // what window this area is in (should be GuiBox?)
+ Button *GuiButton // what button handles mouse events
UiAttrstr *ui.AttributedString
UiArea *ui.Area
@@ -165,7 +163,7 @@ type TableData struct {
lastRow int
lastColumn int
- parentTab *ui.Tab
+// parentTab *ui.Tab
}
//