mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-26 16:56: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
80b6b151db
commit
209b908fb4
@ -62,12 +62,18 @@ class RoarCanvasCommands(RoarCanvasCommandsFile, RoarCanvasCommandsEdit, RoarCan
|
|||||||
self.parentFrame.SetTitle("roar")
|
self.parentFrame.SetTitle("roar")
|
||||||
if "toolName" in self.lastPanelState:
|
if "toolName" in self.lastPanelState:
|
||||||
textItems.append("Current tool: {}".format(self.lastPanelState["toolName"]))
|
textItems.append("Current tool: {}".format(self.lastPanelState["toolName"]))
|
||||||
if "dirty" in self.lastPanelState \
|
if "dirty" in self.lastPanelState \
|
||||||
and self.lastPanelState["dirty"]:
|
and self.lastPanelState["dirty"]:
|
||||||
textItems.append("*")
|
textItems.append("*")
|
||||||
self.parentFrame.statusBar.SetStatusText(" | ".join(textItems))
|
self.parentFrame.statusBar.SetStatusText(" | ".join(textItems))
|
||||||
if "undoLevel" in self.lastPanelState:
|
if ("undoInhibit" in self.lastPanelState) \
|
||||||
if (self.lastPanelState["undoLevel"] >= 0) \
|
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)):
|
and (self.lastPanelState["undoLevel"] < (len(self.parentCanvas.canvas.journal.patchesUndo) - 1)):
|
||||||
self.parentFrame.menuItemsById[self.canvasUndo.attrDict["id"]].Enable(True)
|
self.parentFrame.menuItemsById[self.canvasUndo.attrDict["id"]].Enable(True)
|
||||||
toolBar = self.parentFrame.toolBarItemsById[self.canvasUndo.attrDict["id"]].GetToolBar()
|
toolBar = self.parentFrame.toolBarItemsById[self.canvasUndo.attrDict["id"]].GetToolBar()
|
||||||
|
@ -17,7 +17,9 @@ class RoarCanvasWindowDropTarget(wx.TextDropTarget):
|
|||||||
# {{{ 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:
|
if ((self.parent.commands.currentTool.__class__ != ToolObject) \
|
||||||
|
or (self.parent.commands.currentTool.toolState == self.parent.commands.currentTool.TS_NONE)) \
|
||||||
|
and (not self.inProgress):
|
||||||
try:
|
try:
|
||||||
dropMap, dropSize = json.loads(data)
|
dropMap, dropSize = json.loads(data)
|
||||||
viewRect = self.parent.GetViewStart()
|
viewRect = self.parent.GetViewStart()
|
||||||
@ -73,13 +75,17 @@ class RoarCanvasWindow(GuiWindow):
|
|||||||
else:
|
else:
|
||||||
self.commands.update(cellPos=mapPoint if mapPoint else self.brushPos)
|
self.commands.update(cellPos=mapPoint if mapPoint else self.brushPos)
|
||||||
self.canvas.journal.end()
|
self.canvas.journal.end()
|
||||||
if rc and (tool.__class__ == ToolObject) \
|
if rc and (tool.__class__ == ToolObject):
|
||||||
and (tool.toolState == tool.TS_NONE) \
|
if tool.toolState > tool.TS_NONE:
|
||||||
and tool.external:
|
self.commands.update(undoInhibit=True)
|
||||||
self.commands.currentTool, self.commands.lastTool = self.commands.lastTool, self.commands.currentTool
|
elif tool.toolState == tool.TS_NONE:
|
||||||
self.commands.update(toolName=self.commands.currentTool.name)
|
if tool.external:
|
||||||
self.dropTarget.done()
|
self.commands.currentTool, self.commands.lastTool = self.commands.lastTool, self.commands.currentTool
|
||||||
return rc
|
self.commands.update(toolName=self.commands.currentTool.name, undoInhibit=False)
|
||||||
|
self.dropTarget.done()
|
||||||
|
else:
|
||||||
|
self.commands.update(undoInhibit=False)
|
||||||
|
return rc
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ dispatchDeltaPatches(self, deltaPatches)
|
# {{{ dispatchDeltaPatches(self, deltaPatches)
|
||||||
def dispatchDeltaPatches(self, deltaPatches):
|
def dispatchDeltaPatches(self, deltaPatches):
|
||||||
|
Loading…
Reference in New Issue
Block a user