From 1a9c08a3fd44b8032ad1aa0b2e8fa1315e54d5cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Thu, 11 Jan 2018 01:52:53 +0100 Subject: [PATCH] MiRCARTCanvasInterface.py:_updateCanvasSize(): reimplement (fixes [WASD] bugs.) --- MiRCARTCanvasInterface.py | 40 ++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/MiRCARTCanvasInterface.py b/MiRCARTCanvasInterface.py index 8818170..7cc2d4a 100644 --- a/MiRCARTCanvasInterface.py +++ b/MiRCARTCanvasInterface.py @@ -48,17 +48,39 @@ class MiRCARTCanvasInterface(): # {{{ _updateCanvasSize(self, newCanvasSize): XXX def _updateCanvasSize(self, newCanvasSize): eventDc = self.parentCanvas.canvasBackend.getDeviceContext(self.parentCanvas) + oldCanvasSize = self.parentCanvas.canvasSize self.parentCanvas.resize(newCanvasSize) - self.parentCanvas.canvasBackend.resize( \ - newCanvasSize, \ + self.parentCanvas.canvasBackend.resize( \ + newCanvasSize, \ self.parentCanvas.canvasBackend.cellSize) - for numRow in range(self.parentCanvas.canvasSize[1] - 1): - self.parentCanvas.canvasMap.append([[1, 1], 0, " "]) - self.parentCanvas.canvasMap.append([]) - for numCol in range(self.parentCanvas.canvasSize[0]): - self.parentCanvas.canvasMap[-1].append([[1, 1], 0, " "]) - self.parentCanvas.canvasBackend.drawPatch(eventDc, \ - ([numCol, self.parentCanvas.canvasSize[1] - 1], *[[1, 1], 0, " "])) + if (newCanvasSize[1] - oldCanvasSize[1]) < 0: + for numRowOff in range(1, (oldCanvasSize[1] - newCanvasSize[1]) + 1): + numRow = oldCanvasSize[1] - numRowOff + del self.parentCanvas.canvasMap[numRow] + else: + for numRowOff in range(oldCanvasSize[1] - newCanvasSize[1]): + numRow = oldCanvasSize[1] + numRowOff + self.parentCanvas.canvasMap.append(None) + self.parentCanvas.canvasMap[numRow] = \ + [[[1, 1], 0, " "]] * oldCanvasSize[0] + self.parentCanvas.canvasBackend.drawPatch( \ + eventDc, \ + [[numCol, numRow], *[[1, 1], 0, " "]]) + if (newCanvasSize[0] - oldCanvasSize[0]) < 0: + for numRow in range(newCanvasSize[1]): + for numColOff in range(1, (oldCanvasSize[0] - newCanvasSize[0]) + 1): + numCol = oldCanvasSize[0] - numColOff + del self.parentCanvas.canvasMap[numRow][numCol] + else: + for numRow in range(newCanvasSize[1]): + for numColOff in range(newCanvasSize[0] - oldCanvasSize[0]): + numCol = oldCanvasSize[0] + numColOff + self.parentCanvas.canvasMap[numRow].append(None) + self.parentCanvas.canvasMap[numRow][numCol] = \ + [[1, 1], 0, " "] + self.parentCanvas.canvasBackend.drawPatch( \ + eventDc, \ + [[numCol, numRow], *[[1, 1], 0, " "]]) wx.SafeYield() # }}}