From 55dfbbb13f27203a082c9c835b6cbabc116d329b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Sun, 15 Sep 2019 21:33:19 +0200 Subject: [PATCH] Implements cursor tool & arrow keys navigation. assets/images/toolCursor.png: added. libroar/Roar{CanvasCommands{,Tools},Client}.py: adds cursor tool. libroar/RoarCanvasWindow.py:applyTool(): dummy-handle cursor tool. libroar/RoarCanvasWindow.py:onKeyboardInput(): update cursor position & cursor on {down,left,right,up} arrow key input. assets/text/TODO: updated. --- assets/images/toolCursor.png | Bin 0 -> 203 bytes assets/text/TODO | 18 ++++++++--------- libroar/RoarCanvasCommands.py | 2 +- libroar/RoarCanvasCommandsTools.py | 28 ++++++++++++++++---------- libroar/RoarCanvasWindow.py | 31 ++++++++++++++++++++++------- libroar/RoarClient.py | 2 +- 6 files changed, 51 insertions(+), 30 deletions(-) create mode 100755 assets/images/toolCursor.png diff --git a/assets/images/toolCursor.png b/assets/images/toolCursor.png new file mode 100755 index 0000000000000000000000000000000000000000..2e11893ab8df4c79212db4c10485c81fe19bfe4c GIT binary patch literal 203 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=DinK$vl=HlH+5kiEpy*OmP-C%>?;tmwbSlR%*ePZ!4!i_=Rd8wxQfaxnWI`(JOl zEquWQ?xl~oPBVCFbB47uh%m}<#7`II*xkZ+$aAJX$MQ{i0#?ea6=D+KWG+& 0): + self.brushPos = [self.brushPos[0] - 1, self.brushPos[1]] + elif (keyCode == wx.WXK_RIGHT) and (self.brushPos[0] < (self.canvas.size[0] - 1)): + self.brushPos = [self.brushPos[0] + 1, self.brushPos[1]] + elif (keyCode == wx.WXK_UP) and (self.brushPos[1] > 0): + self.brushPos = [self.brushPos[0], self.brushPos[1] - 1] + self.commands.update(cellPos=self.brushPos) + self.applyTool(eventDc, True, None, None, self.brushPos, False, False, False, self.commands.currentTool, viewRect) else: - viewRect = self.GetViewStart(); eventDc = self.backend.getDeviceContext(self.GetClientSize(), self, viewRect); - keyChar, keyModifiers = chr(event.GetUnicodeKey()), event.GetModifiers() - if not self.applyTool(eventDc, False, keyChar, keyModifiers, None, None, None, None, self.commands.currentTool, viewRect): + if not self.applyTool(eventDc, False, chr(event.GetUnicodeKey()), keyModifiers, None, None, None, None, self.commands.currentTool, viewRect): event.Skip() # }}} # {{{ onEnterWindow(self, event) diff --git a/libroar/RoarClient.py b/libroar/RoarClient.py index 728090d..84efa9d 100644 --- a/libroar/RoarClient.py +++ b/libroar/RoarClient.py @@ -49,7 +49,7 @@ class RoarClient(GuiFrame): self.loadToolBars(self.canvasPanel.commands.toolBars) self.canvasPanel.commands.canvasNew(None) - self.canvasPanel.commands.canvasTool(self.canvasPanel.commands.canvasTool, 4)(None) + self.canvasPanel.commands.canvasTool(self.canvasPanel.commands.canvasTool, 1)(None) self.canvasPanel.commands.update(brushSize=self.canvasPanel.brushSize, colours=self.canvasPanel.brushColours) self.addWindow(self.canvasPanel, expand=True) self.assetsWindow = RoarAssetsWindow(GuiCanvasWxBackend, defaultCellSize, self)