From 0064ea7a3b1c98cf0d02ebdccd480be6061617cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Sat, 28 Sep 2019 20:12:53 +0200 Subject: [PATCH] Apply tool w/ mouse state on brush/colour update. --- libroar/RoarCanvasCommandsEdit.py | 12 ++++++------ libroar/RoarCanvasWindow.py | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libroar/RoarCanvasCommandsEdit.py b/libroar/RoarCanvasCommandsEdit.py index 4ea854b..d785606 100644 --- a/libroar/RoarCanvasCommandsEdit.py +++ b/libroar/RoarCanvasCommandsEdit.py @@ -55,7 +55,7 @@ class RoarCanvasCommandsEdit(): [self.canvasBrushSize(f, dimension_, incrFlag)(None) for dimension_ in [0, 1]] viewRect = self.parentCanvas.GetViewStart() eventDc = self.parentCanvas.backend.getDeviceContext(self.parentCanvas.GetClientSize(), self.parentCanvas, viewRect) - self.parentCanvas.applyTool(eventDc, True, None, None, None, self.parentCanvas.brushPos, False, False, False, self.currentTool, viewRect, force=True) + self.parentCanvas.applyTool(eventDc, True, None, None, None, self.parentCanvas.brushPos, *self.parentCanvas.lastMouseState, self.currentTool, viewRect, force=True) setattr(canvasBrushSize_, "attrDict", f.attrList[dimension + (0 if not incrFlag else 3)]) return canvasBrushSize_ @@ -109,7 +109,7 @@ class RoarCanvasCommandsEdit(): self.update(colours=self.parentCanvas.brushColours) viewRect = self.parentCanvas.GetViewStart() eventDc = self.parentCanvas.backend.getDeviceContext(self.parentCanvas.GetClientSize(), self.parentCanvas, viewRect) - self.parentCanvas.applyTool(eventDc, True, None, None, None, self.parentCanvas.brushPos, False, False, False, self.currentTool, viewRect, force=True) + self.parentCanvas.applyTool(eventDc, True, None, None, None, self.parentCanvas.brushPos, *self.parentCanvas.lastMouseState, self.currentTool, viewRect, force=True) setattr(canvasColour_, "attrDict", f.attrList[idx]) setattr(canvasColour_, "isSelect", True) return canvasColour_ @@ -124,7 +124,7 @@ class RoarCanvasCommandsEdit(): self.update(colours=self.parentCanvas.brushColours) viewRect = self.parentCanvas.GetViewStart() eventDc = self.parentCanvas.backend.getDeviceContext(self.parentCanvas.GetClientSize(), self.parentCanvas, viewRect) - self.parentCanvas.applyTool(eventDc, True, None, None, None, self.parentCanvas.brushPos, False, False, False, self.currentTool, viewRect, force=True) + self.parentCanvas.applyTool(eventDc, True, None, None, None, self.parentCanvas.brushPos, *self.parentCanvas.lastMouseState, self.currentTool, viewRect, force=True) setattr(canvasColourAlpha_, "attrDict", f.attrList[idx]) setattr(canvasColourAlpha_, "isSelect", True) return canvasColourAlpha_ @@ -136,7 +136,7 @@ class RoarCanvasCommandsEdit(): self.update(colours=self.parentCanvas.brushColours) viewRect = self.parentCanvas.GetViewStart() eventDc = self.parentCanvas.backend.getDeviceContext(self.parentCanvas.GetClientSize(), self.parentCanvas, viewRect) - self.parentCanvas.applyTool(eventDc, True, None, None, None, self.parentCanvas.brushPos, False, False, False, self.currentTool, viewRect, force=True) + self.parentCanvas.applyTool(eventDc, True, None, None, None, self.parentCanvas.brushPos, *self.parentCanvas.lastMouseState, self.currentTool, viewRect, force=True) setattr(canvasColourAlphaBackground_, "attrDict", f.attrList[idx]) setattr(canvasColourAlphaBackground_, "isSelect", True) return canvasColourAlphaBackground_ @@ -163,7 +163,7 @@ class RoarCanvasCommandsEdit(): self.update(colours=self.parentCanvas.brushColours) viewRect = self.parentCanvas.GetViewStart() eventDc = self.parentCanvas.backend.getDeviceContext(self.parentCanvas.GetClientSize(), self.parentCanvas, viewRect) - self.parentCanvas.applyTool(eventDc, True, None, None, None, self.parentCanvas.brushPos, False, False, False, self.currentTool, viewRect, force=True) + self.parentCanvas.applyTool(eventDc, True, None, None, None, self.parentCanvas.brushPos, *self.parentCanvas.lastMouseState, self.currentTool, viewRect, force=True) setattr(canvasColourBackground_, "attrDict", f.attrList[idx]) setattr(canvasColourBackground_, "isSelect", True) return canvasColourBackground_ @@ -174,7 +174,7 @@ class RoarCanvasCommandsEdit(): self.update(colours=self.parentCanvas.brushColours) viewRect = self.parentCanvas.GetViewStart() eventDc = self.parentCanvas.backend.getDeviceContext(self.parentCanvas.GetClientSize(), self.parentCanvas, viewRect) - self.parentCanvas.applyTool(eventDc, True, None, None, None, self.parentCanvas.brushPos, False, False, False, self.currentTool, viewRect, force=True) + self.parentCanvas.applyTool(eventDc, True, None, None, None, self.parentCanvas.brushPos, *self.parentCanvas.lastMouseState, self.currentTool, viewRect, force=True) @GuiCommandDecorator("Copy", "&Copy", ["", wx.ART_COPY], None, False) def canvasCopy(self, event): diff --git a/libroar/RoarCanvasWindow.py b/libroar/RoarCanvasWindow.py index 15cebc1..48f62a6 100644 --- a/libroar/RoarCanvasWindow.py +++ b/libroar/RoarCanvasWindow.py @@ -227,6 +227,7 @@ class RoarCanvasWindow(GuiWindow): def onMouseInput(self, event): viewRect = self.GetViewStart(); eventDc = self.backend.getDeviceContext(self.GetClientSize(), self, viewRect); mouseDragging, mouseLeftDown, mouseRightDown = event.Dragging(), event.LeftIsDown(), event.RightIsDown() + self.lastMouseState = [mouseDragging, mouseLeftDown, mouseRightDown] mapPoint = self.backend.xlateEventPoint(event, eventDc, viewRect) if viewRect != (0, 0): mapPoint = [a + b for a, b in zip(mapPoint, viewRect)] @@ -322,7 +323,7 @@ class RoarCanvasWindow(GuiWindow): def __init__(self, backend, canvas, commands, parent, pos, size): super().__init__(parent, pos) - self.size = size + self.lastMouseState, self.size = [False, False, False], size self.backend, self.canvas, self.commands, self.parentFrame = backend(self.size), canvas, commands(self, parent), parent self.brushColours, self.brushPos, self.brushSize, self.dirty, self.lastCellState = [4, 1], [0, 0], [1, 1], False, None self.popupEventDc = None