libroar/RoarCanvasWindow.py:RoarCanvasWindowDropTarget.{done,OnDropText,__init__}(): {honour,set} inProgress.

libroar/RoarCanvasWindow.py:applyTool(): call dropTarget.done() when resetting to last tool.
This commit is contained in:
Lucio Andrés Illanes Albornoz 2019-09-15 13:57:41 +02:00
parent a40017b607
commit d7ebed77f7

View File

@ -10,9 +10,14 @@ import json, wx, sys
import time import time
class RoarCanvasWindowDropTarget(wx.TextDropTarget): class RoarCanvasWindowDropTarget(wx.TextDropTarget):
# {{{ done(self)
def done(self):
self.inProgress = False
# }}}
# {{{ OnDropText(self, x, y, data) # {{{ OnDropText(self, x, y, data)
def OnDropText(self, x, y, data): def OnDropText(self, x, y, data):
rc = False rc = False
if not self.inProgress:
try: try:
dropMap, dropSize = json.loads(data) dropMap, dropSize = json.loads(data)
viewRect = self.parent.GetViewStart() viewRect = self.parent.GetViewStart()
@ -24,7 +29,7 @@ class RoarCanvasWindowDropTarget(wx.TextDropTarget):
self.parent.commands.update(toolName=self.parent.commands.currentTool.name) self.parent.commands.update(toolName=self.parent.commands.currentTool.name)
eventDc = self.parent.backend.getDeviceContext(self.parent.GetClientSize(), self.parent, viewRect) eventDc = self.parent.backend.getDeviceContext(self.parent.GetClientSize(), self.parent, viewRect)
self.parent.applyTool(eventDc, True, None, None, self.parent.brushPos, False, False, False, self.parent.commands.currentTool, viewRect) self.parent.applyTool(eventDc, True, None, None, self.parent.brushPos, False, False, False, self.parent.commands.currentTool, viewRect)
rc = True rc = True; self.inProgress = True;
except: except:
with wx.MessageDialog(self.parent, "Error: {}".format(sys.exc_info()[1]), "", wx.OK | wx.OK_DEFAULT) as dialog: with wx.MessageDialog(self.parent, "Error: {}".format(sys.exc_info()[1]), "", wx.OK | wx.OK_DEFAULT) as dialog:
dialogChoice = dialog.ShowModal() dialogChoice = dialog.ShowModal()
@ -32,7 +37,7 @@ class RoarCanvasWindowDropTarget(wx.TextDropTarget):
# }}} # }}}
# {{{ __init__(self, parent) # {{{ __init__(self, parent)
def __init__(self, parent): def __init__(self, parent):
super().__init__(); self.parent = parent; super().__init__(); self.inProgress, self.parent = False, parent;
# }}} # }}}
class RoarCanvasWindow(GuiWindow): class RoarCanvasWindow(GuiWindow):
@ -73,6 +78,7 @@ class RoarCanvasWindow(GuiWindow):
and tool.external: and tool.external:
self.commands.currentTool, self.commands.lastTool = self.commands.lastTool, self.commands.currentTool self.commands.currentTool, self.commands.lastTool = self.commands.lastTool, self.commands.currentTool
self.commands.update(toolName=self.commands.currentTool.name) self.commands.update(toolName=self.commands.currentTool.name)
self.dropTarget.done()
return rc return rc
# }}} # }}}
# {{{ dispatchDeltaPatches(self, deltaPatches) # {{{ dispatchDeltaPatches(self, deltaPatches)