summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gui.go56
-rw-r--r--table.go8
2 files changed, 56 insertions, 8 deletions
diff --git a/gui.go b/gui.go
index 40243bb..72181a9 100644
--- a/gui.go
+++ b/gui.go
@@ -5,6 +5,9 @@ import "log"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
+import "github.com/gookit/config"
+import "github.com/davecgh/go-spew/spew"
+
var mainwin *ui.Window
var maintab *ui.Tab
var tabcount int
@@ -12,13 +15,17 @@ var tabcount int
var Width int
var Height int
-type InputData struct {
+type TableColumnData struct {
Index int
CellType string
Heading string
Color string
}
+type ButtonMap struct {
+ B *ui.Button
+}
+
func setupUI() {
mainwin = ui.NewWindow("Cloud Control Panel", Width, Height, false)
mainwin.OnClosing(func(*ui.Window) bool {
@@ -43,7 +50,7 @@ func AddNewTab(mytab *ui.Tab, newbox ui.Control, tabOffset int) {
mytab.SetMargined(tabOffset, true)
}
-func InitColumns(mh *TableData, parts []InputData) {
+func InitColumns(mh *TableData, parts []TableColumnData) {
tmpBTindex := 0
humanID := 0
for key, foo := range parts {
@@ -77,7 +84,7 @@ func InitColumns(mh *TableData, parts []InputData) {
}
}
-func AddTableTab(mytab *ui.Tab, mytabcount int, name string, rowcount int, parts []InputData) *TableData {
+func AddTableTab(mytab *ui.Tab, mytabcount int, name string, rowcount int, parts []TableColumnData) *TableData {
mh := new(TableData)
mh.RowCount = rowcount
@@ -114,9 +121,26 @@ func AddTableTab(mytab *ui.Tab, mytabcount int, name string, rowcount int, parts
}
}
- mytab.Append(name, table)
+ vbox := ui.NewVerticalBox()
+ vbox.SetPadded(true)
+
+ vbox.Append(table, true)
+ mytab.Append(name, vbox)
mytab.SetMargined(mytabcount, true)
+ vbox.Append(ui.NewVerticalSeparator(), false)
+
+ hbox := ui.NewHorizontalBox()
+ hbox.SetPadded(true)
+
+ myAddVM := addVmButton("Add Virtual Machine")
+ hbox.Append(myAddVM, false)
+
+ myClose := closeButton("Close", mytab)
+ hbox.Append(myClose, false)
+
+ vbox.Append(hbox, false)
+
return mh
}
@@ -126,3 +150,27 @@ func DoGUI() {
log.Println("GUI exited. Not sure what to do here. os.Exit() ?")
}
}
+
+func closeButtonClick(button *ui.Button) {
+ log.Println("closeButtonClick() hostname =", config.String("hostname"), button)
+ spew.Dump(button)
+}
+
+func closeButton(name string, mytab *ui.Tab) ui.Control {
+ tmpButton := ui.NewButton(name)
+ tmpButton.OnClicked(buttonClick)
+
+ return tmpButton
+}
+
+func addVmButtonClick(button *ui.Button) {
+ log.Println("addVMButtonClick()")
+ spew.Dump(button)
+}
+
+func addVmButton(name string) ui.Control {
+ tmpButton := ui.NewButton(name)
+ tmpButton.OnClicked(addVmButtonClick)
+
+ return tmpButton
+}
diff --git a/table.go b/table.go
index 1833105..f633cd8 100644
--- a/table.go
+++ b/table.go
@@ -51,7 +51,7 @@ type TableData struct {
Human [20]HumanMap
}
-func initRowBTcolor(mh *TableData, intBG int, cell InputData) {
+func initRowBTcolor(mh *TableData, intBG int, cell TableColumnData) {
humanInt := cell.Index
// setup mapping from human readable indexes to internal libUI indexes
@@ -65,7 +65,7 @@ func initRowBTcolor(mh *TableData, intBG int, cell InputData) {
log.Println("intBG, humanInt", intBG, humanInt)
}
-func initRowButtonColumn(mh *TableData, buttonID int, junk string, cell InputData) {
+func initRowButtonColumn(mh *TableData, buttonID int, junk string, cell TableColumnData) {
humanInt := cell.Index
// setup mapping from human readable indexes to internal libUI indexes
@@ -79,7 +79,7 @@ func initRowButtonColumn(mh *TableData, buttonID int, junk string, cell InputDat
log.Println("buttonID, humanInt", buttonID, humanInt)
}
-func initRowTextColorColumn(mh *TableData, stringID int, colorID int, junk string, color ui.TableColor, cell InputData) {
+func initRowTextColorColumn(mh *TableData, stringID int, colorID int, junk string, color ui.TableColor, cell TableColumnData) {
humanInt := cell.Index
// setup mapping from human readable indexes to internal libUI indexes
@@ -95,7 +95,7 @@ func initRowTextColorColumn(mh *TableData, stringID int, colorID int, junk strin
mh.Cells[colorID].HumanID = humanInt
}
-func initRowTextColumn(mh *TableData, stringID int, junk string, cell InputData) {
+func initRowTextColumn(mh *TableData, stringID int, junk string, cell TableColumnData) {
humanInt := cell.Index
// setup mapping from human readable indexes to internal libUI indexes