diff --git a/main.go b/main.go index aa1de2f..510a557 100644 --- a/main.go +++ b/main.go @@ -75,12 +75,6 @@ func main() { log.Println("Sleep for 2 seconds, then try to add new tabs") time.Sleep(2 * 1000 * 1000 * 1000) - log.Println("Sleep for 2 seconds, then try to add new tabs") - time.Sleep(2 * 1000 * 1000 * 1000) - - log.Println("Sleep for 2 seconds, then try to add new tabs") - time.Sleep(2 * 1000 * 1000 * 1000) - for account, _ := range config.StringMap("cloud") { port := config.String("cloud." + account + ".port") proto := config.String("cloud." + account + ".proto") diff --git a/table.go b/table.go index a674567..c602883 100644 --- a/table.go +++ b/table.go @@ -18,11 +18,18 @@ type vmRowData struct { disk int } +var img [2]*ui.Image + type jwcTest struct { part0 ui.TableColor // row background color part1 ui.TableString // column 0 text part2 ui.TableColor // column 0 text color part3 ui.TableString // column 1 button text + part4 ui.TableString // column 2 text + part5 ui.TableColor // column 2 text color + part6 ui.TableString // column 3 text + part7 ui.TableImage // column 3 Image + part8 ui.TableColor // column 3 text color } type modelHandler struct { @@ -43,14 +50,46 @@ type modelHandler struct { } func initValues(mh *modelHandler) { + img[0] = ui.NewImage(16, 16) + img[1] = ui.NewImage(16, 16) + for i := 0; i < mh.rows; i++ { log.Println("i=",i) mh.vms[i].hostname = fmt.Sprintf("jcarrnew %d", i) - mh.cellValues[i].part0 = ui.TableColor{0.1, 0.5, 0.5, .3} + // alternate background of each row light and dark + if (i % 2) == 1 { + mh.cellValues[i].part0 = ui.TableColor{0.5, 0.5, 0.5, .7} + } else { + mh.cellValues[i].part0 = ui.TableColor{0.1, 0.1, 0.1, .1} + } + + // text for Column 0 mh.cellValues[i].part1 = ui.TableString(fmt.Sprintf("fun %d", i)) - mh.cellValues[i].part2 = ui.TableColor{0.5, 0.1, 0.1, .7} + + // text color for Column 0 + mh.cellValues[i].part2 = ui.TableColor{0.9, 0, 0, 1} + + // set the button text for Column 1 mh.cellValues[i].part3 = ui.TableString(fmt.Sprintf("awesome %d", i)) + + + // text for Column 2 + mh.cellValues[i].part4 = ui.TableString(fmt.Sprintf("color %d", i)) + + // text color for Column 2 + mh.cellValues[i].part5 = ui.TableColor{0.9, 0, 0, 1} + + + // text for Column 3 + mh.cellValues[i].part6 = ui.TableString(fmt.Sprintf("imgcolor %d", i)) + + // image for Column 3 + mh.cellValues[i].part7 = ui.TableImage{img[0]} + + // text color for Column 3 + mh.cellValues[i].part8 = ui.TableColor{0.9, 0, 0, 1} + } // os.Exit(-1) } @@ -88,6 +127,13 @@ func standardColumnTypes() []ui.TableValue { ui.TableString(""), // column 0 text ui.TableColor{}, // column 0 text color ui.TableString("test"), // column 1 button text + ui.TableString(""), // column 2 text + ui.TableColor{}, // column 2 text color +/* + ui.TableString(""), // column 3 text + ui.TableImage{}, // column 3 image + ui.TableColor{}, // column 3 text color +*/ } } @@ -105,6 +151,20 @@ func makeTable(name string, rows int, row1Name string) (*ui.Table, *modelHandler table.AppendTextColumn(row1Name, 1, ui.TableModelColumnAlwaysEditable, nil) table.AppendButtonColumn("Details", 3, ui.TableModelColumnAlwaysEditable) + // text color doesn't work like this? + table.AppendTextColumn("testcolor", 4, ui.TableModelColumnAlwaysEditable, + &ui.TableTextColumnOptionalParams{ + ColorModelColumn: 5, + }); + +/* + table.AppendImageTextColumn("testimagecolor", 6, 7, ui.TableModelColumnNeverEditable, + &ui.TableTextColumnOptionalParams{ + ColorModelColumn: 8, + }); +*/ + + return table, mh, model } @@ -118,6 +178,16 @@ func defaultCellValue(mh *modelHandler, row, column int) ui.TableValue { return mh.cellValues[row].part2 case 3: return mh.cellValues[row].part3 + case 4: + return mh.cellValues[row].part4 + case 5: + return mh.cellValues[row].part5 + case 6: + return mh.cellValues[row].part6 + case 7: + return ui.TableImage{img[1]} + case 8: + return mh.cellValues[row].part8 } return ui.TableString(fmt.Sprintf("jcarrbad %d", row)) }