summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2019-05-12 12:54:11 -0700
committerJeff Carr <[email protected]>2019-05-12 12:54:11 -0700
commitcf17208da09867602b7b5e565c6e0d4d45e4e8dc (patch)
tree8828e8e75b70c9430ee355410664a2747e189b62
parentdbe88483da913513c76cc88a59215823965bc3e9 (diff)
save the old way as a 'sample tab' generate option
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--gui.go55
1 files changed, 54 insertions, 1 deletions
diff --git a/gui.go b/gui.go
index 8d5b462..e57e3e1 100644
--- a/gui.go
+++ b/gui.go
@@ -304,7 +304,7 @@ type InputData struct {
Color string
}
-func AddTableTab(mytab *ui.Tab, mytabcount int, name string, rowcount int, parts []InputData) {
+func AddSampleTableTab(mytab *ui.Tab, mytabcount int, name string, rowcount int, parts []InputData) {
mh := new(tableData)
mh.rowcount = rowcount
@@ -357,6 +357,59 @@ func AddTableTab(mytab *ui.Tab, mytabcount int, name string, rowcount int, parts
mytab.SetMargined(mytabcount, true)
}
+func AddTableTab(mytab *ui.Tab, mytabcount int, name string, rowcount int, parts []InputData) {
+ mh := new(tableData)
+
+ mh.rowcount = rowcount
+ mh.rows = make([]rowData, mh.rowcount)
+
+ // This is the standard callback function from libUI when the user does something
+ mh.libUIevent = defaultSetCellValue
+
+ tmpBTindex := 0
+
+ for key, foo := range parts {
+ log.Println(key, foo)
+ initColumnNames(mh, foo.CellType, foo.Heading)
+ }
+
+ // time.Sleep(1 * 1000 * 1000 * 1000)
+
+ for row := 0; row < mh.rowcount; row++ {
+ initRow(mh, row, parts)
+ }
+ log.Println(mh)
+
+ model := ui.NewTableModel(mh)
+ table := ui.NewTable(
+ &ui.TableParams{
+ Model: model,
+ RowBackgroundColorModelColumn: tmpBTindex,
+ })
+
+ 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
+ table.AppendButtonColumn(foo.Heading, tmpBTindex, ui.TableModelColumnAlwaysEditable)
+ } else if (foo.CellType == "TEXTCOLOR") {
+ tmpBTindex += 1
+ appendTextColorColumn (mh, table, tmpBTindex, tmpBTindex + 1, foo.Heading)
+ tmpBTindex += 1
+ } else if (foo.CellType == "TEXT") {
+ tmpBTindex += 1
+ appendTextColumn (mh, table, tmpBTindex, foo.Heading)
+ } else {
+ panic("I don't know what this is in initColumnNames")
+ }
+ }
+
+ mytab.Append(name, table)
+ mytab.SetMargined(mytabcount, true)
+}
+
func DoGUI() {
ui.Main(setupUI)