OpenToonz - An open-source full-featured 2D animation creation software
C
Sync Level Strip Renumber Changes with XSheet (#1464)
Jeremy Bullock4386c6271d3a
diff --git a/toonz/sources/include/toonz/preferences.h b/toonz/sources/include/toonz/preferences.hindex 8c1cbc6f4..c2317f250 100644--- a/toonz/sources/include/toonz/preferences.h+++ b/toonz/sources/include/toonz/preferences.h@@ -412,6 +412,11 @@ public:void enableShowColumnNumbers(bool on);bool isShowColumnNumbersEnabled() const { return m_showColumnNumbers; }+ void enableSyncLevelRenumberWithXsheet(bool on);+ bool isSyncLevelRenumberWithXsheetEnabled() const {+ return m_syncLevelRenumberWithXsheet;+ }+void enableShortcutCommandsWhileRenamingCell(bool on);bool isShortcutCommandsWhileRenamingCellEnabled() const {return m_shortcutCommandsWhileRenamingCellEnabled;@@ -578,7 +583,8 @@ private:m_sceneNumberingEnabled, m_animationSheetEnabled, m_inksOnly,m_startupPopupEnabled;bool m_fillOnlySavebox, m_show0ThickLines, m_regionAntialias;- bool m_onionSkinDuringPlayback, m_ignoreImageDpi;+ bool m_onionSkinDuringPlayback, m_ignoreImageDpi,+ m_syncLevelRenumberWithXsheet;bool m_keepFillOnVectorSimplify, m_useHigherDpiOnVectorSimplify;TPixel32 m_viewerBGColor, m_previewBGColor, m_chessboardColor1,m_chessboardColor2;diff --git a/toonz/sources/toonz/cellselection.cpp b/toonz/sources/toonz/cellselection.cppindex 9b7307bf6..cdf26abf7 100644--- a/toonz/sources/toonz/cellselection.cpp+++ b/toonz/sources/toonz/cellselection.cpp@@ -39,6 +39,7 @@#include "toonz/tobjecthandle.h"#include "toonz/txsheet.h"#include "toonz/txshsimplelevel.h"+#include "toonz/txshchildlevel.h"#include "toonz/toonzscene.h"#include "toonz/txshleveltypes.h"#include "toonz/tcamera.h"@@ -427,48 +428,10 @@ public:// RenumberUndo//------------------------------------------------------------------------------class RenumberUndo final : public TUndo {- std::map<TXshCell, TXshCell> m_undoTable, m_redoTable;-+class RenumberUndo {public:class RedoNotifier;class UndoNotifier;--public:- RenumberUndo(const std::map<TXshCell, TXshCell> &cellsMap)- : m_redoTable(cellsMap) {- // Invert the redo table to obtain the undo table- std::map<TXshCell, TXshCell>::iterator it, end = m_redoTable.end();- for (it = m_redoTable.begin(); it != end; ++it)- m_undoTable.insert(std::make_pair(it->second, it->first));- }-- void renumber(const std::map<TXshCell, TXshCell> &table) const {- TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();- for (int c = 0; c < xsh->getColumnCount(); ++c) {- int r0, r1;- int n = xsh->getCellRange(c, r0, r1);- if (n > 0) {- bool changed = false;- std::vector<TXshCell> cells(n);- xsh->getCells(r0, c, n, &cells[0]);- for (int i = 0; i < n; i++) {- std::map<TXshCell, TXshCell>::const_iterator it =- table.find(cells[i]);- if (it != table.end() && it->first != it->second)- cells[i] = it->second, changed = true;- }- if (changed) xsh->setCells(r0, c, n, &cells[0]);- }- }- }-- void undo() const override { renumber(m_undoTable); }- void redo() const override { renumber(m_redoTable); }-- int getSize() const override {- return (m_redoTable.size() << 2) * sizeof(TXshCell);- }};class RenumberUndo::RedoNotifier final : public TUndo {@@ -1335,19 +1298,41 @@ void TCellSelection::enableCommands() {bool TCellSelection::isEnabledCommand(std::string commandId) { // static function- static QList<std::string> commands = {- MI_Autorenumber, MI_Reverse, MI_Swing,- MI_Random, MI_Increment, MI_ResetStep,- MI_IncreaseStep, MI_DecreaseStep, MI_Step2,- MI_Step3, MI_Step4, MI_Each2,- MI_Each3, MI_Each4, MI_Rollup,- MI_Rolldown, MI_TimeStretch, MI_CloneLevel,- MI_SetKeyframes, MI_Copy, MI_Paste,- MI_PasteInto, MI_Cut, MI_Clear,- MI_Insert, MI_Reframe1, MI_Reframe2,- MI_Reframe3, MI_Reframe4, MI_ReframeWithEmptyInbetweens,- MI_Undo, MI_Redo, MI_PasteNumbers,- MI_ConvertToToonzRaster, MI_ConvertVectorToVector};+ static QList<std::string> commands = {MI_Autorenumber,+ MI_Reverse,+ MI_Swing,+ MI_Random,+ MI_Increment,+ MI_ResetStep,+ MI_IncreaseStep,+ MI_DecreaseStep,+ MI_Step2,+ MI_Step3,+ MI_Step4,+ MI_Each2,+ MI_Each3,+ MI_Each4,+ MI_Rollup,+ MI_Rolldown,+ MI_TimeStretch,+ MI_CloneLevel,+ MI_SetKeyframes,+ MI_Copy,+ MI_Paste,+ MI_PasteInto,+ MI_Cut,+ MI_Clear,+ MI_Insert,+ MI_Reframe1,+ MI_Reframe2,+ MI_Reframe3,+ MI_Reframe4,+ MI_ReframeWithEmptyInbetweens,+ MI_Undo,+ MI_Redo,+ MI_PasteNumbers,+ MI_ConvertToToonzRaster,+ MI_ConvertVectorToVector};return commands.contains(commandId);}@@ -1874,13 +1859,8 @@ static void dRenumberCells(int col, int r0, int r1) {{LevelsTable::iterator it, end = levelsTable.end();for (it = levelsTable.begin(); it != end; ++it)- FilmstripCmd::renumber(it->first, it->second);+ FilmstripCmd::renumber(it->first, it->second, true);}-- // Finally, renumber the xsheet cells- RenumberUndo *undo = new RenumberUndo(cellsMap);- undo->redo();- TUndoManager::manager()->add(undo);}//-----------------------------------------------------------------------------@@ -2447,8 +2427,8 @@ TXshSimpleLevel *TCellSelection::getNewToonzRasterLevel(ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();TFilePath sourcePath = sourceSl->getPath();std::wstring sourceName = sourcePath.getWideName();- TFilePath parentDir = sourceSl->getPath().getParentDir();- TFilePath fp = scene->getDefaultLevelPath(TZP_XSHLEVEL, sourceName)+ TFilePath parentDir = sourceSl->getPath().getParentDir();+ TFilePath fp = scene->getDefaultLevelPath(TZP_XSHLEVEL, sourceName).withParentDir(parentDir);TFilePath actualFp = scene->decodeFilePath(fp);@@ -2491,8 +2471,7 @@ public:, m_newImages(newImages), m_oldLevelHooks(oldLevelHooks) {}- ~VectorToVectorUndo() {- }+ ~VectorToVectorUndo() {}void undo() const override {for (int i = 0; i < m_frameIds.size(); i++) {@@ -2754,8 +2733,7 @@ void TCellSelection::convertVectortoVector() {// get clones of the new images for undostd::vector<TImageP> newImages;for (i = 0; i < totalImages; i++) {- newImages.push_back(- sourceSl->getFrame(frameIds[i], false)->cloneImage());+ newImages.push_back(sourceSl->getFrame(frameIds[i], false)->cloneImage());}HookSet *oldLevelHooks = new HookSet();diff --git a/toonz/sources/toonz/filmstripcommand.cpp b/toonz/sources/toonz/filmstripcommand.cppindex 23af794e2..7237d3d90 100644--- a/toonz/sources/toonz/filmstripcommand.cpp+++ b/toonz/sources/toonz/filmstripcommand.cpp@@ -22,6 +22,7 @@#include "tundo.h"#include "toonz/txshsimplelevel.h"+#include "toonz/txshchildlevel.h"#include "toonz/txshsoundlevel.h"#include "toonz/txshpalettelevel.h"#include "toonz/txshpalettecolumn.h"@@ -34,6 +35,7 @@#include "toonz/toonzimageutils.h"#include "toonz/trasterimageutils.h"#include "toonz/tcamera.h"+#include "toonz/preferences.h"#include "trop.h"#include "toonzqt/gutil.h"@@ -51,6 +53,62 @@ TFrameId operator+(const TFrameId &fid, int d) {//-----------------------------------------------------------------------------+void doUpdateXSheet(TXshSimpleLevel *sl, std::vector<TFrameId> oldFids,+ std::vector<TFrameId> newFids, TXsheet *xsh,+ std::vector<TXshChildLevel *> &childLevels) {+ for (int c = 0; c < xsh->getColumnCount(); ++c) {+ int r0, r1;+ int n = xsh->getCellRange(c, r0, r1);+ if (n > 0) {+ bool changed = false;+ std::vector<TXshCell> cells(n);+ xsh->getCells(r0, c, n, &cells[0]);+ for (int i = 0; i < n; i++) {+ TXshCell currCell = cells[i];+ // check the sub xsheets too+ if (!cells[i].isEmpty() &&+ cells[i].m_level->getType() == CHILD_XSHLEVEL) {+ TXshChildLevel *level = cells[i].m_level->getChildLevel();+ // make sure we haven't already checked the level+ if (level &&+ std::find(childLevels.begin(), childLevels.end(), level) ==+ childLevels.end()) {+ childLevels.push_back(level);+ TXsheet *subXsh = level->getXsheet();+ doUpdateXSheet(sl, oldFids, newFids, subXsh, childLevels);+ }+ }+ for (int j = 0; j < oldFids.size(); j++) {+ if (oldFids.at(j) == newFids.at(j)) continue;+ TXshCell tempCell(sl, oldFids.at(j));+ bool sameSl = tempCell.getSimpleLevel() == currCell.getSimpleLevel();+ bool sameFid = tempCell.getFrameId() == currCell.getFrameId();+ if (sameSl && sameFid) {+ TXshCell newCell(sl, newFids.at(j));+ cells[i] = newCell;+ changed = true;+ break;+ }+ }+ }+ if (changed) {+ xsh->setCells(r0, c, n, &cells[0]);+ TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();+ }+ }+ }+}++//-----------------------------------------------------------------------------++void updateXSheet(TXshSimpleLevel *sl, std::vector<TFrameId> oldFids,+ std::vector<TFrameId> newFids) {+ std::vector<TXshChildLevel *> childLevels;+ TXsheet *xsh =+ TApp::instance()->getCurrentScene()->getScene()->getTopXsheet();+ doUpdateXSheet(sl, oldFids, newFids, xsh, childLevels);+}+//=============================================================================// makeSpaceForFid// se necessario renumera gli altri fid del livello in modo che@@ -61,7 +119,9 @@ TFrameId operator+(const TFrameId &fid, int d) {void makeSpaceForFids(TXshSimpleLevel *sl,const std::set<TFrameId> &framesToInsert) {std::vector<TFrameId> fids;+ std::vector<TFrameId> oldFids;sl->getFids(fids);+ sl->getFids(oldFids);std::set<TFrameId>::const_iterator it;std::set<TFrameId> touchedFids;for (it = framesToInsert.begin(); it != framesToInsert.end(); ++it) {@@ -82,6 +142,8 @@ void makeSpaceForFids(TXshSimpleLevel *sl,}}if (!touchedFids.empty()) {+ if (Preferences::instance()->isSyncLevelRenumberWithXsheetEnabled())+ updateXSheet(sl, oldFids, fids);sl->renumber(fids);invalidateIcons(sl, touchedFids);sl->setDirtyFlag(true);@@ -876,7 +938,7 @@ class PasteFramesUndo final : public TUndo {DrawingData *m_newData;DrawingData::ImageSetType m_setType;HookSet *m_oldLevelHooks;-+ bool m_updateXSheet;bool m_keepOriginalPalette;public:@@ -897,6 +959,8 @@ public:QMimeData *data = cloneData(clipboard->mimeData());m_newData = dynamic_cast<DrawingData *>(data);assert(m_newData);+ m_updateXSheet =+ Preferences::instance()->isSyncLevelRenumberWithXsheetEnabled();}~PasteFramesUndo() {@@ -916,6 +980,11 @@ public:// Renumero i frame con i vecchi fidsif (m_setType == DrawingData::INSERT) {assert(m_sl->getFrameCount() == m_oldLevelFrameId.size());+ if (m_updateXSheet) {+ std::vector<TFrameId> newFrames;+ m_sl->getFids(newFrames);+ updateXSheet(m_sl.getPointer(), newFrames, m_oldLevelFrameId);+ }m_sl->renumber(m_oldLevelFrameId);TApp::instance()->getPaletteController()@@ -1110,15 +1179,24 @@ class AddFramesUndo final : public TUndo {TXshSimpleLevelP m_level;std::set<TFrameId> m_insertedFids;std::vector<TFrameId> m_oldFids;+ bool m_updateXSheet;public:AddFramesUndo(const TXshSimpleLevelP &level,const std::set<TFrameId> insertedFids,std::vector<TFrameId> oldFids)- : m_level(level), m_insertedFids(insertedFids), m_oldFids(oldFids) {}+ : m_level(level), m_insertedFids(insertedFids), m_oldFids(oldFids) {+ m_updateXSheet =+ Preferences::instance()->isSyncLevelRenumberWithXsheetEnabled();+ }void undo() const override {removeFramesWithoutUndo(m_level, m_insertedFids);+ if (m_updateXSheet) {+ std::vector<TFrameId> newFrames;+ m_level->getFids(newFrames);+ updateXSheet(m_level.getPointer(), newFrames, m_oldFids);+ }m_level->renumber(m_oldFids);invalidateIcons(m_level.getPointer(), m_oldFids);m_level->setDirtyFlag(true);@@ -1205,9 +1283,11 @@ class RenumberUndo final : public TUndo {TXshSimpleLevelP m_level;std::vector<TFrameId> m_fids;std::map<TFrameId, TFrameId> m_mapOldFrameId;+ bool m_updateXSheet = false;public:- RenumberUndo(const TXshSimpleLevelP &level, const std::vector<TFrameId> &fids)+ RenumberUndo(const TXshSimpleLevelP &level, const std::vector<TFrameId> &fids,+ bool forceCallUpdateXSheet = false): m_level(level), m_fids(fids) {assert(m_level);std::vector<TFrameId> oldFids;@@ -1217,8 +1297,16 @@ public:for (i = 0; i < m_fids.size(); i++) {if (m_fids[i] != oldFids[i]) m_mapOldFrameId[m_fids[i]] = oldFids[i];}+ m_updateXSheet =+ Preferences::instance()->isSyncLevelRenumberWithXsheetEnabled() ||+ forceCallUpdateXSheet;}void renumber(std::vector<TFrameId> fids) const {+ if (m_updateXSheet) {+ std::vector<TFrameId> oldFrames;+ m_level->getFids(oldFrames);+ updateXSheet(m_level.getPointer(), oldFrames, fids);+ }m_level->renumber(fids);TSelection *selection = TSelection::getCurrent();if (selection) selection->selectNone();@@ -1260,7 +1348,8 @@ public:void FilmstripCmd::renumber(TXshSimpleLevel *sl,- const std::vector<std::pair<TFrameId, TFrameId>> &table) {+ const std::vector<std::pair<TFrameId, TFrameId>> &table,+ bool forceCallUpdateXSheet) {if (!sl || sl->isSubsequence() || sl->isReadOnly()) return;if (table.empty()) return;@@ -1275,8 +1364,9 @@ void FilmstripCmd::renumber(}// tmp contains all the level fids that are not affected by the renumbering- std::vector<TFrameId> fids, rfids;+ std::vector<TFrameId> fids, rfids, oldFrames;sl->getFids(fids);+ sl->getFids(oldFrames);std::set<TFrameId> tmp;for (int i = 0; i < (int)fids.size(); i++) tmp.insert(fids[i]);for (it = table.begin(); it != table.end(); ++it) tmp.erase(it->first);@@ -1306,7 +1396,12 @@ void FilmstripCmd::renumber(}}- TUndoManager::manager()->add(new RenumberUndo(sl, fids));+ TUndoManager::manager()->add(+ new RenumberUndo(sl, fids, forceCallUpdateXSheet));+ if (Preferences::instance()->isSyncLevelRenumberWithXsheetEnabled() ||+ forceCallUpdateXSheet) {+ updateXSheet(sl, oldFrames, fids);+ }sl->renumber(fids);sl->setDirtyFlag(true);TApp::instance()->getCurrentScene()->setDirtyFlag(true);@@ -1334,6 +1429,8 @@ void FilmstripCmd::renumber(TXshSimpleLevel *sl, std::set<TFrameId> &frames,if (startFrame <= 0 || stepFrame <= 0 || frames.empty()) return;std::vector<TFrameId> fids;+ std::vector<TFrameId> oldFrames;+ sl->getFids(oldFrames);sl->getFids(fids);std::set<TFrameId> modifiedFids;@@ -1369,6 +1466,9 @@ void FilmstripCmd::renumber(TXshSimpleLevel *sl, std::set<TFrameId> &frames,}}TUndoManager::manager()->add(new RenumberUndo(sl, fids));+ if (Preferences::instance()->isSyncLevelRenumberWithXsheetEnabled()) {+ updateXSheet(sl, oldFrames, fids);+ }sl->renumber(fids);sl->setDirtyFlag(true);TApp::instance()->getCurrentScene()->setDirtyFlag(true);@@ -1615,6 +1715,7 @@ class UndoInsertEmptyFrames final : public TUndo {TXshSimpleLevelP m_level;std::vector<TFrameId> m_oldFrames;std::set<TFrameId> m_frames;+ bool m_updateXSheet;public:UndoInsertEmptyFrames(const TXshSimpleLevelP &level,@@ -1628,20 +1729,27 @@ public:// TImageCache::instance()->add("UndoInsertEmptyFrames"+QString::number((UINT)this),// img);TImageCache::instance()->add(- "UndoInsertEmptyFrames" + QString::number((uintptr_t)this), img);+ "UndoInsertEmptyFrames" + QString::number((uintptr_t) this), img);}}+ m_updateXSheet =+ Preferences::instance()->isSyncLevelRenumberWithXsheetEnabled();}~UndoInsertEmptyFrames() {// TImageCache::instance()->remove("UndoInsertEmptyFrames"+QString::number((UINT)this));TImageCache::instance()->remove("UndoInsertEmptyFrames" +- QString::number((uintptr_t)this));+ QString::number((uintptr_t) this));}void undo() const override {removeFramesWithoutUndo(m_level, m_frames);assert(m_oldFrames.size() == m_level->getFrameCount());+ if (m_updateXSheet) {+ std::vector<TFrameId> newFrames;+ m_level->getFids(newFrames);+ updateXSheet(m_level.getPointer(), newFrames, m_oldFrames);+ }m_level->renumber(m_oldFrames);invalidateIcons(m_level.getPointer(), m_oldFrames);TApp::instance()->getCurrentLevel()->notifyLevelChange();@@ -1658,7 +1766,7 @@ public:// (TToonzImageP)TImageCache::instance()->get("UndoInsertEmptyFrames"+QString::number((UINT)this),// true);TToonzImageP image = (TToonzImageP)TImageCache::instance()->get(- "UndoInsertEmptyFrames" + QString::number((uintptr_t)this), true);+ "UndoInsertEmptyFrames" + QString::number((uintptr_t) this), true);if (!image) return;for (it = m_frames.begin(); it != m_frames.end(); ++it)m_level->setFrame(*it, image);@@ -1707,6 +1815,8 @@ void performReverse(const TXshSimpleLevelP &sl,if (!sl || frames.empty()) return;std::vector<TFrameId> fids;+ std::vector<TFrameId> oldFrames;+ sl->getFids(oldFrames);sl->getFids(fids);int i = 0, j = (int)fids.size() - 1;for (;;) {@@ -1717,6 +1827,9 @@ void performReverse(const TXshSimpleLevelP &sl,i++;j--;}+ if (Preferences::instance()->isSyncLevelRenumberWithXsheetEnabled()) {+ updateXSheet(sl.getPointer(), oldFrames, fids);+ }sl->renumber(fids);sl->setDirtyFlag(true);// TApp::instance()->getCurrentScene()->setDirtyFlag(true);@@ -1859,6 +1972,8 @@ void stepFilmstripFrames(const TXshSimpleLevelP &sl,std::vector<TFrameId> fids;std::set<TFrameId> changedFids;std::vector<int> insertIndices;+ std::vector<TFrameId> oldFrames;+ sl->getFids(oldFrames);sl->getFids(fids);int i, offset = 0;for (i = 0; i < (int)fids.size(); i++) {@@ -1873,6 +1988,9 @@ void stepFilmstripFrames(const TXshSimpleLevelP &sl,offset += step - 1;}}+ if (Preferences::instance()->isSyncLevelRenumberWithXsheetEnabled()) {+ updateXSheet(sl.getPointer(), oldFrames, fids);+ }sl->renumber(fids);for (i = 0; i < (int)insertIndices.size(); i++) {int j = insertIndices[i];@@ -1898,6 +2016,7 @@ class StepFilmstripUndo final : public TUndo {std::set<TFrameId> m_frames;std::vector<TFrameId> m_oldFrames;int m_step;+ bool m_updateXSheet;public:StepFilmstripUndo(const TXshSimpleLevelP &level,@@ -1909,11 +2028,18 @@ public:std::set<TFrameId>::const_iterator it;for (it = frames.begin(); it != frames.end(); ++it)for (int j = 1; j < step; j++) m_insertedFrames.insert(*it + (++d));+ m_updateXSheet =+ Preferences::instance()->isSyncLevelRenumberWithXsheetEnabled();}void undo() const override {removeFramesWithoutUndo(m_level, m_insertedFrames);std::set<TFrameId>::const_iterator it = m_frames.begin();+ if (m_updateXSheet) {+ std::vector<TFrameId> newFrames;+ m_level->getFids(newFrames);+ updateXSheet(m_level.getPointer(), newFrames, m_oldFrames);+ }m_level->renumber(m_oldFrames);TSelection *selection = TSelection::getCurrent();if (selection) selection->selectNone();@@ -2059,6 +2185,7 @@ class UndoDuplicateDrawing final : public TUndo {std::set<TFrameId> m_frameInserted;std::vector<TFrameId> m_oldFrames;std::set<TFrameId> m_framesForRedo;+ bool m_updateXSheet;public:UndoDuplicateDrawing(const TXshSimpleLevelP &level,@@ -2068,11 +2195,19 @@ public:: m_level(level), m_oldFrames(oldFrames), m_frameInserted(frameInserted)- , m_framesForRedo(framesForRedo) {}+ , m_framesForRedo(framesForRedo) {+ m_updateXSheet =+ Preferences::instance()->isSyncLevelRenumberWithXsheetEnabled();+ }void undo() const override {assert(m_level);removeFramesWithoutUndo(m_level, m_frameInserted);+ if (m_updateXSheet) {+ std::vector<TFrameId> newFrames;+ m_level->getFids(newFrames);+ updateXSheet(m_level.getPointer(), newFrames, m_oldFrames);+ }m_level->renumber(m_oldFrames);invalidateIcons(m_level.getPointer(), m_oldFrames);TApp::instance()->getCurrentLevel()->notifyLevelChange();@@ -2400,6 +2535,8 @@ void FilmstripCmd::renumberDrawing(TXshSimpleLevel *sl, const TFrameId &oldFid,const TFrameId &desiredNewFid) {if (oldFid == desiredNewFid) return;std::vector<TFrameId> fids;+ std::vector<TFrameId> oldFrames;+ sl->getFids(oldFrames);sl->getFids(fids);std::vector<TFrameId>::iterator it =std::find(fids.begin(), fids.end(), oldFid);@@ -2415,28 +2552,11 @@ void FilmstripCmd::renumberDrawing(TXshSimpleLevel *sl, const TFrameId &oldFid,newFid = TFrameId(newFid.getNumber(), letter);}*it = newFid;+ if (Preferences::instance()->isSyncLevelRenumberWithXsheetEnabled()) {+ updateXSheet(sl, oldFrames, fids);+ }sl->renumber(fids);- TXshCell oldCell(sl, oldFid);- TXshCell newCell(sl, newFid);-- TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();- for (int c = 0; c < xsh->getColumnCount(); c++) {- int r0, r1;- int n = xsh->getCellRange(c, r0, r1);- if (n > 0) {- std::vector<TXshCell> cells(n);- xsh->getCells(r0, c, n, &cells[0]);- bool changed = false;- for (int i = 0; i < n; i++) {- if (cells[i] == oldCell) {- changed = true;- cells[i] = newCell;- }- }- if (changed) xsh->setCells(r0, c, n, &cells[0]);- }- }TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();TApp::instance()->getCurrentLevel()->notifyLevelChange();TApp::instance()->getCurrentScene()->setDirtyFlag(true);diff --git a/toonz/sources/toonz/filmstripcommand.h b/toonz/sources/toonz/filmstripcommand.hindex b2cae3956..b15355ca3 100644--- a/toonz/sources/toonz/filmstripcommand.h+++ b/toonz/sources/toonz/filmstripcommand.h@@ -23,7 +23,8 @@ void addFrames(TXshSimpleLevel *sl, int start, int end, int step);void renumber(TXshSimpleLevel *sl, std::set<TFrameId> &frames, int startFrame,int stepFrame);void renumber(TXshSimpleLevel *sl,- const std::vector<std::pair<TFrameId, TFrameId>> &table);+ const std::vector<std::pair<TFrameId, TFrameId>> &table,+ bool forceCallUpdateXSheet = false);void copy(TXshSimpleLevel *sl, std::set<TFrameId> &frames);void paste(TXshSimpleLevel *sl, std::set<TFrameId> &frames);diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cppindex 068c1408b..385888986 100644--- a/toonz/sources/toonz/preferencespopup.cpp+++ b/toonz/sources/toonz/preferencespopup.cpp@@ -1075,6 +1075,12 @@ void PreferencesPopup::onShowXSheetToolbarClicked(bool checked) {//-----------------------------------------------------------------------------+void PreferencesPopup::onSyncLevelRenumberWithXsheetChanged(int checked) {+ m_pref->enableSyncLevelRenumberWithXsheet(checked);+}++//-----------------------------------------------------------------------------+void PreferencesPopup::onExpandFunctionHeaderClicked(bool checked) {m_pref->enableExpandFunctionHeader(checked);}@@ -1356,11 +1362,14 @@ PreferencesPopup::PreferencesPopup()m_showXSheetToolbar = new QGroupBox(tr("Show Toolbar in the XSheet "), this);m_showXSheetToolbar->setCheckable(true);m_expandFunctionHeader = new CheckBox(- tr("Expand Function Editor Header to Match XSheet Toolbar Height "+ tr("Expand Function Editor Header to Match Xsheet Toolbar Height ""(Requires Restart)"),this);CheckBox *showColumnNumbersCB =new CheckBox(tr("Show Column Numbers in Column Headers"), this);+ m_syncLevelRenumberWithXsheet = new CheckBox(+ tr("Sync Level Strip Drawing Number Changes with the Xsheet"));+QStringList xsheetLayouts;// options should not be translatable as they are used as key stringsxsheetLayouts << "Classic"@@ -1705,6 +1714,8 @@ PreferencesPopup::PreferencesPopup()m_showXSheetToolbar->setChecked(m_pref->isShowXSheetToolbarEnabled());m_expandFunctionHeader->setChecked(m_pref->isExpandFunctionHeaderEnabled());showColumnNumbersCB->setChecked(m_pref->isShowColumnNumbersEnabled());+ m_syncLevelRenumberWithXsheet->setChecked(+ m_pref->isSyncLevelRenumberWithXsheetEnabled());showCurrentTimelineCB->setChecked(m_pref->isCurrentTimelineIndicatorEnabled());@@ -2242,15 +2253,15 @@ PreferencesPopup::PreferencesPopup()xsheetFrameLay->addWidget(m_showXSheetToolbar, 9, 0, 3, 3);xsheetFrameLay->addWidget(showColumnNumbersCB, 12, 0, 1, 2);- xsheetFrameLay->addWidget(showCurrentTimelineCB, 13, 0, 1, 2);+ xsheetFrameLay->addWidget(m_syncLevelRenumberWithXsheet, 13, 0, 1, 2);+ xsheetFrameLay->addWidget(showCurrentTimelineCB, 14, 0, 1, 2);}xsheetFrameLay->setColumnStretch(0, 0);xsheetFrameLay->setColumnStretch(1, 0);xsheetFrameLay->setColumnStretch(2, 1);- xsheetFrameLay->setRowStretch(14, 1);+ xsheetFrameLay->setRowStretch(15, 1);xsheetBoxFrameLay->addLayout(xsheetFrameLay);-xsheetBoxFrameLay->addStretch(1);xsheetBoxFrameLay->addWidget(note_xsheet, 0);@@ -2648,6 +2659,10 @@ PreferencesPopup::PreferencesPopup()ret = ret && connect(showColumnNumbersCB, SIGNAL(stateChanged(int)), this,SLOT(onShowColumnNumbersChanged(int)));++ ret = ret && connect(m_syncLevelRenumberWithXsheet, SIGNAL(stateChanged(int)),+ this, SLOT(onSyncLevelRenumberWithXsheetChanged(int)));+ret = ret && connect(xsheetLayoutOptions,SIGNAL(currentIndexChanged(const QString &)), this,SLOT(onXsheetLayoutChanged(const QString &)));diff --git a/toonz/sources/toonz/preferencespopup.h b/toonz/sources/toonz/preferencespopup.hindex 47912c5aa..6cdcb192a 100644--- a/toonz/sources/toonz/preferencespopup.h+++ b/toonz/sources/toonz/preferencespopup.h@@ -43,7 +43,7 @@ private:private:Preferences *m_pref;-+FormatProperties *m_formatProperties;DVGui::ColorField *m_blankColor, *m_frontOnionColor, *m_backOnionColor,@@ -76,7 +76,8 @@ private:*m_onionSkinDuringPlayback, *m_autoSaveSceneCB, *m_autoSaveOtherFilesCB,*m_useNumpadForSwitchingStyles, *m_expandFunctionHeader,*m_useHigherDpiOnVectorSimplifyCB, *m_keepFillOnVectorSimplifyCB,- *m_newLevelToCameraSizeCB, *m_ignoreImageDpiCB;+ *m_newLevelToCameraSizeCB, *m_ignoreImageDpiCB,+ *m_syncLevelRenumberWithXsheet;DVGui::FileField *m_customProjectRootFileField;@@ -186,6 +187,7 @@ private slots:void onFastRenderPathChanged();void onUseNumpadForSwitchingStylesClicked(bool);void onShowXSheetToolbarClicked(bool);+ void onSyncLevelRenumberWithXsheetChanged(int);void onExpandFunctionHeaderClicked(bool);void onShowColumnNumbersChanged(int);void onUseArrowKeyToShiftCellSelectionClicked(int);diff --git a/toonz/sources/toonzlib/preferences.cpp b/toonz/sources/toonzlib/preferences.cppindex fcb46bf23..dd95bd3e9 100644--- a/toonz/sources/toonzlib/preferences.cpp+++ b/toonz/sources/toonzlib/preferences.cpp@@ -320,6 +320,7 @@ Preferences::Preferences(), m_useNumpadForSwitchingStyles(true), m_newLevelSizeToCameraSizeEnabled(false), m_showXSheetToolbar(false)+ , m_syncLevelRenumberWithXsheet(false), m_expandFunctionHeader(false), m_showColumnNumbers(false), m_useArrowKeyToShiftCellSelection(false)@@ -634,6 +635,8 @@ Preferences::Preferences()getValue(*m_settings, "newLevelSizeToCameraSizeEnabled",m_newLevelSizeToCameraSizeEnabled);getValue(*m_settings, "showXSheetToolbar", m_showXSheetToolbar);+ getValue(*m_settings, "syncLevelRenumberWithXsheet",+ m_syncLevelRenumberWithXsheet);getValue(*m_settings, "expandFunctionHeader", m_expandFunctionHeader);getValue(*m_settings, "showColumnNumbers", m_showColumnNumbers);getValue(*m_settings, "useArrowKeyToShiftCellSelection",@@ -1535,6 +1538,13 @@ void Preferences::enableShowXSheetToolbar(bool on) {//-----------------------------------------------------------------+void Preferences::enableSyncLevelRenumberWithXsheet(bool on) {+ m_syncLevelRenumberWithXsheet = on;+ m_settings->setValue("syncLevelRenumberWithXsheet", on ? "1" : "0");+}++//-----------------------------------------------------------------+void Preferences::enableExpandFunctionHeader(bool on) {m_expandFunctionHeader = on;m_settings->setValue("expandFunctionHeader", on ? "1" : "0");