mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-26 08:56:36 +00:00
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:
parent
9c6b7fa9b2
commit
bc50a0ca43
@ -10,29 +10,34 @@ 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
|
||||||
try:
|
if not self.inProgress:
|
||||||
dropMap, dropSize = json.loads(data)
|
try:
|
||||||
viewRect = self.parent.GetViewStart()
|
dropMap, dropSize = json.loads(data)
|
||||||
rectX, rectY = x - (x % self.parent.backend.cellSize[0]), y - (y % self.parent.backend.cellSize[1])
|
viewRect = self.parent.GetViewStart()
|
||||||
mapX, mapY = int(rectX / self.parent.backend.cellSize[0] if rectX else 0), int(rectY / self.parent.backend.cellSize[1] if rectY else 0)
|
rectX, rectY = x - (x % self.parent.backend.cellSize[0]), y - (y % self.parent.backend.cellSize[1])
|
||||||
mapPoint = [m + n for m, n in zip((mapX, mapY), viewRect)]
|
mapX, mapY = int(rectX / self.parent.backend.cellSize[0] if rectX else 0), int(rectY / self.parent.backend.cellSize[1] if rectY else 0)
|
||||||
self.parent.commands.lastTool, self.parent.commands.currentTool = self.parent.commands.currentTool, ToolObject()
|
mapPoint = [m + n for m, n in zip((mapX, mapY), viewRect)]
|
||||||
self.parent.commands.currentTool.setRegion(self.parent.canvas, mapPoint, dropMap, dropSize, external=True)
|
self.parent.commands.lastTool, self.parent.commands.currentTool = self.parent.commands.currentTool, ToolObject()
|
||||||
self.parent.commands.update(toolName=self.parent.commands.currentTool.name)
|
self.parent.commands.currentTool.setRegion(self.parent.canvas, mapPoint, dropMap, dropSize, external=True)
|
||||||
eventDc = self.parent.backend.getDeviceContext(self.parent.GetClientSize(), self.parent, viewRect)
|
self.parent.commands.update(toolName=self.parent.commands.currentTool.name)
|
||||||
self.parent.applyTool(eventDc, True, None, None, self.parent.brushPos, False, False, False, self.parent.commands.currentTool, viewRect)
|
eventDc = self.parent.backend.getDeviceContext(self.parent.GetClientSize(), self.parent, viewRect)
|
||||||
rc = True
|
self.parent.applyTool(eventDc, True, None, None, self.parent.brushPos, False, False, False, self.parent.commands.currentTool, viewRect)
|
||||||
except:
|
rc = True; self.inProgress = True;
|
||||||
with wx.MessageDialog(self.parent, "Error: {}".format(sys.exc_info()[1]), "", wx.OK | wx.OK_DEFAULT) as dialog:
|
except:
|
||||||
dialogChoice = dialog.ShowModal()
|
with wx.MessageDialog(self.parent, "Error: {}".format(sys.exc_info()[1]), "", wx.OK | wx.OK_DEFAULT) as dialog:
|
||||||
|
dialogChoice = dialog.ShowModal()
|
||||||
return rc
|
return rc
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ __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)
|
||||||
|
Loading…
Reference in New Issue
Block a user