Tweaked background colour rendering on seperators when using row fill

This commit is contained in:
Ryan Lewis 2019-02-01 18:24:46 +00:00
parent 83319fb800
commit 3eaafc7706
2 changed files with 8 additions and 5 deletions

View File

@ -56,7 +56,7 @@ func main() {
table3.SetRect(0, 30, 70, 20) table3.SetRect(0, 30, 70, 20)
table3.FillRow = true table3.FillRow = true
table3.RowStyles[0] = ui.NewStyle(ui.ColorWhite, ui.ColorBlack, ui.ModifierBold) table3.RowStyles[0] = ui.NewStyle(ui.ColorWhite, ui.ColorBlack, ui.ModifierBold)
table3.RowStyles[2] = ui.NewStyle(ui.ColorRed) table3.RowStyles[2] = ui.NewStyle(ui.ColorWhite, ui.ColorRed, ui.ModifierBold)
table3.RowStyles[3] = ui.NewStyle(ui.ColorYellow) table3.RowStyles[3] = ui.NewStyle(ui.ColorYellow)
ui.Render(table3) ui.Render(table3)

View File

@ -100,13 +100,16 @@ func (self *Table) Draw(buf *Buffer) {
// draw vertical separators // draw vertical separators
separatorStyle := self.Block.BorderStyle separatorStyle := self.Block.BorderStyle
if self.FillRow {
separatorStyle.Bg = rowStyle.Bg
}
separatorXCoordinate := self.Inner.Min.X separatorXCoordinate := self.Inner.Min.X
verticalCell := NewCell(VERTICAL_LINE, separatorStyle) verticalCell := NewCell(VERTICAL_LINE, separatorStyle)
for _, width := range columnWidths { for i, width := range columnWidths {
if self.FillRow && i < len(columnWidths)-1 {
verticalCell.Style.Bg = rowStyle.Bg
} else {
verticalCell.Style.Bg = self.Block.BorderStyle.Bg
}
separatorXCoordinate += width separatorXCoordinate += width
buf.SetCell(verticalCell, image.Pt(separatorXCoordinate, yCoordinate)) buf.SetCell(verticalCell, image.Pt(separatorXCoordinate, yCoordinate))
separatorXCoordinate++ separatorXCoordinate++