From 79d310d331d6c0e5de05f8bb12216592a3120a11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Mon, 23 Sep 2019 22:12:20 +0200 Subject: [PATCH] Implements pick colour tool. assets/text/TODO: updated. --- assets/images/toolPickColour.png | Bin 0 -> 220 bytes assets/text/TODO | 6 +++--- assets/text/hotkeys.txt | 2 +- libroar/RoarCanvasCommands.py | 2 +- libroar/RoarCanvasCommandsTools.py | 10 ++++++---- libtools/ToolPickColour.py | 27 +++++++++++++++++++++++++++ 6 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 assets/images/toolPickColour.png create mode 100644 libtools/ToolPickColour.py diff --git a/assets/images/toolPickColour.png b/assets/images/toolPickColour.png new file mode 100644 index 0000000000000000000000000000000000000000..851cb4a2265a11b60255b40a28e2baf7e4b10430 GIT binary patch literal 220 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucLCF%=h?3y^w370~qEv>0#LT=By}Z;C1rt33 zJwwYY*EWF^`FOfGhFJJ-?eXMdFyJ`y>%YH$wPx!|#%(O!&{DXWlJQt*7HB} zt7vcfz{mPfmg|tUNK3f}$NK<*dkYoz+;*Avo!^hMzw(L|$HLhCbJoNy0Gi9->FVdQ I&MBb@0EFE|ApigX literal 0 HcmV?d00001 diff --git a/assets/text/TODO b/assets/text/TODO index 5e3c725..2934c6b 100644 --- a/assets/text/TODO +++ b/assets/text/TODO @@ -24,8 +24,8 @@ High-priority list: 2) bug: a) new canvas/startup b) place rect c) move mouse d) undo status changes 3) bug: a) start w/ spoke-vxplion.txt b) scroll down c) fix w/ canvas resize 4) add hotkeys.txt mIRC art canvas to help menu -5) tools: pick colour, unicode block elements -6) bug: a) text tool b) paste text c) undo -7) bug: a) tile once b) tile twice +5) bug: a) text tool b) paste text c) undo +6) bug: a) tile once b) tile twice +7) tools: unicode block elements vim:ff=dos tw=0 diff --git a/assets/text/hotkeys.txt b/assets/text/hotkeys.txt index cd2bac7..92de855 100644 --- a/assets/text/hotkeys.txt +++ b/assets/text/hotkeys.txt @@ -1,6 +1,6 @@ 0-9, 0-5, 6 Set foreground colour to #0-9, #10-15, transparent colour, resp. 0-9, 0-5, 6 Set background colour to #0-9, #10-15, transparent colour, resp. - C, U, E, F, L, R, E, T Switch to circle, cursor, erase, fill, line, rectangle, object, text tool + C, U, E, F, L, P, R, E, T Switch to circle, cursor, erase, fill, line, pick colour, rectangle, object, text tool I Flip colours N New canvas O Open mIRC art file diff --git a/libroar/RoarCanvasCommands.py b/libroar/RoarCanvasCommands.py index b64323d..344287d 100644 --- a/libroar/RoarCanvasCommands.py +++ b/libroar/RoarCanvasCommands.py @@ -129,7 +129,7 @@ class RoarCanvasCommands(RoarCanvasCommandsFile, RoarCanvasCommandsEdit, RoarCan self.canvasUndo, self.canvasRedo, NID_TOOLBAR_HSEP, self.canvasCut, self.canvasCopy, self.canvasPaste, self.canvasDelete, NID_TOOLBAR_HSEP, self.canvasAssetsWindowHide, self.canvasAssetsWindowShow, NID_TOOLBAR_HSEP, - self.canvasTool(self.canvasTool, 1), self.canvasTool(self.canvasTool, 6), self.canvasTool(self.canvasTool, 0), self.canvasTool(self.canvasTool, 3), self.canvasTool(self.canvasTool, 4), self.canvasTool(self.canvasTool, 7), self.canvasTool(self.canvasTool, 5), self.canvasTool(self.canvasTool, 2), + self.canvasTool(self.canvasTool, 1), self.canvasTool(self.canvasTool, 7), self.canvasTool(self.canvasTool, 0), self.canvasTool(self.canvasTool, 3), self.canvasTool(self.canvasTool, 4), self.canvasTool(self.canvasTool, 8), self.canvasTool(self.canvasTool, 5), self.canvasTool(self.canvasTool, 2), self.canvasTool(self.canvasTool, 6), ]) toolBars.append( [self.canvasColour(self.canvasColour, 0), self.canvasColour(self.canvasColour, 1), self.canvasColour(self.canvasColour, 2), self.canvasColour(self.canvasColour, 3), diff --git a/libroar/RoarCanvasCommandsTools.py b/libroar/RoarCanvasCommandsTools.py index 18bde4b..588294c 100644 --- a/libroar/RoarCanvasCommandsTools.py +++ b/libroar/RoarCanvasCommandsTools.py @@ -10,6 +10,7 @@ from ToolErase import ToolErase from ToolFill import ToolFill from ToolLine import ToolLine from ToolObject import ToolObject +from ToolPickColour import ToolPickColour from ToolRect import ToolRect from ToolText import ToolText import wx @@ -21,15 +22,16 @@ class RoarCanvasCommandsTools(): @GuiSelectDecorator(3, "Fill", "&Fill", ["toolFill.png"], [wx.ACCEL_CTRL, ord("F")], False) @GuiSelectDecorator(4, "Line", "&Line", ["toolLine.png"], [wx.ACCEL_CTRL, ord("L")], False) @GuiSelectDecorator(5, "Object", "&Object", ["toolObject.png"], [wx.ACCEL_CTRL, ord("E")], False) - @GuiSelectDecorator(6, "Rectangle", "&Rectangle", ["toolRect.png"], [wx.ACCEL_CTRL, ord("R")], True) - @GuiSelectDecorator(7, "Text", "&Text", ["toolText.png"], [wx.ACCEL_CTRL, ord("T")], False) + @GuiSelectDecorator(6, "Pick colour", "&Pick colour", ["toolPickColour.png"], [wx.ACCEL_CTRL, ord("P")], False) + @GuiSelectDecorator(7, "Rectangle", "&Rectangle", ["toolRect.png"], [wx.ACCEL_CTRL, ord("R")], True) + @GuiSelectDecorator(8, "Text", "&Text", ["toolText.png"], [wx.ACCEL_CTRL, ord("T")], False) def canvasTool(self, f, idx): def canvasTool_(event): if (self.currentTool.__class__ == ToolObject) \ and (self.currentTool.toolState > self.currentTool.TS_NONE) \ and self.currentTool.external: self.parentCanvas.dropTarget.done() - self.lastTool, self.currentTool = self.currentTool, [ToolCircle, None, ToolErase, ToolFill, ToolLine, ToolObject, ToolRect, ToolText][idx] + self.lastTool, self.currentTool = self.currentTool, [ToolCircle, None, ToolErase, ToolFill, ToolLine, ToolObject, ToolPickColour, ToolRect, ToolText][idx] if self.currentTool != None: self.currentTool = self.currentTool() self.currentOperator, self.operatorState = None, None @@ -53,7 +55,7 @@ class RoarCanvasCommandsTools(): self.accels = () self.menus = ( ("&Tools", - self.canvasTool(self.canvasTool, 1), self.canvasTool(self.canvasTool, 6), self.canvasTool(self.canvasTool, 0), self.canvasTool(self.canvasTool, 3), self.canvasTool(self.canvasTool, 4), self.canvasTool(self.canvasTool, 7), self.canvasTool(self.canvasTool, 5), self.canvasTool(self.canvasTool, 2), + self.canvasTool(self.canvasTool, 1), self.canvasTool(self.canvasTool, 7), self.canvasTool(self.canvasTool, 0), self.canvasTool(self.canvasTool, 3), self.canvasTool(self.canvasTool, 4), self.canvasTool(self.canvasTool, 8), self.canvasTool(self.canvasTool, 5), self.canvasTool(self.canvasTool, 2), self.canvasTool(self.canvasTool, 6), ), ) self.toolBars = () diff --git a/libtools/ToolPickColour.py b/libtools/ToolPickColour.py new file mode 100644 index 0000000..6b1fac2 --- /dev/null +++ b/libtools/ToolPickColour.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +# +# ToolPickColour.py +# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz +# + +from Tool import Tool + +class ToolPickColour(Tool): + name = "Pick colour" + + # + # onMouseEvent(self, atPoint, brushColours, brushPos, brushSize, canvas, dispatchFn, eventDc, keyModifiers, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown) + def onMouseEvent(self, atPoint, brushColours, brushPos, brushSize, canvas, dispatchFn, eventDc, keyModifiers, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown): + if (mapPoint[0] < canvas.size[0]) \ + and (mapPoint[1] < canvas.size[1]): + if mouseLeftDown: + if canvas.map[mapPoint[1]][mapPoint[0]][3] == " ": + brushColours[0] = canvas.map[mapPoint[1]][mapPoint[0]][1] + else: + brushColours[0] = canvas.map[mapPoint[1]][mapPoint[0]][0] + elif mouseRightDown: + brushColours[1] = canvas.map[mapPoint[1]][mapPoint[0]][1] + dispatchFn(eventDc, True, [*mapPoint, *brushColours, 0, "░"]) + return True, False + +# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120