x-backend #2

Merged
sashakoshka merged 34 commits from x-backend into main 2022-11-14 21:40:25 -07:00
3 changed files with 28 additions and 7 deletions
Showing only changes of commit 79d8891c5b - Show all commits

View File

@ -51,13 +51,15 @@ func (backend *Backend) drawRune (x, y int, character rune) {
Y: fixed.I(origin.Y - backend.metrics.descent), Y: fixed.I(origin.Y - backend.metrics.descent),
}, },
character) character)
// strokeRectangle ( if backend.drawCellBounds {
// &image.Uniform { strokeRectangle (
// C: backend.config.Color(stone.ColorForeground), &image.Uniform {
// }, C: backend.config.Color(stone.ColorForeground),
// backend.canvas, },
// backend.boundsOfCell(x, y)) backend.canvas,
backend.boundsOfCell(x, y))
}
draw.DrawMask ( draw.DrawMask (
backend.canvas, backend.canvas,
@ -86,6 +88,18 @@ func (backend *Backend) drawCells (forceRedraw bool) (areas []image.Rectangle) {
areas = append(areas, backend.boundsOfCell(x, y)) areas = append(areas, backend.boundsOfCell(x, y))
backend.drawRune(x, y, content) backend.drawRune(x, y, content)
}} }}
if backend.drawBufferBounds && forceRedraw {
strokeRectangle (
&image.Uniform {
C: backend.config.Color(stone.ColorForeground),
},
backend.canvas,
image.Rectangle {
Min: backend.originOfCell(0, 0),
Max: backend.originOfCell(width, height),
})
}
return return
} }

View File

@ -126,6 +126,10 @@ func factory (application *stone.Application) (output stone.Backend, err error)
Connect(backend.connection, backend.window.Id) Connect(backend.connection, backend.window.Id)
xevent.KeyReleaseFun(backend.handleKeyRelease). xevent.KeyReleaseFun(backend.handleKeyRelease).
Connect(backend.connection, backend.window.Id) Connect(backend.connection, backend.window.Id)
// uncomment these to draw debug bounds
// backend.drawCellBounds = true
// backend.drawBufferBounds = true
output = backend output = backend
return return

View File

@ -21,6 +21,9 @@ type Backend struct {
canvas *xgraphics.Image canvas *xgraphics.Image
channel chan(stone.Event) channel chan(stone.Event)
drawCellBounds bool
drawBufferBounds bool
drawLock sync.Mutex drawLock sync.Mutex
font struct { font struct {