2019-05-08 15:09:17 -05:00
|
|
|
package gui
|
2019-05-08 15:04:18 -05:00
|
|
|
|
|
|
|
//
|
|
|
|
// These functions are the hooks to the andlabs libui
|
|
|
|
// They eventually feed information to the OS native GUI toolkits
|
|
|
|
// and feed back user interaction with the GUI
|
|
|
|
//
|
|
|
|
|
|
|
|
import "log"
|
2019-05-15 13:03:42 -05:00
|
|
|
import "fmt"
|
2019-05-21 17:17:50 -05:00
|
|
|
import "image/color"
|
2019-05-08 15:04:18 -05:00
|
|
|
|
|
|
|
import "github.com/andlabs/ui"
|
|
|
|
import _ "github.com/andlabs/ui/winmanifest"
|
|
|
|
|
2019-05-21 20:42:14 -05:00
|
|
|
import "github.com/gookit/config"
|
2019-05-21 20:25:08 -05:00
|
|
|
|
2019-05-12 17:11:32 -05:00
|
|
|
func (mh *TableData) NumRows(m *ui.TableModel) int {
|
2019-05-21 20:42:14 -05:00
|
|
|
if (config.String("debugging") == "true") {
|
2019-05-21 20:25:08 -05:00
|
|
|
log.Println("NumRows = mh.RowCount = ", mh.RowCount)
|
2019-05-21 20:42:14 -05:00
|
|
|
}
|
2019-05-12 17:11:32 -05:00
|
|
|
return mh.RowCount
|
2019-05-08 15:04:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// FYI: this routine seems to be called around 10 to 100 times a second for each table
|
2019-05-12 17:11:32 -05:00
|
|
|
func (mh *TableData) ColumnTypes(m *ui.TableModel) []ui.TableValue {
|
2019-05-21 20:42:14 -05:00
|
|
|
if (config.String("debugging") == "true") {
|
2019-05-21 20:25:08 -05:00
|
|
|
log.Println("ColumnTypes = ", mh.generatedColumnTypes)
|
2019-05-21 20:42:14 -05:00
|
|
|
}
|
2019-05-08 15:04:18 -05:00
|
|
|
return mh.generatedColumnTypes
|
|
|
|
}
|
|
|
|
|
2019-05-21 17:17:50 -05:00
|
|
|
func libuiColorToGOlangColor(rgba color.RGBA) ui.TableColor {
|
|
|
|
return ui.TableColor{float64(rgba.R) / 256, float64(rgba.G) / 256, float64(rgba.B) / 256, float64(rgba.A) / 256}
|
|
|
|
}
|
|
|
|
|
2019-05-08 15:04:18 -05:00
|
|
|
// TODO: Figure out why this is being called 1000 times a second (10 times for each row & column)
|
|
|
|
// Nevermind this TODO. Who gives a shit. This is a really smart way to treat the OS toolkits
|
2019-05-12 17:11:32 -05:00
|
|
|
func (mh *TableData) CellValue(m *ui.TableModel, row, column int) ui.TableValue {
|
2019-05-21 20:42:14 -05:00
|
|
|
if (config.String("debugging") == "true") {
|
2019-05-21 20:28:20 -05:00
|
|
|
log.Println("CellValue() row, column =", row, column)
|
2019-05-21 20:42:14 -05:00
|
|
|
}
|
2019-05-13 01:49:26 -05:00
|
|
|
humanID := mh.Cells[column].HumanID
|
2019-05-13 01:56:53 -05:00
|
|
|
if (column == mh.Human[humanID].TextID) {
|
2019-05-21 16:48:15 -05:00
|
|
|
return ui.TableString(mh.Rows[row].HumanData[humanID].Text)
|
2019-05-12 23:21:13 -05:00
|
|
|
}
|
2019-05-13 01:56:53 -05:00
|
|
|
if (column == mh.Human[humanID].ColorID) {
|
2019-05-21 17:17:50 -05:00
|
|
|
return libuiColorToGOlangColor(mh.Rows[row].HumanData[humanID].Color)
|
2019-05-12 23:44:05 -05:00
|
|
|
}
|
2019-05-13 02:30:38 -05:00
|
|
|
log.Println("CellValue() FAILURE")
|
|
|
|
log.Println("CellValue() FAILURE")
|
|
|
|
log.Println("CellValue() row, column = ", row, column)
|
|
|
|
log.Println("CellValue() FAILURE")
|
|
|
|
log.Println("CellValue() FAILURE")
|
|
|
|
log.Println("CellValue() mh.Cells", mh.Cells)
|
|
|
|
log.Println("CellValue() mh.Human", mh.Human)
|
|
|
|
panic("CellValue() not sure what sort of ui.TableValue to return in CellValue()")
|
2019-05-13 01:17:48 -05:00
|
|
|
return ui.TableString("")
|
2019-05-08 15:04:18 -05:00
|
|
|
}
|
|
|
|
|
2019-05-12 17:11:32 -05:00
|
|
|
func (mh *TableData) SetCellValue(m *ui.TableModel, row, column int, value ui.TableValue) {
|
2019-05-12 23:01:22 -05:00
|
|
|
log.Println("SetCellValue() START row=", row, "column=", column, "value=", value)
|
|
|
|
|
2019-05-13 01:37:27 -05:00
|
|
|
defaultSetCellValue(mh, row, column)
|
2019-05-12 23:01:22 -05:00
|
|
|
|
2019-05-13 01:49:26 -05:00
|
|
|
log.Println("mh.Cells[column].HumanID =", mh.Cells[column].HumanID)
|
|
|
|
// log.Println("mh.Rows[row].Cells[column].HumanID =", mh.Rows[row].Cells[column].HumanID)
|
2019-05-12 23:01:22 -05:00
|
|
|
|
2019-05-13 01:49:26 -05:00
|
|
|
humanID := mh.Cells[column].HumanID
|
2019-05-13 01:56:53 -05:00
|
|
|
log.Println("mh.Human[humanID].ColorID =", mh.Human[humanID].ColorID)
|
|
|
|
log.Println("mh.Human[humanID].TextID =", mh.Human[humanID].TextID)
|
2019-05-12 23:01:22 -05:00
|
|
|
|
|
|
|
log.Println("SetCellValue() END")
|
2019-05-08 15:04:18 -05:00
|
|
|
}
|
2019-05-13 01:37:27 -05:00
|
|
|
|
|
|
|
func defaultSetCellValue(mh *TableData, row int, column int) {
|
2019-05-13 01:49:26 -05:00
|
|
|
if (mh.Cells[column].Name == "BUTTON") {
|
2019-05-15 13:03:42 -05:00
|
|
|
humanID := mh.Cells[column].HumanID
|
|
|
|
vmname := mh.Rows[row].HumanData[humanID].Text
|
|
|
|
log.Println("vmname =", vmname)
|
2019-05-13 01:37:27 -05:00
|
|
|
log.Println("defaultSetCellValue() FOUND THE BUTTON!!!!!!! Button was pressed START", row, column)
|
2019-05-22 21:18:55 -05:00
|
|
|
Data.CurrentVM = fmt.Sprintf("%s",vmname)
|
|
|
|
log.Println("Data.CurrentVM =", Data.CurrentVM)
|
2019-05-15 13:03:42 -05:00
|
|
|
go ui.Main(ShowVM)
|
2019-05-13 01:37:27 -05:00
|
|
|
}
|
|
|
|
}
|