mirror of
https://github.com/lalbornoz/roar.git
synced 2024-12-22 20:36:37 +00:00
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.
This commit is contained in:
parent
1487f2eb9a
commit
9f72bd5a4c
@ -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()
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user