From 1616c615bfe6657329b337a6d8dd25b4e92fecf3 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sat, 8 Apr 2023 14:41:29 -0400 Subject: [PATCH] Grid draws in the empty areas around the cells --- elements/grid.go | 13 +++++++++++++ elements/terminal.go | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/elements/grid.go b/elements/grid.go index 44ddd0f..8b9d302 100644 --- a/elements/grid.go +++ b/elements/grid.go @@ -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 } diff --git a/elements/terminal.go b/elements/terminal.go index b1377dd..b8b4b61 100644 --- a/elements/terminal.go +++ b/elements/terminal.go @@ -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, + }) }