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-08 15:04:18 -05:00
|
|
|
|
|
|
|
import "github.com/andlabs/ui"
|
|
|
|
import _ "github.com/andlabs/ui/winmanifest"
|
|
|
|
|
2019-05-15 13:03:42 -05:00
|
|
|
var CurrentVM string
|
|
|
|
|
2019-05-12 17:11:32 -05:00
|
|
|
func (mh *TableData) NumRows(m *ui.TableModel) int {
|
|
|
|
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-08 15:04:18 -05:00
|
|
|
return mh.generatedColumnTypes
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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-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) {
|
|
|
|
return 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) {
|
|
|
|
return 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-15 13:03:42 -05:00
|
|
|
CurrentVM = fmt.Sprintf("%s",vmname)
|
|
|
|
log.Println("CurrentVM =", CurrentVM)
|
|
|
|
go ui.Main(ShowVM)
|
2019-05-13 01:37:27 -05:00
|
|
|
}
|
|
|
|
}
|