diff --git a/table.go b/table.go index 81e8df3..6bd29fd 100644 --- a/table.go +++ b/table.go @@ -11,8 +11,23 @@ import "github.com/davecgh/go-spew/spew" var img [2]*ui.Image -type cellTest struct { - jwc [20]ui.TableValue +type cellData struct { + index int + value ui.TableValue + name string // what type of cell is this? + event func() // what function to call if there is an event on this +} + +// hmm. will this stand the test of time? +type rowData struct { + name string // what kind of row is this? + status string // status of the row? +/* + // These may or may not be implementable + click func() // what function to call if the user clicks on it + doubleclick func() // what function to call if the user double clicks on it +*/ + cells [20]cellData } type modelHandler struct { @@ -20,7 +35,7 @@ type modelHandler struct { rowcount int rowBGcolor int - rows []cellTest + rows []rowData generatedColumnTypes []ui.TableValue // generate this dynamically @@ -43,35 +58,35 @@ func initValues(mh *modelHandler) { // alternate background of each row light and dark if (i % 2) == 1 { - mh.rows[i].jwc[0] = ui.TableColor{0.5, 0.5, 0.5, .7} + mh.rows[i].cells[0].value = ui.TableColor{0.5, 0.5, 0.5, .7} } else { - mh.rows[i].jwc[0] = ui.TableColor{0.1, 0.1, 0.1, .1} + mh.rows[i].cells[0].value = ui.TableColor{0.1, 0.1, 0.1, .1} } // text for Column 0 - mh.rows[i].jwc[1] = ui.TableString(fmt.Sprintf("fun %d", i)) + mh.rows[i].cells[1].value = ui.TableString(fmt.Sprintf("fun %d", i)) // text color for Column 0 - mh.rows[i].jwc[2] = ui.TableColor{0.9, 0, 0, 1} + mh.rows[i].cells[2].value = ui.TableColor{0.9, 0, 0, 1} // set the button text for Column 1 - mh.rows[i].jwc[3] = ui.TableString(fmt.Sprintf("awesome %d", i)) + mh.rows[i].cells[3].value = ui.TableString(fmt.Sprintf("awesome %d", i)) // text for Column 2 - mh.rows[i].jwc[4] = ui.TableString(fmt.Sprintf("color %d", i)) + mh.rows[i].cells[4].value = ui.TableString(fmt.Sprintf("color %d", i)) // text color for Column 2 - mh.rows[i].jwc[5] = ui.TableColor{0.9, 0, 0, 1} + mh.rows[i].cells[5].value = ui.TableColor{0.9, 0, 0, 1} // text for Column 3 - mh.rows[i].jwc[6] = ui.TableString(fmt.Sprintf("imgcolor %d", i)) + mh.rows[i].cells[6].value = ui.TableString(fmt.Sprintf("imgcolor %d", i)) // image for Column 3 - mh.rows[i].jwc[7] = ui.TableImage{img[0]} + mh.rows[i].cells[7].value = ui.TableImage{img[0]} // text color for Column 3 - mh.rows[i].jwc[8] = ui.TableColor{0.9, 0, 0, 1} + mh.rows[i].cells[8].value = ui.TableColor{0.9, 0, 0, 1} } // os.Exit(-1) } @@ -86,7 +101,7 @@ func newModelHandler(rowcount int) *modelHandler { mh.rowBGcolor = 0 // this is the weird exception. Just always have this as 0 - mh.rows = make([]cellTest, mh.rowcount) + mh.rows = make([]rowData, mh.rowcount) initValues(mh) @@ -130,7 +145,7 @@ func defaultSetCellValue(mh *modelHandler, m *ui.TableModel, row, column int, va switch column { case 0: case 1: - mh.rows[row].jwc[1] = value + mh.rows[row].cells[1].value = value case 2: case 3: log.Println("Button was pressed START", row, column) diff --git a/tableCallbacks.go b/tableCallbacks.go index 7f869dd..200d024 100644 --- a/tableCallbacks.go +++ b/tableCallbacks.go @@ -24,7 +24,7 @@ func (mh *modelHandler) ColumnTypes(m *ui.TableModel) []ui.TableValue { // 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 func (mh *modelHandler) CellValue(m *ui.TableModel, row, column int) ui.TableValue { - return mh.rows[row].jwc[column] + return mh.rows[row].cells[column].value } func (mh *modelHandler) SetCellValue(m *ui.TableModel, row, column int, value ui.TableValue) {