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