diff --git a/toonz/sources/include/toonz/preferences.h b/toonz/sources/include/toonz/preferences.h index 572598f115..96c12a963a 100644 --- a/toonz/sources/include/toonz/preferences.h +++ b/toonz/sources/include/toonz/preferences.h @@ -403,6 +403,11 @@ class DVAPI Preferences final : public QObject // singleton 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; @@ -569,7 +574,8 @@ class DVAPI Preferences final : public QObject // singleton 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.cpp index 9b7307bf6a..cdf26abf72 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 @@ class InsertUndo final : public TUndo { // RenumberUndo //----------------------------------------------------------------------------- -class RenumberUndo final : public TUndo { - std::map m_undoTable, m_redoTable; - +class RenumberUndo { public: class RedoNotifier; class UndoNotifier; - -public: - RenumberUndo(const std::map &cellsMap) - : m_redoTable(cellsMap) { - // Invert the redo table to obtain the undo table - std::map::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 &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 cells(n); - xsh->getCells(r0, c, n, &cells[0]); - for (int i = 0; i < n; i++) { - std::map::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 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 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 @@ class VectorToVectorUndo final : public TUndo { , 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 undo std::vector 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.cpp index 23af794e2a..7237d3d907 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 oldFids, + std::vector newFids, TXsheet *xsh, + std::vector &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 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 oldFids, + std::vector newFids) { + std::vector 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 &framesToInsert) { std::vector fids; + std::vector oldFids; sl->getFids(fids); + sl->getFids(oldFids); std::set::const_iterator it; std::set 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 @@ class PasteFramesUndo final : public TUndo { QMimeData *data = cloneData(clipboard->mimeData()); m_newData = dynamic_cast(data); assert(m_newData); + m_updateXSheet = + Preferences::instance()->isSyncLevelRenumberWithXsheetEnabled(); } ~PasteFramesUndo() { @@ -916,6 +980,11 @@ class PasteFramesUndo final : public TUndo { // Renumero i frame con i vecchi fids if (m_setType == DrawingData::INSERT) { assert(m_sl->getFrameCount() == m_oldLevelFrameId.size()); + if (m_updateXSheet) { + std::vector 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 m_insertedFids; std::vector m_oldFids; + bool m_updateXSheet; public: AddFramesUndo(const TXshSimpleLevelP &level, const std::set insertedFids, std::vector 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 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 m_fids; std::map m_mapOldFrameId; + bool m_updateXSheet = false; public: - RenumberUndo(const TXshSimpleLevelP &level, const std::vector &fids) + RenumberUndo(const TXshSimpleLevelP &level, const std::vector &fids, + bool forceCallUpdateXSheet = false) : m_level(level), m_fids(fids) { assert(m_level); std::vector oldFids; @@ -1217,8 +1297,16 @@ class RenumberUndo final : public TUndo { 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 fids) const { + if (m_updateXSheet) { + std::vector 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 @@ class RenumberUndo final : public TUndo { void FilmstripCmd::renumber( TXshSimpleLevel *sl, - const std::vector> &table) { + const std::vector> &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 fids, rfids; + std::vector fids, rfids, oldFrames; sl->getFids(fids); + sl->getFids(oldFrames); std::set 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 &frames, if (startFrame <= 0 || stepFrame <= 0 || frames.empty()) return; std::vector fids; + std::vector oldFrames; + sl->getFids(oldFrames); sl->getFids(fids); std::set modifiedFids; @@ -1369,6 +1466,9 @@ void FilmstripCmd::renumber(TXshSimpleLevel *sl, std::set &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 m_oldFrames; std::set m_frames; + bool m_updateXSheet; public: UndoInsertEmptyFrames(const TXshSimpleLevelP &level, @@ -1628,20 +1729,27 @@ class UndoInsertEmptyFrames final : public TUndo { // 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 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 @@ class UndoInsertEmptyFrames final : public TUndo { // (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 fids; + std::vector 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 fids; std::set changedFids; std::vector insertIndices; + std::vector 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 m_frames; std::vector m_oldFrames; int m_step; + bool m_updateXSheet; public: StepFilmstripUndo(const TXshSimpleLevelP &level, @@ -1909,11 +2028,18 @@ class StepFilmstripUndo final : public TUndo { std::set::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::const_iterator it = m_frames.begin(); + if (m_updateXSheet) { + std::vector 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 m_frameInserted; std::vector m_oldFrames; std::set m_framesForRedo; + bool m_updateXSheet; public: UndoDuplicateDrawing(const TXshSimpleLevelP &level, @@ -2068,11 +2195,19 @@ class UndoDuplicateDrawing final : public TUndo { : 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 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 fids; + std::vector oldFrames; + sl->getFids(oldFrames); sl->getFids(fids); std::vector::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 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.h index b2cae39562..b15355ca33 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 &frames, int startFrame, int stepFrame); void renumber(TXshSimpleLevel *sl, - const std::vector> &table); + const std::vector> &table, + bool forceCallUpdateXSheet = false); void copy(TXshSimpleLevel *sl, std::set &frames); void paste(TXshSimpleLevel *sl, std::set &frames); diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp index 258dde5378..15cd2f4a18 100644 --- a/toonz/sources/toonz/preferencespopup.cpp +++ b/toonz/sources/toonz/preferencespopup.cpp @@ -341,10 +341,10 @@ void PreferencesPopup::onRoomChoiceChanged(int index) { //----------------------------------------------------------------------------- void PreferencesPopup::onDropdownShortcutsCycleOptionsChanged(int index) { - m_pref->setDropdownShortcutsCycleOptions(index); + m_pref->setDropdownShortcutsCycleOptions(index); } - //----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void PreferencesPopup::onInterfaceFontChanged(int index) { QString font = m_interfaceFont->currentText(); @@ -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); } @@ -1346,11 +1352,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; xsheetLayouts << tr("Classic") << tr("Classic-revised") << tr("Compact"); QComboBox *xsheetLayoutOptions = new QComboBox(this); @@ -1683,6 +1692,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()); @@ -2208,15 +2219,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); @@ -2611,6 +2622,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.h index 522cde86e2..a86fa6ad73 100644 --- a/toonz/sources/toonz/preferencespopup.h +++ b/toonz/sources/toonz/preferencespopup.h @@ -43,7 +43,7 @@ class PreferencesPopup final : public QDialog { private: Preferences *m_pref; - + FormatProperties *m_formatProperties; DVGui::ColorField *m_blankColor, *m_frontOnionColor, *m_backOnionColor, @@ -57,7 +57,6 @@ class PreferencesPopup final : public QDialog { *m_vectorSnappingTargetCB, *m_dropdownShortcutsCycleOptionsCB, *m_interfaceFont, *m_interfaceFontWeight, *m_guidedDrawingStyle; - DVGui::MeasuredDoubleLineEdit *m_defLevelWidth, *m_defLevelHeight; DVGui::DoubleLineEdit *m_defLevelDpi; @@ -77,7 +76,8 @@ class PreferencesPopup final : public QDialog { *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; @@ -187,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.cpp index 38b06d13e8..d27f175e24 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) @@ -633,6 +634,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", @@ -1531,6 +1534,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");