diff --git a/toonz/sources/tnztools/editassistantstool.cpp b/toonz/sources/tnztools/editassistantstool.cpp index ddb78b6..8d00997 100644 --- a/toonz/sources/tnztools/editassistantstool.cpp +++ b/toonz/sources/tnztools/editassistantstool.cpp @@ -10,6 +10,7 @@ // TnzLib includes #include #include +#include // TnzCore includes #include @@ -41,14 +42,16 @@ public: EditAssistantsUndo( TXshSimpleLevel *level, const TFrameId &frameId, - bool isCreated, - bool isRemoved, + bool frameCreated, + bool levelCreated, + bool objectCreated, + bool objectRemoved, TMetaObjectP metaObject, TVariant oldData ): - ToolUtils::TToolUndo(level, frameId), - m_isCreated(isCreated), - m_isRemoved(isRemoved), + ToolUtils::TToolUndo(level, frameId, frameCreated, levelCreated), + m_isCreated(objectCreated), + m_isRemoved(objectRemoved), m_metaObject(metaObject), m_oldData(oldData), m_newData(m_metaObject->data()), @@ -80,15 +83,22 @@ public: m_metaObject->handler()->fixData(); } } - notifyImageChanged(); } } - void undo() const override - { process(m_isCreated, m_oldData); } + void undo() const override { + removeLevelAndFrameIfNeeded(); + process(m_isCreated, m_oldData); + TTool::getApplication()->getCurrentXsheet()->notifyXsheetChanged(); + notifyImageChanged(); + } - void redo() const override - { process(m_isRemoved, m_newData); } + void redo() const override { + insertLevelAndFrameIfNeeded(); + process(m_isRemoved, m_newData); + TTool::getApplication()->getCurrentXsheet()->notifyXsheetChanged(); + notifyImageChanged(); + } }; @@ -372,12 +382,16 @@ protected: TUndoManager::manager()->add(new EditAssistantsUndo( getApplication()->getCurrentLevel()->getLevel()->getSimpleLevel(), getCurrentFid(), + m_isFrameCreated, + m_isLevelCreated, m_currentAssistantCreated, false, m_writeObject, m_currentAssistantBackup )); m_currentAssistantCreated = false; m_currentAssistantChanged = false; + m_isFrameCreated = false; + m_isLevelCreated = false; success = true; } } @@ -391,6 +405,12 @@ protected: return success; } +public: + bool preLeftButtonDown() override { + touchImage(); + return true; + } + void leftButtonDown(const TPointD &position, const TMouseEvent&) override { apply(); m_dragging = true; @@ -457,16 +477,17 @@ protected: TUndoManager::manager()->add(new EditAssistantsUndo( getApplication()->getCurrentLevel()->getLevel()->getSimpleLevel(), getCurrentFid(), - false, - true, + false, // frameCreated + false, // levelCreated + false, // objectCreated + true, // objectRemoved m_writeObject, m_writeObject->data() )); success = true; } - if (success) { + if (success) notifyImageChanged(); - } resetCurrentPoint(); getApplication()->getCurrentTool()->notifyToolChanged(); diff --git a/toonz/sources/toonzlib/txshsimplelevel.cpp b/toonz/sources/toonzlib/txshsimplelevel.cpp index 4e9acd5..8233c0a 100644 --- a/toonz/sources/toonzlib/txshsimplelevel.cpp +++ b/toonz/sources/toonzlib/txshsimplelevel.cpp @@ -22,6 +22,7 @@ // TnzCore includes #include "trasterimage.h" #include "tvectorimage.h" +#include "tmetaimage.h" #include "tmeshimage.h" #include "timagecache.h" #include "tofflinegl.h" @@ -2033,6 +2034,10 @@ TImageP TXshSimpleLevel::createEmptyFrame() { result = new TVectorImage; break; + case META_XSHLEVEL: + result = new TMetaImage(); + break; + case MESH_XSHLEVEL: assert(false); // Not implemented yet break;