only have one copy of the libUI -> human index mapping
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
f4f430561d
commit
ea6d22fc46
34
table.go
34
table.go
|
@ -23,8 +23,7 @@ type RowData struct {
|
||||||
click func() // what function to call if the user clicks on it
|
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
|
doubleclick func() // what function to call if the user double clicks on it
|
||||||
*/
|
*/
|
||||||
// Cells [20]CellData
|
HumanData [20]HumanCellData
|
||||||
Human [20]HumanCellData
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// hmm. will this stand the test of time?
|
// hmm. will this stand the test of time?
|
||||||
|
@ -36,6 +35,12 @@ type HumanCellData struct {
|
||||||
ColorID int
|
ColorID int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type HumanMap struct {
|
||||||
|
Name string // what kind of row is this?
|
||||||
|
TextID int
|
||||||
|
ColorID int
|
||||||
|
}
|
||||||
|
|
||||||
type TableData struct {
|
type TableData struct {
|
||||||
RowCount int // This is the number of 'rows' which really means data elements not what the human sees
|
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
|
RowWidth int // This is how wide each row is
|
||||||
|
@ -45,15 +50,16 @@ type TableData struct {
|
||||||
cellChangeEvent func(int, int, ui.TableValue)
|
cellChangeEvent func(int, int, ui.TableValue)
|
||||||
|
|
||||||
Cells [20]CellData
|
Cells [20]CellData
|
||||||
|
Human [20]HumanMap
|
||||||
}
|
}
|
||||||
|
|
||||||
func initRowBTcolor(mh *TableData, row int, intBG int, cell InputData) {
|
func initRowBTcolor(mh *TableData, row int, intBG int, cell InputData) {
|
||||||
humanInt := cell.Index
|
humanInt := cell.Index
|
||||||
|
|
||||||
// setup mapping from human readable indexes to internal libUI indexes
|
// setup mapping from human readable indexes to internal libUI indexes
|
||||||
mh.Rows[row].Human[humanInt].Name = "BG"
|
mh.Human[humanInt].Name = "BG"
|
||||||
mh.Rows[row].Human[humanInt].ColorID = intBG
|
mh.Human[humanInt].ColorID = intBG
|
||||||
mh.Rows[row].Human[humanInt].TextID = -1
|
mh.Human[humanInt].TextID = -1
|
||||||
|
|
||||||
mh.Cells[intBG].Name = "BG"
|
mh.Cells[intBG].Name = "BG"
|
||||||
mh.Cells[intBG].HumanID = humanInt
|
mh.Cells[intBG].HumanID = humanInt
|
||||||
|
@ -65,9 +71,9 @@ func initRowButtonColumn(mh *TableData, row int, buttonID int, junk string, cell
|
||||||
humanInt := cell.Index
|
humanInt := cell.Index
|
||||||
|
|
||||||
// setup mapping from human readable indexes to internal libUI indexes
|
// setup mapping from human readable indexes to internal libUI indexes
|
||||||
mh.Rows[row].Human[humanInt].Name = "BUTTON"
|
mh.Human[humanInt].Name = "BUTTON"
|
||||||
mh.Rows[row].Human[humanInt].ColorID = -1
|
mh.Human[humanInt].ColorID = -1
|
||||||
mh.Rows[row].Human[humanInt].TextID = buttonID
|
mh.Human[humanInt].TextID = buttonID
|
||||||
|
|
||||||
mh.Cells[buttonID].Name = "BUTTON"
|
mh.Cells[buttonID].Name = "BUTTON"
|
||||||
mh.Cells[buttonID].HumanID = humanInt
|
mh.Cells[buttonID].HumanID = humanInt
|
||||||
|
@ -79,9 +85,9 @@ func initRowTextColorColumn(mh *TableData, row int, stringID int, colorID int, j
|
||||||
humanInt := cell.Index
|
humanInt := cell.Index
|
||||||
|
|
||||||
// setup mapping from human readable indexes to internal libUI indexes
|
// setup mapping from human readable indexes to internal libUI indexes
|
||||||
mh.Rows[row].Human[humanInt].Name = "EDIT"
|
mh.Human[humanInt].Name = "EDIT"
|
||||||
mh.Rows[row].Human[humanInt].ColorID = colorID
|
mh.Human[humanInt].ColorID = colorID
|
||||||
mh.Rows[row].Human[humanInt].TextID = stringID
|
mh.Human[humanInt].TextID = stringID
|
||||||
|
|
||||||
// text for Column humanInt
|
// text for Column humanInt
|
||||||
mh.Cells[stringID].Name = "EDIT"
|
mh.Cells[stringID].Name = "EDIT"
|
||||||
|
@ -95,9 +101,9 @@ func initRowTextColumn(mh *TableData, row int, stringID int, junk string, cell I
|
||||||
humanInt := cell.Index
|
humanInt := cell.Index
|
||||||
|
|
||||||
// setup mapping from human readable indexes to internal libUI indexes
|
// setup mapping from human readable indexes to internal libUI indexes
|
||||||
mh.Rows[row].Human[humanInt].Name = "EDIT"
|
mh.Human[humanInt].Name = "EDIT"
|
||||||
mh.Rows[row].Human[humanInt].ColorID = -1
|
mh.Human[humanInt].ColorID = -1
|
||||||
mh.Rows[row].Human[humanInt].TextID = stringID
|
mh.Human[humanInt].TextID = stringID
|
||||||
|
|
||||||
mh.Cells[stringID].Name = "EDIT"
|
mh.Cells[stringID].Name = "EDIT"
|
||||||
mh.Cells[stringID].HumanID = humanInt
|
mh.Cells[stringID].HumanID = humanInt
|
||||||
|
|
|
@ -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
|
// 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 {
|
func (mh *TableData) CellValue(m *ui.TableModel, row, column int) ui.TableValue {
|
||||||
humanID := mh.Cells[column].HumanID
|
humanID := mh.Cells[column].HumanID
|
||||||
if (column == mh.Rows[row].Human[humanID].TextID) {
|
if (column == mh.Human[humanID].TextID) {
|
||||||
return mh.Rows[row].Human[humanID].Text
|
return mh.Rows[row].HumanData[humanID].Text
|
||||||
}
|
}
|
||||||
if (column == mh.Rows[row].Human[humanID].ColorID) {
|
if (column == mh.Human[humanID].ColorID) {
|
||||||
return mh.Rows[row].Human[humanID].Color
|
return mh.Rows[row].HumanData[humanID].Color
|
||||||
}
|
}
|
||||||
panic("not sure what sort of ui.TableValue to return in CellValue()")
|
panic("not sure what sort of ui.TableValue to return in CellValue()")
|
||||||
return ui.TableString("")
|
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)
|
// log.Println("mh.Rows[row].Cells[column].HumanID =", mh.Rows[row].Cells[column].HumanID)
|
||||||
|
|
||||||
humanID := mh.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.Human[humanID].ColorID =", mh.Human[humanID].ColorID)
|
||||||
log.Println("mh.Rows[row].Human[humanID].TextID =", mh.Rows[row].Human[humanID].TextID)
|
log.Println("mh.Human[humanID].TextID =", mh.Human[humanID].TextID)
|
||||||
|
|
||||||
log.Println("SetCellValue() END")
|
log.Println("SetCellValue() END")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue