Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

Extended tool class to prevent permanent undo in all OSes

Dennis Lam7fb9cb837192
diff --git a/toonz/sources/include/tools/tool.h b/toonz/sources/include/tools/tool.h
index f6ba61878..c6b71bf35 100644
--- a/toonz/sources/include/tools/tool.h
+++ b/toonz/sources/include/tools/tool.h
@@ -550,6 +550,9 @@ transformation.
return m_selectedFrames;
}
+ void setCanUndo(bool on) { m_canUndo = on; }
+ bool isUndoable() const { return m_canUndo; }
+
void tweenSelectedGuideStrokes();
void tweenGuideStrokeToSelected();
void flipGuideStrokeDirection(int mode);
@@ -582,6 +585,7 @@ protected:
int m_targetType; //!< The tool's image type target.
bool m_enabled; //!< Whether the tool allows user interaction.
+ bool m_canUndo; //!< Whether the tool allows the user to undo while the tool is selected
bool m_active;
bool m_picking;
diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cpp
index bd7a4efe6..4b0b32d88 100644
--- a/toonz/sources/toonz/mainwindow.cpp
+++ b/toonz/sources/toonz/mainwindow.cpp
@@ -941,7 +941,7 @@ void MainWindow::onUndo() {
ToolHandle *toolH = TApp::instance()->getCurrentTool();
// do not use undo if tool is currently in use
- if (!toolH->isToolBusy()) {
+ if (!toolH->getTool()->isUndoable()) {
bool ret = TUndoManager::manager()->undo();
if (!ret) DVGui::error(QObject::tr("No more Undo operations available."));
}
diff --git a/toonz/sources/toonz/sceneviewerevents.cpp b/toonz/sources/toonz/sceneviewerevents.cpp
index 35527c6de..8c95743bf 100644
--- a/toonz/sources/toonz/sceneviewerevents.cpp
+++ b/toonz/sources/toonz/sceneviewerevents.cpp
@@ -827,11 +827,13 @@ void SceneViewer::onPress(const TMouseEvent &event) {
// separate tablet and mouse events
if (m_tabletEvent && m_tabletState == Touched) {
TApp::instance()->getCurrentTool()->setToolBusy(true);
+ tool->setCanUndo(true);
m_tabletState = StartStroke;
tool->leftButtonDown(pos, event);
} else if (m_mouseButton == Qt::LeftButton) {
m_mouseState = StartStroke;
TApp::instance()->getCurrentTool()->setToolBusy(true);
+ tool->setCanUndo(true);
tool->leftButtonDown(pos, event);
}
if (m_mouseButton == Qt::RightButton) tool->rightButtonDown(pos, event);
@@ -924,6 +926,7 @@ void SceneViewer::onRelease(const TMouseEvent &event) {
if (m_mouseButton == Qt::LeftButton || m_tabletState == Released) {
if (!m_toolSwitched) tool->leftButtonUp(pos, event);
TApp::instance()->getCurrentTool()->setToolBusy(false);
+ tool->setCanUndo(false);
}
}