From 209b908fb4bbcfe4fdf3e67c03ef6dfec2fcad99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Sun, 15 Sep 2019 15:57:38 +0200 Subject: [PATCH] Inhibit {drag & drop,{un,re}do} during object tool usage. libroar/RoarCanvasCommands.py:update(): disable {re,un}do {menu,toolbar} items on lastPanelState["undoInhibit"]. libroar/RoarCanvasWindow.py:applyTool(): call commands.update(undoInhibit=True) after active object tool usage. libroar/RoarCanvasWindow.py:OnDropText(): inhibit during active object tool usage. --- libroar/RoarCanvasCommands.py | 12 +++++++++--- libroar/RoarCanvasWindow.py | 22 ++++++++++++++-------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/libroar/RoarCanvasCommands.py b/libroar/RoarCanvasCommands.py index 6eb577a..4eec844 100644 --- a/libroar/RoarCanvasCommands.py +++ b/libroar/RoarCanvasCommands.py @@ -62,12 +62,18 @@ class RoarCanvasCommands(RoarCanvasCommandsFile, RoarCanvasCommandsEdit, RoarCan self.parentFrame.SetTitle("roar") if "toolName" in self.lastPanelState: textItems.append("Current tool: {}".format(self.lastPanelState["toolName"])) - if "dirty" in self.lastPanelState \ + if "dirty" in self.lastPanelState \ and self.lastPanelState["dirty"]: textItems.append("*") self.parentFrame.statusBar.SetStatusText(" | ".join(textItems)) - if "undoLevel" in self.lastPanelState: - if (self.lastPanelState["undoLevel"] >= 0) \ + if ("undoInhibit" in self.lastPanelState) \ + and (self.lastPanelState["undoInhibit"]): + for item in (self.canvasRedo, self.canvasUndo): + self.parentFrame.menuItemsById[item.attrDict["id"]].Enable(False) + toolBar = self.parentFrame.toolBarItemsById[item.attrDict["id"]].GetToolBar() + toolBar.EnableTool(item.attrDict["id"], False) + elif "undoLevel" in self.lastPanelState: + if (self.lastPanelState["undoLevel"] >= 0) \ and (self.lastPanelState["undoLevel"] < (len(self.parentCanvas.canvas.journal.patchesUndo) - 1)): self.parentFrame.menuItemsById[self.canvasUndo.attrDict["id"]].Enable(True) toolBar = self.parentFrame.toolBarItemsById[self.canvasUndo.attrDict["id"]].GetToolBar() diff --git a/libroar/RoarCanvasWindow.py b/libroar/RoarCanvasWindow.py index 0b57205..c6ee63d 100644 --- a/libroar/RoarCanvasWindow.py +++ b/libroar/RoarCanvasWindow.py @@ -17,7 +17,9 @@ class RoarCanvasWindowDropTarget(wx.TextDropTarget): # {{{ OnDropText(self, x, y, data) def OnDropText(self, x, y, data): rc = False - if not self.inProgress: + if ((self.parent.commands.currentTool.__class__ != ToolObject) \ + or (self.parent.commands.currentTool.toolState == self.parent.commands.currentTool.TS_NONE)) \ + and (not self.inProgress): try: dropMap, dropSize = json.loads(data) viewRect = self.parent.GetViewStart() @@ -73,13 +75,17 @@ class RoarCanvasWindow(GuiWindow): else: self.commands.update(cellPos=mapPoint if mapPoint else self.brushPos) self.canvas.journal.end() - if rc and (tool.__class__ == ToolObject) \ - and (tool.toolState == tool.TS_NONE) \ - and tool.external: - self.commands.currentTool, self.commands.lastTool = self.commands.lastTool, self.commands.currentTool - self.commands.update(toolName=self.commands.currentTool.name) - self.dropTarget.done() - return rc + if rc and (tool.__class__ == ToolObject): + if tool.toolState > tool.TS_NONE: + self.commands.update(undoInhibit=True) + elif tool.toolState == tool.TS_NONE: + if tool.external: + self.commands.currentTool, self.commands.lastTool = self.commands.lastTool, self.commands.currentTool + self.commands.update(toolName=self.commands.currentTool.name, undoInhibit=False) + self.dropTarget.done() + else: + self.commands.update(undoInhibit=False) + return rc # }}} # {{{ dispatchDeltaPatches(self, deltaPatches) def dispatchDeltaPatches(self, deltaPatches):