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"
|
|
|
|
|
|
|
|
import "github.com/andlabs/ui"
|
|
|
|
import _ "github.com/andlabs/ui/winmanifest"
|
|
|
|
|
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-12 23:21:13 -05:00
|
|
|
if (column == mh.Rows[row].Human[humanID].TextID) {
|
|
|
|
return mh.Rows[row].Human[humanID].Text
|
|
|
|
}
|
2019-05-12 23:44:05 -05:00
|
|
|
if (column == mh.Rows[row].Human[humanID].ColorID) {
|
|
|
|
return mh.Rows[row].Human[humanID].Color
|
|
|
|
}
|
2019-05-13 01:17:48 -05:00
|
|
|
panic("not sure what sort of ui.TableValue to return in CellValue()")
|
|
|
|
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-12 17:11:32 -05:00
|
|
|
if (mh.cellChangeEvent != nil) {
|
|
|
|
mh.cellChangeEvent(row, column, value)
|
|
|
|
}
|
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-12 23:01:22 -05:00
|
|
|
log.Println("mh.Rows[row].Human[humanID].ColorID =", mh.Rows[row].Human[humanID].ColorID)
|
|
|
|
log.Println("mh.Rows[row].Human[humanID].TextID =", mh.Rows[row].Human[humanID].TextID)
|
|
|
|
|
|
|
|
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-13 01:37:27 -05:00
|
|
|
log.Println("defaultSetCellValue() FOUND THE BUTTON!!!!!!! Button was pressed START", row, column)
|
|
|
|
}
|
|
|
|
}
|