diff options
| author | Jeff Carr <[email protected]> | 2019-05-12 23:56:53 -0700 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2019-05-12 23:56:53 -0700 |
| commit | ea6d22fc4692e49e1657b9b27f03a5d20fafe56f (patch) | |
| tree | 5e447c872310d6829e583ff7e8acb0e96b96d9f3 | |
| parent | f4f430561d5cd572ae766cf5a222aae28d817a1d (diff) | |
only have one copy of the libUI -> human index mapping
Signed-off-by: Jeff Carr <[email protected]>
| -rw-r--r-- | table.go | 34 | ||||
| -rw-r--r-- | tableCallbacks.go | 12 |
2 files changed, 26 insertions, 20 deletions
@@ -23,8 +23,7 @@ type RowData struct { 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 - Human [20]HumanCellData + HumanData [20]HumanCellData } // hmm. will this stand the test of time? @@ -36,6 +35,12 @@ type HumanCellData struct { ColorID int } +type HumanMap struct { + Name string // what kind of row is this? + TextID int + ColorID int +} + type TableData struct { RowCount int // This is the number of 'rows' which really means data elements not what the human sees RowWidth int // This is how wide each row is @@ -45,15 +50,16 @@ type TableData struct { cellChangeEvent func(int, int, ui.TableValue) Cells [20]CellData + Human [20]HumanMap } func initRowBTcolor(mh *TableData, row int, intBG int, cell InputData) { humanInt := cell.Index // setup mapping from human readable indexes to internal libUI indexes - mh.Rows[row].Human[humanInt].Name = "BG" - mh.Rows[row].Human[humanInt].ColorID = intBG - mh.Rows[row].Human[humanInt].TextID = -1 + mh.Human[humanInt].Name = "BG" + mh.Human[humanInt].ColorID = intBG + mh.Human[humanInt].TextID = -1 mh.Cells[intBG].Name = "BG" mh.Cells[intBG].HumanID = humanInt @@ -65,9 +71,9 @@ func initRowButtonColumn(mh *TableData, row int, buttonID int, junk string, cell humanInt := cell.Index // setup mapping from human readable indexes to internal libUI indexes - mh.Rows[row].Human[humanInt].Name = "BUTTON" - mh.Rows[row].Human[humanInt].ColorID = -1 - mh.Rows[row].Human[humanInt].TextID = buttonID + mh.Human[humanInt].Name = "BUTTON" + mh.Human[humanInt].ColorID = -1 + mh.Human[humanInt].TextID = buttonID mh.Cells[buttonID].Name = "BUTTON" mh.Cells[buttonID].HumanID = humanInt @@ -79,9 +85,9 @@ func initRowTextColorColumn(mh *TableData, row int, stringID int, colorID int, j humanInt := cell.Index // setup mapping from human readable indexes to internal libUI indexes - mh.Rows[row].Human[humanInt].Name = "EDIT" - mh.Rows[row].Human[humanInt].ColorID = colorID - mh.Rows[row].Human[humanInt].TextID = stringID + mh.Human[humanInt].Name = "EDIT" + mh.Human[humanInt].ColorID = colorID + mh.Human[humanInt].TextID = stringID // text for Column humanInt mh.Cells[stringID].Name = "EDIT" @@ -95,9 +101,9 @@ func initRowTextColumn(mh *TableData, row int, stringID int, junk string, cell I humanInt := cell.Index // setup mapping from human readable indexes to internal libUI indexes - mh.Rows[row].Human[humanInt].Name = "EDIT" - mh.Rows[row].Human[humanInt].ColorID = -1 - mh.Rows[row].Human[humanInt].TextID = stringID + mh.Human[humanInt].Name = "EDIT" + mh.Human[humanInt].ColorID = -1 + mh.Human[humanInt].TextID = stringID mh.Cells[stringID].Name = "EDIT" mh.Cells[stringID].HumanID = humanInt diff --git a/tableCallbacks.go b/tableCallbacks.go index cda183a..b36fc4c 100644 --- a/tableCallbacks.go +++ b/tableCallbacks.go @@ -24,11 +24,11 @@ func (mh *TableData) ColumnTypes(m *ui.TableModel) []ui.TableValue { // Nevermind this TODO. Who gives a shit. This is a really smart way to treat the OS toolkits func (mh *TableData) CellValue(m *ui.TableModel, row, column int) ui.TableValue { humanID := mh.Cells[column].HumanID - if (column == mh.Rows[row].Human[humanID].TextID) { - return mh.Rows[row].Human[humanID].Text + if (column == mh.Human[humanID].TextID) { + return mh.Rows[row].HumanData[humanID].Text } - if (column == mh.Rows[row].Human[humanID].ColorID) { - return mh.Rows[row].Human[humanID].Color + if (column == mh.Human[humanID].ColorID) { + return mh.Rows[row].HumanData[humanID].Color } panic("not sure what sort of ui.TableValue to return in CellValue()") return ui.TableString("") @@ -47,8 +47,8 @@ func (mh *TableData) SetCellValue(m *ui.TableModel, row, column int, value ui.Ta // log.Println("mh.Rows[row].Cells[column].HumanID =", mh.Rows[row].Cells[column].HumanID) humanID := mh.Cells[column].HumanID - log.Println("mh.Rows[row].Human[humanID].ColorID =", mh.Rows[row].Human[humanID].ColorID) - log.Println("mh.Rows[row].Human[humanID].TextID =", mh.Rows[row].Human[humanID].TextID) + log.Println("mh.Human[humanID].ColorID =", mh.Human[humanID].ColorID) + log.Println("mh.Human[humanID].TextID =", mh.Human[humanID].TextID) log.Println("SetCellValue() END") } |
