minor cleanups

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-08 03:41:41 -07:00
parent fb89975cdf
commit f8e6200c4c
1 changed files with 19 additions and 17 deletions

View File

@ -31,14 +31,11 @@ type rowData struct {
}
type modelHandler struct {
name string
rowcount int
rowBGcolor int
rows []rowData
name string // I forgot where this goes
rowcount int // This is the number of 'rows' which really means data elements not what the human sees
rowBGcolor int // This is what index stores the row BG color (should always be 0)
rows []rowData // This is all the table data by row
generatedColumnTypes []ui.TableValue // generate this dynamically
libUIevent func(*modelHandler, *ui.TableModel, int, int, ui.TableValue)
}
@ -59,34 +56,43 @@ func initValues(mh *modelHandler) {
// alternate background of each row light and dark
if (i % 2) == 1 {
mh.rows[i].cells[0].value = ui.TableColor{0.5, 0.5, 0.5, .7}
mh.rows[i].cells[0].name = "BG"
} else {
mh.rows[i].cells[0].value = ui.TableColor{0.1, 0.1, 0.1, .1}
mh.rows[i].cells[0].name = "BG"
}
// text for Column 0
mh.rows[i].cells[1].value = ui.TableString(fmt.Sprintf("fun %d", i))
mh.rows[i].cells[1].name = "EDIT"
// text color for Column 0
mh.rows[i].cells[2].value = ui.TableColor{0.9, 0, 0, 1}
mh.rows[i].cells[2].name = "COLOR"
// set the button text for Column 1
mh.rows[i].cells[3].value = ui.TableString(fmt.Sprintf("awesome %d", i))
mh.rows[i].cells[3].name = "BUTTON"
// text for Column 2
mh.rows[i].cells[4].value = ui.TableString(fmt.Sprintf("color %d", i))
mh.rows[i].cells[4].name = "EDIT"
// text color for Column 2
mh.rows[i].cells[5].value = ui.TableColor{0.9, 0, 0, 1}
mh.rows[i].cells[5].name = "COLOR"
// text for Column 3
mh.rows[i].cells[6].value = ui.TableString(fmt.Sprintf("imgcolor %d", i))
// image for Column 3
mh.rows[i].cells[7].value = ui.TableImage{img[0]}
mh.rows[i].cells[7].name = "IMAGE"
// text color for Column 3
mh.rows[i].cells[8].value = ui.TableColor{0.9, 0, 0, 1}
mh.rows[i].cells[8].name = "COLOR"
}
// os.Exit(-1)
}
@ -94,13 +100,12 @@ func initValues(mh *modelHandler) {
func newModelHandler(rowcount int) *modelHandler {
mh := new(modelHandler)
mh.rowBGcolor = 0 // this is the weird exception. Just always have this as 0
mh.rowcount = rowcount
// This is the standard callback function from libUI when the user does something
mh.libUIevent = defaultSetCellValue
mh.rowBGcolor = 0 // this is the weird exception. Just always have this as 0
mh.rows = make([]rowData, mh.rowcount)
initValues(mh)
@ -142,14 +147,11 @@ func makeTable(name string, rowcount int, row1Name string) (*ui.Table, *modelHan
}
func defaultSetCellValue(mh *modelHandler, m *ui.TableModel, row, column int, value ui.TableValue) {
switch column {
case 0:
case 1:
mh.rows[row].cells[1].value = value
case 2:
case 3:
log.Println("Button was pressed START", row, column)
if (mh.rows[row].cells[column].name == "EDIT") {
mh.rows[row].cells[column].value = value
}
if (mh.rows[row].cells[column].name == "BUTTON") {
log.Println("FOUND THE BUTTON!!!!!!! Button was pressed START", row, column)
}
log.Println("ui.TableValue=", value)
return
}