Overhauled event system

This commit is contained in:
2022-11-16 00:29:23 -05:00
parent 3a3fb66db8
commit e030f8632b
9 changed files with 216 additions and 153 deletions
+7 -24
View File
@@ -14,17 +14,17 @@ import "github.com/jezek/xgbutil/xgraphics"
import "git.tebibyte.media/sashakoshka/stone"
type Backend struct {
application *stone.Application
config *stone.Config
connection *xgbutil.XUtil
window *xwindow.Window
canvas *xgraphics.Image
channel chan(stone.Event)
application *stone.Application
config *stone.Config
callbackManager *stone.CallbackManager
connection *xgbutil.XUtil
window *xwindow.Window
canvas *xgraphics.Image
drawCellBounds bool
drawBufferBounds bool
drawLock sync.Mutex
lock sync.Mutex
font struct {
face font.Face
@@ -114,23 +114,6 @@ func (backend *Backend) calculateBufferSize () (width, height int) {
return
}
func (backend *Backend) reallocateCanvas () {
if backend.canvas != nil {
backend.canvas.Destroy()
}
backend.canvas = xgraphics.New (
backend.connection,
image.Rect (
0, 0,
backend.metrics.windowWidth,
backend.metrics.windowHeight))
backend.canvas.For (func (x, y int) xgraphics.BGRA {
return backend.colors[stone.ColorBackground]
})
backend.canvas.XSurfaceSet(backend.window.Id)
}
func (backend *Backend) cellAt (onScreen image.Point) (x, y int) {
x = (onScreen.X - backend.metrics.paddingX) / backend.metrics.cellWidth
y = (onScreen.Y - backend.metrics.paddingY) / backend.metrics.cellHeight