better variable names
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
6a9ff162d9
commit
7d01a72e59
56
gui.go
56
gui.go
|
@ -5,6 +5,9 @@ import "log"
|
||||||
import "github.com/andlabs/ui"
|
import "github.com/andlabs/ui"
|
||||||
import _ "github.com/andlabs/ui/winmanifest"
|
import _ "github.com/andlabs/ui/winmanifest"
|
||||||
|
|
||||||
|
import "github.com/gookit/config"
|
||||||
|
import "github.com/davecgh/go-spew/spew"
|
||||||
|
|
||||||
var mainwin *ui.Window
|
var mainwin *ui.Window
|
||||||
var maintab *ui.Tab
|
var maintab *ui.Tab
|
||||||
var tabcount int
|
var tabcount int
|
||||||
|
@ -12,13 +15,17 @@ var tabcount int
|
||||||
var Width int
|
var Width int
|
||||||
var Height int
|
var Height int
|
||||||
|
|
||||||
type InputData struct {
|
type TableColumnData struct {
|
||||||
Index int
|
Index int
|
||||||
CellType string
|
CellType string
|
||||||
Heading string
|
Heading string
|
||||||
Color string
|
Color string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ButtonMap struct {
|
||||||
|
B *ui.Button
|
||||||
|
}
|
||||||
|
|
||||||
func setupUI() {
|
func setupUI() {
|
||||||
mainwin = ui.NewWindow("Cloud Control Panel", Width, Height, false)
|
mainwin = ui.NewWindow("Cloud Control Panel", Width, Height, false)
|
||||||
mainwin.OnClosing(func(*ui.Window) bool {
|
mainwin.OnClosing(func(*ui.Window) bool {
|
||||||
|
@ -43,7 +50,7 @@ func AddNewTab(mytab *ui.Tab, newbox ui.Control, tabOffset int) {
|
||||||
mytab.SetMargined(tabOffset, true)
|
mytab.SetMargined(tabOffset, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitColumns(mh *TableData, parts []InputData) {
|
func InitColumns(mh *TableData, parts []TableColumnData) {
|
||||||
tmpBTindex := 0
|
tmpBTindex := 0
|
||||||
humanID := 0
|
humanID := 0
|
||||||
for key, foo := range parts {
|
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 := new(TableData)
|
||||||
|
|
||||||
mh.RowCount = rowcount
|
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)
|
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
|
return mh
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,3 +150,27 @@ func DoGUI() {
|
||||||
log.Println("GUI exited. Not sure what to do here. os.Exit() ?")
|
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
|
||||||
|
}
|
||||||
|
|
8
table.go
8
table.go
|
@ -51,7 +51,7 @@ type TableData struct {
|
||||||
Human [20]HumanMap
|
Human [20]HumanMap
|
||||||
}
|
}
|
||||||
|
|
||||||
func initRowBTcolor(mh *TableData, intBG int, cell InputData) {
|
func initRowBTcolor(mh *TableData, intBG int, cell TableColumnData) {
|
||||||
humanInt := cell.Index
|
humanInt := cell.Index
|
||||||
|
|
||||||
// setup mapping from human readable indexes to internal libUI indexes
|
// 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)
|
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
|
humanInt := cell.Index
|
||||||
|
|
||||||
// setup mapping from human readable indexes to internal libUI indexes
|
// 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)
|
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
|
humanInt := cell.Index
|
||||||
|
|
||||||
// setup mapping from human readable indexes to internal libUI indexes
|
// 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
|
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
|
humanInt := cell.Index
|
||||||
|
|
||||||
// setup mapping from human readable indexes to internal libUI indexes
|
// setup mapping from human readable indexes to internal libUI indexes
|
||||||
|
|
Loading…
Reference in New Issue