From 25c9e884846d2db487e9ebeda5b91e732b847a59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Sat, 14 Sep 2019 15:44:17 +0200 Subject: [PATCH] libgui/GuiCanvasWxBackend.py:resize(): set font size from cellSize[0] + 1 vs. hard-wired 8. libroar/RoarCanvasWindow.py:{onMouseWheel,__init__}(): {de,in}crease cell size w/ . assets/text/TODO: updated. --- assets/text/TODO | 3 +-- libgui/GuiCanvasWxBackend.py | 4 ++-- libroar/RoarCanvasWindow.py | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/assets/text/TODO b/assets/text/TODO index 35b37b0..e481c00 100644 --- a/assets/text/TODO +++ b/assets/text/TODO @@ -13,7 +13,6 @@ High-priority list: 1) geometric primitives: arrow, circle, cloud/speech bubble, curve, heart, hexagon, line, pentagon, polygon, rhombus, triangle, square, star 2) region filters: crop, duplicate, erase, fill, invert, measure, pick, rotate, scale, select, shift, slice, tile, translate 3) text tool: a) allow navigating w/ cursor keys b) Unicode set key & GUI w/ MRU -4) GUI: {de,in}crease cell size on -5) cleanup & refactor +4) cleanup & refactor vim:ff=dos tw=0 diff --git a/libgui/GuiCanvasWxBackend.py b/libgui/GuiCanvasWxBackend.py index 658c753..204a8fc 100644 --- a/libgui/GuiCanvasWxBackend.py +++ b/libgui/GuiCanvasWxBackend.py @@ -153,9 +153,9 @@ class GuiCanvasWxBackend(): self.canvasBitmap.Destroy(); self.canvasBitmap = newBitmap; self.canvasSize, self.cellSize = canvasSize, cellSize if platform.system() == "Windows": - self._font = wx.TheFontList.FindOrCreateFont(8, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, self.fontName) + self._font = wx.TheFontList.FindOrCreateFont(cellSize[0] + 1, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, self.fontName) else: - self._font = wx.Font(8, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) + self._font = wx.Font(cellSize[0] + 1, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) # }}} # {{{ xlateEventPoint(self, event, eventDc, viewRect) def xlateEventPoint(self, event, eventDc, viewRect): diff --git a/libroar/RoarCanvasWindow.py b/libroar/RoarCanvasWindow.py index 8b0baed..f0eaea8 100644 --- a/libroar/RoarCanvasWindow.py +++ b/libroar/RoarCanvasWindow.py @@ -150,6 +150,22 @@ class RoarCanvasWindow(GuiWindow): if not self.applyTool(eventDc, True, None, None, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown, self.commands.currentTool, viewRect): event.Skip() # }}} + # {{{ onMouseWheel(self, event) + def onMouseWheel(self, event): + if event.GetModifiers() == wx.MOD_CONTROL: + cd = +1 if event.GetWheelRotation() >= event.GetWheelDelta() else -1 + newCellSize = [cs + cd for cs in self.backend.cellSize] + if (newCellSize[0] > 0) and (newCellSize[1] > 0): + self.backend.cellSize = newCellSize + super().resize([a * b for a, b in zip(self.canvas.size, self.backend.cellSize)]) + self.backend.resize(self.canvas.size, self.backend.cellSize) + viewRect = self.GetViewStart(); eventDc = self.backend.getDeviceContext(self.GetClientSize(), self, viewRect); + for numRow in range(self.canvas.size[1]): + for numCol in range(len(self.canvas.map[numRow])): + self._drawPatch(eventDc, False, [numCol, numRow, *self.canvas.map[numRow][numCol]], viewRect) + else: + event.Skip() + # }}} # {{{ onPaint(self, event) def onPaint(self, event): self.backend.onPaint(self.GetClientSize(), self, self.GetViewStart()) @@ -170,5 +186,6 @@ class RoarCanvasWindow(GuiWindow): self.brushColours, self.brushPos, self.brushSize, self.dirty, self.lastCellState = [4, 1], [0, 0], [1, 1], False, None self.dropTarget = RoarCanvasWindowDropTarget(self) self.SetDropTarget(self.dropTarget) + self.Bind(wx.EVT_MOUSEWHEEL, self.onMouseWheel) # vim:expandtab foldmethod=marker sw=4 ts=4 tw=120