Grid draws in the empty areas around the cells

This commit is contained in:
Sasha Koshka 2023-04-08 14:41:29 -04:00
parent ce7584ceee
commit 1616c615bf
2 changed files with 18 additions and 0 deletions

View File

@ -40,6 +40,7 @@ type Grid struct {
stride int
cellWidth int
cellHeight int
gridBounds image.Rectangle
cursor image.Point
@ -147,6 +148,11 @@ func (element *Grid) alloc () bool {
height := bounds.Dy() / element.cellHeight
oldWidth, oldHeight := element.Size()
if width == oldWidth && height == oldHeight { return false }
element.gridBounds = image.Rect (
0, 0,
width * element.cellWidth,
height * element.cellHeight).Add(bounds.Min)
oldCells := element.cells
heightLarger := height > oldHeight
@ -249,5 +255,12 @@ func (element *Grid) draw (force bool) image.Rectangle {
element.bound(index))
}}
if force {
shapes.FillColorRectangleShatter (
element.core,
element.theme.Color(tomo.ColorBackground, element.state()),
bounds, element.gridBounds)
}
return bounds // FIXME
}

View File

@ -27,4 +27,9 @@ func (element *Terminal) handleResize () {
Background: tomo.ColorRed,
Foreground: tomo.ColorBlack,
})
element.Set(image.Pt(15, 10), Cell {
Rune: 'Y',
Background: tomo.ColorBrightBlue,
Foreground: tomo.ColorBlack,
})
}