summaryrefslogtreecommitdiff
path: root/gui.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2019-05-13 00:46:11 -0700
committerJeff Carr <[email protected]>2019-05-13 00:46:11 -0700
commit2ea414bb14a8d9de8fb44a5bec8a8852ba1a3c98 (patch)
treef56830f832ec78cd7d3a36c68f34bed59261f433 /gui.go
parent5ec1416d20f874fe0ef01b9f33ba86dbe5960435 (diff)
make a common column init()
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'gui.go')
-rw-r--r--gui.go44
1 files changed, 17 insertions, 27 deletions
diff --git a/gui.go b/gui.go
index c9ea6f7..40243bb 100644
--- a/gui.go
+++ b/gui.go
@@ -43,27 +43,7 @@ func AddNewTab(mytab *ui.Tab, newbox ui.Control, tabOffset int) {
mytab.SetMargined(tabOffset, true)
}
-func initColumnNames(mh *TableData, cellJWC string, junk string) {
- if (cellJWC == "BG") {
- mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableColor{})
- } else if (cellJWC == "BUTTON") {
- mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString(""))
- } else if (cellJWC == "TEXTCOLOR") {
- mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString(""))
- mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableColor{})
- } else if (cellJWC == "TEXT") {
- mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString(""))
- } else {
- panic("I don't know what this is in initColumnNames")
- }
-}
-
-func AddTableTab(mytab *ui.Tab, mytabcount int, name string, rowcount int, parts []InputData) *TableData {
- mh := new(TableData)
-
- mh.RowCount = rowcount
- mh.Rows = make([]RowData, mh.RowCount)
-
+func InitColumns(mh *TableData, parts []InputData) {
tmpBTindex := 0
humanID := 0
for key, foo := range parts {
@@ -71,40 +51,50 @@ func AddTableTab(mytab *ui.Tab, mytabcount int, name string, rowcount int, parts
// log.Println("mh.Cells =", mh.Cells)
// log.Println("mh.Human =", mh.Human)
- initColumnNames(mh, foo.CellType, foo.Heading)
-
parts[key].Index = humanID
humanID += 1
if (foo.CellType == "BG") {
+ mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableColor{})
initRowBTcolor (mh, tmpBTindex, parts[key])
tmpBTindex += 1
} else if (foo.CellType == "BUTTON") {
+ mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString(""))
initRowButtonColumn (mh, tmpBTindex, parts[key].Heading, parts[key])
tmpBTindex += 1
} else if (foo.CellType == "TEXTCOLOR") {
+ mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString(""))
+ mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableColor{})
initRowTextColorColumn(mh, tmpBTindex, tmpBTindex + 1, parts[key].Heading, ui.TableColor{0.0, 0, 0.9, 1}, parts[key])
tmpBTindex += 2
} else if (foo.CellType == "TEXT") {
+ mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString(""))
initRowTextColumn (mh, tmpBTindex, parts[key].Heading, parts[key])
tmpBTindex += 1
} else {
panic("I don't know what this is in initColumnNames")
}
}
- tmpBTindex = 0
- humanID = 0
+}
+
+func AddTableTab(mytab *ui.Tab, mytabcount int, name string, rowcount int, parts []InputData) *TableData {
+ mh := new(TableData)
+
+ mh.RowCount = rowcount
+ mh.Rows = make([]RowData, mh.RowCount)
+
+ InitColumns(mh, parts)
model := ui.NewTableModel(mh)
table := ui.NewTable(
&ui.TableParams{
Model: model,
- RowBackgroundColorModelColumn: tmpBTindex,
+ RowBackgroundColorModelColumn: 0, // Row Background color is always index zero
})
+ tmpBTindex := 0
for key, foo := range parts {
log.Println(key, foo)
- initColumnNames(mh, foo.CellType, foo.Heading)
if (foo.CellType == "BG") {
} else if (foo.CellType == "BUTTON") {
tmpBTindex += 1