libgui/GuiCanvasWxBackend.py:GuiBufferedDC.__init__(): directly select buffer into DC.

libroar/RoarCanvasWindow.py:applyTool(): normalise mapPoint w/ viewRect if mapPoint != None.
This commit is contained in:
Lucio Andrés Illanes Albornoz 2019-09-13 21:09:51 +02:00
parent 2fa06043c6
commit 74e2bf7f49
2 changed files with 4 additions and 5 deletions

View File

@ -22,11 +22,8 @@ class GuiBufferedDC(wx.MemoryDC):
viewRect = [m * n for m, n in zip(backend.cellSize, viewRect)] viewRect = [m * n for m, n in zip(backend.cellSize, viewRect)]
viewSize = [min(m, n) for m, n in zip(canvasSize, clientSize)] viewSize = [min(m, n) for m, n in zip(canvasSize, clientSize)]
viewSize = [m * n for m, n in zip(backend.cellSize, viewSize)] viewSize = [m * n for m, n in zip(backend.cellSize, viewSize)]
bitmap = wx.Bitmap(viewSize); self.SelectObject(bitmap); self.SelectObject(buffer); self.SetDeviceOrigin(*viewRect);
bufferDc = wx.MemoryDC(); bufferDc.SelectObject(buffer); self.dc, self.viewRect, self.viewSize = dc, viewRect, viewSize
self.Blit(0, 0, *viewSize, bufferDc, *viewRect)
bufferDc.SelectObject(wx.NullBitmap)
self.dc, self.viewSize = dc, viewSize
# }}} # }}}
class GuiCanvasWxBackend(): class GuiCanvasWxBackend():

View File

@ -47,6 +47,8 @@ class RoarCanvasWindow(GuiWindow):
# {{{ applyTool(self, eventDc, eventMouse, keyChar, keyModifiers, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown, tool, viewRect) # {{{ applyTool(self, eventDc, eventMouse, keyChar, keyModifiers, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown, tool, viewRect)
def applyTool(self, eventDc, eventMouse, keyChar, keyModifiers, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown, tool, viewRect): def applyTool(self, eventDc, eventMouse, keyChar, keyModifiers, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown, tool, viewRect):
if mapPoint != None:
mapPoint = [a + b for a, b in zip(mapPoint, viewRect)]
dirty, self.canvas.dirtyCursor, rc = False, False, False dirty, self.canvas.dirtyCursor, rc = False, False, False
self.canvas.journal.begin() self.canvas.journal.begin()
if eventMouse: if eventMouse: