start renaming variables to figure out what to do next

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-08 03:02:32 -07:00
parent f5be9dbd1e
commit e41764285c
2 changed files with 14 additions and 18 deletions

View File

@ -22,7 +22,7 @@ type cellValue struct {
type modelHandler struct { type modelHandler struct {
name string name string
rows int rowcount int
rowBGcolor int rowBGcolor int
// new attempt // new attempt
@ -48,7 +48,7 @@ func initValues(mh *modelHandler) {
mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString("")) mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString(""))
mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableColor{}) mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableColor{})
for i := 0; i < mh.rows; i++ { for i := 0; i < mh.rowcount; i++ {
log.Println("i=",i) log.Println("i=",i)
// alternate background of each row light and dark // alternate background of each row light and dark
@ -86,17 +86,17 @@ func initValues(mh *modelHandler) {
// os.Exit(-1) // os.Exit(-1)
} }
func newModelHandler(rows int) *modelHandler { func newModelHandler(rowcount int) *modelHandler {
mh := new(modelHandler) mh := new(modelHandler)
mh.rows = rows mh.rowcount = rowcount
// These are the standard callback functions for libUI // These are the standard callback functions for libUI
mh.setCellValue = defaultSetCellValue mh.setCellValue = defaultSetCellValue
mh.rowBGcolor = 0 // this is the weird exception. Just always have this as 0 mh.rowBGcolor = 0 // this is the weird exception. Just always have this as 0
mh.cellValues = make([]cellTest, mh.rows) mh.cellValues = make([]cellTest, mh.rowcount)
initValues(mh) initValues(mh)
@ -105,8 +105,8 @@ func newModelHandler(rows int) *modelHandler {
return mh return mh
} }
func makeTable(name string, rows int, row1Name string) (*ui.Table, *modelHandler, *ui.TableModel) { func makeTable(name string, rowcount int, row1Name string) (*ui.Table, *modelHandler, *ui.TableModel) {
mh := newModelHandler(rows) mh := newModelHandler(rowcount)
mh.name = name mh.name = name
model := ui.NewTableModel(mh) model := ui.NewTableModel(mh)

View File

@ -1,28 +1,24 @@
package main package main
//
// 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 "os" import "os"
import "log" import "log"
import "github.com/andlabs/ui" import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest" import _ "github.com/andlabs/ui/winmanifest"
// import "github.com/davecgh/go-spew/spew"
func (mh *modelHandler) NumRows(m *ui.TableModel) int { func (mh *modelHandler) NumRows(m *ui.TableModel) int {
// log.Println("NumRows() with m=", m) return mh.rowcount
return mh.rows
} }
// FYI: this routine seems to be called around 10 to 100 times a second for each table // FYI: this routine seems to be called around 10 to 100 times a second for each table
func (mh *modelHandler) ColumnTypes(m *ui.TableModel) []ui.TableValue { func (mh *modelHandler) ColumnTypes(m *ui.TableModel) []ui.TableValue {
return mh.generatedColumnTypes return mh.generatedColumnTypes
/*
if (mh.funcColumnTypes == nil) {
log.Println("ColumnTypes NOT DEFINED. This table wasn't setup correctly! mh.funcColmnTypes == nil")
os.Exit(-1)
}
return mh.funcColumnTypes()
*/
} }
// TODO: Figure out why this is being called 1000 times a second (10 times for each row & column) // TODO: Figure out why this is being called 1000 times a second (10 times for each row & column)