those things are 'rows' in the table
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
e41764285c
commit
b28c2c09fa
34
table.go
34
table.go
|
@ -15,23 +15,21 @@ type cellTest struct {
|
|||
jwc [20]ui.TableValue
|
||||
}
|
||||
|
||||
/*
|
||||
type cellValue struct {
|
||||
ref int // libUI reference int
|
||||
value ui.TableValue // cell Value (TableString, TableColor or TableImage)
|
||||
}
|
||||
*/
|
||||
|
||||
type modelHandler struct {
|
||||
name string
|
||||
rowcount int
|
||||
rowBGcolor int
|
||||
|
||||
// new attempt
|
||||
allRows []cellValue
|
||||
rows []cellTest
|
||||
|
||||
// old attempt that works
|
||||
cellValues []cellTest
|
||||
|
||||
generatedColumnTypes []ui.TableValue // attempt to generate this dynamically
|
||||
generatedColumnTypes []ui.TableValue // generate this dynamically
|
||||
|
||||
// This is a needed function for libUI tables (maybe)
|
||||
setCellValue func(*modelHandler, *ui.TableModel, int, int, ui.TableValue)
|
||||
|
@ -53,35 +51,35 @@ func initValues(mh *modelHandler) {
|
|||
|
||||
// alternate background of each row light and dark
|
||||
if (i % 2) == 1 {
|
||||
mh.cellValues[i].jwc[0] = ui.TableColor{0.5, 0.5, 0.5, .7}
|
||||
mh.rows[i].jwc[0] = ui.TableColor{0.5, 0.5, 0.5, .7}
|
||||
} else {
|
||||
mh.cellValues[i].jwc[0] = ui.TableColor{0.1, 0.1, 0.1, .1}
|
||||
mh.rows[i].jwc[0] = ui.TableColor{0.1, 0.1, 0.1, .1}
|
||||
}
|
||||
|
||||
// text for Column 0
|
||||
mh.cellValues[i].jwc[1] = ui.TableString(fmt.Sprintf("fun %d", i))
|
||||
mh.rows[i].jwc[1] = ui.TableString(fmt.Sprintf("fun %d", i))
|
||||
|
||||
// text color for Column 0
|
||||
mh.cellValues[i].jwc[2] = ui.TableColor{0.9, 0, 0, 1}
|
||||
mh.rows[i].jwc[2] = ui.TableColor{0.9, 0, 0, 1}
|
||||
|
||||
// set the button text for Column 1
|
||||
mh.cellValues[i].jwc[3] = ui.TableString(fmt.Sprintf("awesome %d", i))
|
||||
mh.rows[i].jwc[3] = ui.TableString(fmt.Sprintf("awesome %d", i))
|
||||
|
||||
|
||||
// text for Column 2
|
||||
mh.cellValues[i].jwc[4] = ui.TableString(fmt.Sprintf("color %d", i))
|
||||
mh.rows[i].jwc[4] = ui.TableString(fmt.Sprintf("color %d", i))
|
||||
|
||||
// text color for Column 2
|
||||
mh.cellValues[i].jwc[5] = ui.TableColor{0.9, 0, 0, 1}
|
||||
mh.rows[i].jwc[5] = ui.TableColor{0.9, 0, 0, 1}
|
||||
|
||||
// text for Column 3
|
||||
mh.cellValues[i].jwc[6] = ui.TableString(fmt.Sprintf("imgcolor %d", i))
|
||||
mh.rows[i].jwc[6] = ui.TableString(fmt.Sprintf("imgcolor %d", i))
|
||||
|
||||
// image for Column 3
|
||||
mh.cellValues[i].jwc[7] = ui.TableImage{img[0]}
|
||||
mh.rows[i].jwc[7] = ui.TableImage{img[0]}
|
||||
|
||||
// text color for Column 3
|
||||
mh.cellValues[i].jwc[8] = ui.TableColor{0.9, 0, 0, 1}
|
||||
mh.rows[i].jwc[8] = ui.TableColor{0.9, 0, 0, 1}
|
||||
}
|
||||
// os.Exit(-1)
|
||||
}
|
||||
|
@ -96,7 +94,7 @@ func newModelHandler(rowcount int) *modelHandler {
|
|||
|
||||
mh.rowBGcolor = 0 // this is the weird exception. Just always have this as 0
|
||||
|
||||
mh.cellValues = make([]cellTest, mh.rowcount)
|
||||
mh.rows = make([]cellTest, mh.rowcount)
|
||||
|
||||
initValues(mh)
|
||||
|
||||
|
@ -140,7 +138,7 @@ func defaultSetCellValue(mh *modelHandler, m *ui.TableModel, row, column int, va
|
|||
switch column {
|
||||
case 0:
|
||||
case 1:
|
||||
mh.cellValues[row].jwc[1] = value
|
||||
mh.rows[row].jwc[1] = value
|
||||
case 2:
|
||||
case 3:
|
||||
log.Println("Button was pressed START", row, column)
|
||||
|
|
|
@ -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.cellValues[row].jwc[column]
|
||||
return mh.rows[row].jwc[column]
|
||||
}
|
||||
|
||||
func (mh *modelHandler) SetCellValue(m *ui.TableModel, row, column int, value ui.TableValue) {
|
||||
|
|
Loading…
Reference in New Issue