x-backend #2

Merged
sashakoshka merged 34 commits from x-backend into main 2022-11-14 21:40:25 -07:00
Showing only changes of commit 38f7185be2 - Show all commits

View File

@ -142,6 +142,9 @@ func (backend *Backend) handleXEvent (event xgb.Event) {
// resize and rebind canvas
backend.reallocateCanvas()
// notify application of resize
backend.channel <- stone.EventResize { }
}
}
}
@ -201,28 +204,50 @@ func (backend *Backend) reallocateCanvas () {
return backend.colors[stone.ColorApplication]
})
backend.drawRune(0, 0, 'T')
backend.drawRune(1, 0, 'h')
backend.drawRune(2, 0, 'e')
backend.drawRune(4, 0, 'q')
backend.drawRune(5, 0, 'u')
backend.drawRune(6, 0, 'i')
backend.drawRune(7, 0, 'c')
backend.drawRune(8, 0, 'k')
backend.drawRune(0, 1, 'b')
backend.drawRune(1, 1, 'r')
backend.drawRune(2, 1, 'o')
backend.drawRune(3, 1, 'w')
backend.drawRune(4, 1, 'n')
backend.drawRune(6, 1, 'f')
backend.drawRune(7, 1, 'o')
backend.drawRune(8, 1, 'x')
// backend.drawRune(0, 0, 'T')
// backend.drawRune(1, 0, 'h')
// backend.drawRune(2, 0, 'e')
// backend.drawRune(4, 0, 'q')
// backend.drawRune(5, 0, 'u')
// backend.drawRune(6, 0, 'i')
// backend.drawRune(7, 0, 'c')
// backend.drawRune(8, 0, 'k')
// backend.drawRune(0, 1, 'b')
// backend.drawRune(1, 1, 'r')
// backend.drawRune(2, 1, 'o')
// backend.drawRune(3, 1, 'w')
// backend.drawRune(4, 1, 'n')
// backend.drawRune(6, 1, 'f')
// backend.drawRune(7, 1, 'o')
// backend.drawRune(8, 1, 'x')
backend.drawCells(true)
backend.canvas.XSurfaceSet(backend.window.Id)
backend.canvas.XDraw()
backend.canvas.XPaint(backend.window.Id)
}
func (backend *Backend) drawCells (forceRedraw bool) (areas []image.Rectangle) {
width, height := backend.application.Size()
for y := 0; y < height; y ++ {
for x := 0; x < width; x ++ {
if !forceRedraw && backend.application.Clean(x, y) { continue }
backend.application.MarkClean(x, y)
cell := backend.application.Cell(x, y)
content := cell.Rune()
if content < 32 { continue }
backend.drawRune(x, y, content)
}}
return
}
func (backend *Backend) updateWindowAreas (areas ...image.Rectangle) {
backend.canvas.XPaintRects(backend.window.Id, areas...)
}
func (backend *Backend) drawRune (x, y int, character rune) {
// TODO: cache these draws as non-transparent buffers with the
// application background color as the background. that way, we won't