OpenToonz - An open-source full-featured 2D animation creation software
C
Enable lock on camera column
manongjohn4334db09bc53
diff --git a/toonz/sources/include/toonz/tstageobjecttree.h b/toonz/sources/include/toonz/tstageobjecttree.hindex 03d6f0054..44d94ccdb 100644--- a/toonz/sources/include/toonz/tstageobjecttree.h+++ b/toonz/sources/include/toonz/tstageobjecttree.h@@ -6,6 +6,7 @@#include <memory>#include "toonz/tstageobject.h"+#include "toonz/txsheet.h"#undef DVAPI#undef DVVAR@@ -141,14 +142,15 @@ TStageObjectId \b \e id.Retrieves object's data from a tagged data stream \b \e is.\sa saveData()*/- void loadData(TIStream &is) override;- /*!- Saves object's data (name, center coords, etc ) to a tagged data- stream \b \e os saved on a file.- This method call iteratively all stage objects in the tree and save- their data.- */- void saveData(TOStream &os, int occupiedColumnCount);+ void loadData(TIStream &is, TXsheet *xsh);+ void loadData(TIStream &is) override{}; // not used+ /*!+ Saves object's data (name, center coords, etc ) to a tagged data+ stream \b \e os saved on a file.+ This method call iteratively all stage objects in the tree and save+ their data.+ */+ void saveData(TOStream &os, int occupiedColumnCount, TXsheet *xsh);void saveData(TOStream &os) override{}; // not used/*!Returns the numbers of the objects in the tree.diff --git a/toonz/sources/include/toonz/txsheet.h b/toonz/sources/include/toonz/txsheet.hindex 3268d028d..6dbced4d6 100644--- a/toonz/sources/include/toonz/txsheet.h+++ b/toonz/sources/include/toonz/txsheet.h@@ -157,6 +157,7 @@ private:SoundProperties *m_soundProperties;int m_cameraColumnIndex;+ TXshColumn *m_cameraColumn;DECLARE_CLASS_CODE@@ -562,6 +563,9 @@ in TXsheetImp.void setCameraColumnIndex(int index) { m_cameraColumnIndex = index; }int getCameraColumnIndex() { return m_cameraColumnIndex; }+ void setCameraColumnLocked(bool locked) { m_cameraColumn->lock(locked); }+ bool isCameraColumnLocked() { return m_cameraColumn->isLocked(); }+protected:bool checkCircularReferences(TXsheet *childCandidate);diff --git a/toonz/sources/toonz/columncommand.cpp b/toonz/sources/toonz/columncommand.cppindex 2b8002ba6..637d698c7 100644--- a/toonz/sources/toonz/columncommand.cpp+++ b/toonz/sources/toonz/columncommand.cpp@@ -36,6 +36,7 @@#include "toonz/tcamera.h"#include "toonz/tstageobjectspline.h"#include "toonz/fxcommand.h"+#include "toonz/preferences.h"// TnzBase includes#include "tfx.h"@@ -1249,9 +1250,12 @@ public:TTool::Viewer *viewer = tool ? tool->getViewer() : nullptr;bool viewer_changed = false;- for (int i = 0; i < xsh->getColumnCount(); i++) {+ int startCol =+ Preferences::instance()->isXsheetCameraColumnEnabled() ? -1 : 0;++ for (int i = startCol; i < xsh->getColumnCount(); i++) {/*- 空のカラムの場合は飛ばす -*/- if (xsh->isColumnEmpty(i)) continue;+ if (i >= 0 && xsh->isColumnEmpty(i)) continue;/*- カラムが取得できなかったら飛ばす -*/TXshColumn *column = xsh->getColumn(i);if (!column) continue;diff --git a/toonz/sources/toonz/keyframedata.cpp b/toonz/sources/toonz/keyframedata.cppindex 7e49697ff..1773777f2 100644--- a/toonz/sources/toonz/keyframedata.cpp+++ b/toonz/sources/toonz/keyframedata.cpp@@ -118,9 +118,7 @@ bool TKeyframeData::getKeyframes(std::set<Position> &positions,if (column && column->getSoundColumn()) continue;TStageObject *pegbar = xsh->getStageObject(col >= 0 ? TStageObjectId::ColumnId(col) : cameraId);- if (pegbar->getId().isColumn() && xsh->getColumn(col) &&- xsh->getColumn(col)->isLocked())- continue;+ if (xsh->getColumn(col) && xsh->getColumn(col)->isLocked()) continue;keyFrameChanged = true;assert(pegbar);diff --git a/toonz/sources/toonz/keyframeselection.cpp b/toonz/sources/toonz/keyframeselection.cppindex f3c9985c5..1b35b1e35 100644--- a/toonz/sources/toonz/keyframeselection.cpp+++ b/toonz/sources/toonz/keyframeselection.cpp@@ -104,9 +104,7 @@ bool deleteKeyframesWithoutUndo(int col = it->second;TStageObject *pegbar = xsh->getStageObject(col >= 0 ? TStageObjectId::ColumnId(col) : cameraId);- if (pegbar->getId().isColumn() && xsh->getColumn(col) &&- xsh->getColumn(col)->isLocked())- continue;+ if (xsh->getColumn(col) && xsh->getColumn(col)->isLocked()) continue;areAllColumnLocked = false;assert(pegbar);pegbar->removeKeyframeWithoutUndo(row);@@ -255,10 +253,10 @@ void TKeyframeSelection::unselectLockedColumn() {TXsheet *xsh = app->getCurrentXsheet()->getXsheet();std::set<Position> positions;std::set<Position>::iterator it;+for (it = m_positions.begin(); it != m_positions.end(); ++it) {int col = it->second;- if (col >= 0 && xsh->getColumn(col) && xsh->getColumn(col)->isLocked())- continue;+ if (xsh->getColumn(col) && xsh->getColumn(col)->isLocked()) continue;positions.insert(*it);}m_positions.swap(positions);diff --git a/toonz/sources/toonz/layerheaderpanel.cpp b/toonz/sources/toonz/layerheaderpanel.cppindex 8187f3866..92e5b7dd4 100644--- a/toonz/sources/toonz/layerheaderpanel.cpp+++ b/toonz/sources/toonz/layerheaderpanel.cpp@@ -221,8 +221,10 @@ void LayerHeaderPanel::mouseReleaseEvent(QMouseEvent *event) {bool sound_changed = false;if (m_doOnRelease != 0 && totcols > 0) {- for (col = 0; col < totcols; col++) {- if (!xsh->isColumnEmpty(col)) {+ int startCol =+ Preferences::instance()->isXsheetCameraColumnEnabled() ? -1 : 0;+ for (col = startCol; col < totcols; col++) {+ if (startCol < 0 || !xsh->isColumnEmpty(col)) {TXshColumn *column = xsh->getColumn(col);if (m_doOnRelease == ToggleAllPreviewVisible) {diff --git a/toonz/sources/toonz/xshcolumnviewer.cpp b/toonz/sources/toonz/xshcolumnviewer.cppindex 64261779b..6a0d37a0c 100644--- a/toonz/sources/toonz/xshcolumnviewer.cpp+++ b/toonz/sources/toonz/xshcolumnviewer.cpp@@ -553,13 +553,9 @@ ColumnArea::DrawHeader::DrawHeader(ColumnArea *nArea, QPainter &nP, int nCol)o = m_viewer->orientation();app = TApp::instance();xsh = m_viewer->getXsheet();- column = col >= 0 ? xsh->getColumn(col) : 0;- isEmpty = col >= 0 && xsh->isColumnEmpty(col);+ column = xsh->getColumn(col);+ isEmpty = col >= 0 ? xsh->isColumnEmpty(col) : false;- if (col < 0) {- column = TXshColumn::createEmpty(0);- isEmpty = false;- }TStageObjectId currentColumnId = app->getCurrentObject()->getObjectId();// check if the column is current@@ -785,11 +781,6 @@ void ColumnArea::DrawHeader::drawLock() const {// lock buttonp.setPen(m_viewer->getVerticalLineColor());- if (col < 0) {- if (o->flag(PredefinedFlag::LOCK_AREA_BORDER)) p.drawRect(lockModeRect);- return;- }-p.fillRect(lockModeRect, bgColor);if (o->flag(PredefinedFlag::LOCK_AREA_BORDER)) p.drawRect(lockModeRect);@@ -2001,8 +1992,7 @@ void ColumnArea::mousePressEvent(QMouseEvent *event) {// lock buttonelse if (o->rect(PredefinedRect::LOCK_AREA).contains(mouseInCell) &&event->button() == Qt::LeftButton) {- if (m_col >= 0)- m_doOnRelease = isCtrlPressed ? ToggleAllLock : ToggleLock;+ m_doOnRelease = isCtrlPressed ? ToggleAllLock : ToggleLock;}// preview buttonelse if (o->rect(PredefinedRect::EYE_AREA).contains(mouseInCell) &&@@ -2300,7 +2290,9 @@ void ColumnArea::mouseReleaseEvent(QMouseEvent *event) {app->getCurrentXsheet()->notifyXsheetSoundChanged();}} else if (m_doOnRelease == ToggleAllLock) {- for (col = 0; col < totcols; col++) {+ int startCol =+ Preferences::instance()->isXsheetCameraColumnEnabled() ? -1 : 0;+ for (col = startCol; col < totcols; col++) {TXshColumn *column = xsh->getColumn(col);if (!xsh->isColumnEmpty(col)) {column->lock(!column->isLocked());@@ -2448,14 +2440,14 @@ void ColumnArea::contextMenuEvent(QContextMenuEvent *event) {}menu.addSeparator();menu.addAction(cmdManager->getAction(MI_FoldColumns));- QAction *cameraToggle = cmdManager->getAction(MI_ToggleXsheetCameraColumn);- bool cameraVisible = Preferences::instance()->isXsheetCameraColumnEnabled();- if (cameraVisible)- cameraToggle->setText(tr("Hide Camera Column"));- else- cameraToggle->setText(tr("Show Camera Column"));- menu.addAction(cameraToggle);- menu.addSeparator();+ QAction *cameraToggle = cmdManager->getAction(MI_ToggleXsheetCameraColumn);+ bool cameraVisible = Preferences::instance()->isXsheetCameraColumnEnabled();+ if (cameraVisible)+ cameraToggle->setText(tr("Hide Camera Column"));+ else+ cameraToggle->setText(tr("Show Camera Column"));+ menu.addAction(cameraToggle);+ menu.addSeparator();menu.addAction(cmdManager->getAction(MI_ToggleXSheetToolbar));// force the selected cells placed in n-stepsdiff --git a/toonz/sources/toonz/xsheetcmd.cpp b/toonz/sources/toonz/xsheetcmd.cppindex fce43178f..dbd4b3018 100644--- a/toonz/sources/toonz/xsheetcmd.cpp+++ b/toonz/sources/toonz/xsheetcmd.cpp@@ -168,10 +168,10 @@ void InsertSceneFrameUndo::doInsertSceneFrame(int frame) {xsh->insertCells(frame, c);xsh->setCell(frame, c, xsh->getCell(frame + 1, c));-- if (!xsh->getColumn(c) || xsh->getColumn(c)->isLocked()) continue;}+ if (!xsh->getColumn(c) || xsh->getColumn(c)->isLocked()) continue;+if (TStageObject *obj = xsh->getStageObject(objectId))insertFrame(obj, frame);}@@ -191,10 +191,10 @@ void InsertSceneFrameUndo::doRemoveSceneFrame(int frame) {objectId = TStageObjectId::ColumnId(c);xsh->removeCells(frame, c);-- if (!xsh->getColumn(c) || xsh->getColumn(c)->isLocked()) continue;}+ if (!xsh->getColumn(c) || xsh->getColumn(c)->isLocked()) continue;+if (TStageObject *pegbar = xsh->getStageObject(objectId))removeFrame(pegbar, frame);}@@ -362,7 +362,9 @@ void GlobalKeyframeUndo::doInsertGlobalKeyframes(TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();int i, colsCount = columns.size();- for (i = 0; i != colsCount; ++i) {+ int startCol =+ Preferences::instance()->isXsheetCameraColumnEnabled() ? -1 : 0;+ for (i = startCol; i != colsCount; ++i) {TStageObjectId objectId;int c = columns[i];@@ -370,19 +372,14 @@ void GlobalKeyframeUndo::doInsertGlobalKeyframes(TXshColumn *column = xsh->getColumn(c);if (column && column->getSoundColumn()) continue;- if (c == -1) {-#ifdef LINETEST+ if (c == -1)objectId = TStageObjectId::CameraId(xsh->getCameraColumnIndex());-#else- continue;-#endif- } else+ elseobjectId = TStageObjectId::ColumnId(c);TXshColumn *xshColumn = xsh->getColumn(c);- if ((!xshColumn || xshColumn->isLocked() ||- xshColumn->isCellEmpty(frame)) &&- !objectId.isCamera())+ if (!xshColumn || xshColumn->isLocked() ||+ (xshColumn->isCellEmpty(frame) && !objectId.isCamera()))continue;TStageObject *obj = xsh->getStageObject(objectId);@@ -397,6 +394,8 @@ void GlobalKeyframeUndo::doRemoveGlobalKeyframes(TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();int i, colsCount = columns.size();+ int startCol =+ Preferences::instance()->isXsheetCameraColumnEnabled() ? -1 : 0;for (i = 0; i != colsCount; ++i) {TStageObjectId objectId;@@ -405,13 +404,9 @@ void GlobalKeyframeUndo::doRemoveGlobalKeyframes(TXshColumn *column = xsh->getColumn(c);if (column && column->getSoundColumn()) continue;- if (c == -1) {-#ifdef LINETEST+ if (c == -1)objectId = TStageObjectId::CameraId(xsh->getCameraColumnIndex());-#else- continue;-#endif- } else+ elseobjectId = TStageObjectId::ColumnId(c);if (xsh->getColumn(c) && xsh->getColumn(c)->isLocked()) continue;diff --git a/toonz/sources/toonz/xsheetdragtool.cpp b/toonz/sources/toonz/xsheetdragtool.cppindex 7dedef502..9733642c9 100644--- a/toonz/sources/toonz/xsheetdragtool.cpp+++ b/toonz/sources/toonz/xsheetdragtool.cpp@@ -1171,7 +1171,7 @@ public:TStageObjectId::CameraId(xsh->getCameraColumnIndex());TStageObjectId objId = col >= 0 ? TStageObjectId::ColumnId(col) : cameraId;- if (col >= 0 && xsh->getColumn(col) && xsh->getColumn(col)->isLocked()) {+ if (xsh->getColumn(col) && xsh->getColumn(col)->isLocked()) {m_enable = false;return;}diff --git a/toonz/sources/toonzlib/tstageobjecttree.cpp b/toonz/sources/toonzlib/tstageobjecttree.cppindex e0b02bd7b..96966b9d0 100644--- a/toonz/sources/toonzlib/tstageobjecttree.cpp+++ b/toonz/sources/toonzlib/tstageobjecttree.cpp@@ -372,7 +372,7 @@ void TStageObjectTree::swapColumns(int i, int j) {//------------------------------------------------------------------------------void TStageObjectTree::loadData(TIStream &is) {+void TStageObjectTree::loadData(TIStream &is, TXsheet *xsh) {std::string tagName;while (is.matchTag(tagName)) {if (tagName == "splines") {@@ -396,6 +396,9 @@ void TStageObjectTree::loadData(TIStream &is) {m_imp->m_currentPreviewCameraId = id;else if (id.isCamera() && is.getTagAttribute("activeboth") == "yes")m_imp->m_currentPreviewCameraId = m_imp->m_currentCameraId = id;++ if (id.isCamera() && is.getTagAttribute("columnLocked") == "yes")+ xsh->setCameraColumnLocked(true);TStageObject *pegbar =dynamic_cast<TStageObject *>(getStageObject(id, true));@@ -421,7 +424,8 @@ void TStageObjectTree::loadData(TIStream &is) {//------------------------------------------------------------------------------void TStageObjectTree::saveData(TOStream &os, int occupiedColumnCount) {+void TStageObjectTree::saveData(TOStream &os, int occupiedColumnCount,+ TXsheet *xsh) {std::map<TStageObjectId, TStageObject *>::iterator it;std::map<TStageObjectId, TStageObject *> &pegbars = m_imp->m_pegbarTable;if (!m_imp->m_splines.empty()) {@@ -449,6 +453,11 @@ void TStageObjectTree::saveData(TOStream &os, int occupiedColumnCount) {else if (objectId == m_imp->m_currentPreviewCameraId)attr["activepreview"] = "yes";+ if ((objectId == m_imp->m_currentCameraId ||+ objectId == m_imp->m_currentPreviewCameraId) &&+ xsh->isCameraColumnLocked())+ attr["columnLocked"] = "yes";+os.openChild("pegbar", attr);pegbar->saveData(os);diff --git a/toonz/sources/toonzlib/txsheet.cpp b/toonz/sources/toonzlib/txsheet.cppindex 4d4982ad9..2dcd05478 100644--- a/toonz/sources/toonzlib/txsheet.cpp+++ b/toonz/sources/toonzlib/txsheet.cpp@@ -192,6 +192,11 @@ TXsheet::TXsheet()m_imp->m_handleManager = new XshHandleManager(this);m_imp->m_pegTree->setHandleManager(m_imp->m_handleManager);m_imp->m_pegTree->createGrammar(this);++ // Dummy camera column+ m_cameraColumn = TXshColumn::createEmpty(0);+ m_cameraColumn->m_index = -1;+ m_cameraColumn->setXsheet(this);}//-----------------------------------------------------------------------------@@ -774,7 +779,7 @@ void TXsheet::increaseStepCells(int r0, int c0, int &r1, int c1) {// controllo se devo cambiare la selezionebool allIncreaseIsEqual = true;for (c = 0; c < ends.size() - 1 && allIncreaseIsEqual; c++)- allIncreaseIsEqual = allIncreaseIsEqual && ends[c] == ends[c + 1];+ allIncreaseIsEqual = allIncreaseIsEqual && ends[c] == ends[c + 1];if (allIncreaseIsEqual) r1 = ends[0];}@@ -808,7 +813,7 @@ void TXsheet::decreaseStepCells(int r0, int c0, int &r1, int c1) {// controllo se devo cambiare la selezionebool allDecreaseIsEqual = true;for (c = 0; c < ends.size() - 1 && allDecreaseIsEqual; c++)- allDecreaseIsEqual = allDecreaseIsEqual && ends[c] == ends[c + 1];+ allDecreaseIsEqual = allDecreaseIsEqual && ends[c] == ends[c + 1];if (allDecreaseIsEqual) r1 = ends[0];}@@ -1208,7 +1213,7 @@ void TXsheet::loadData(TIStream &is) {}} else if (tagName == "pegbars") {TPersist *p = m_imp->m_pegTree;- is >> *p;+ m_imp->m_pegTree->loadData(is, this);} else if (tagName == "fxnodes") {m_imp->m_fxDag->loadData(is);std::vector<TFx *> fxs;@@ -1263,7 +1268,7 @@ void TXsheet::saveData(TOStream &os) {}os.closeChild();os.openChild("pegbars");- m_imp->m_pegTree->saveData(os, getFirstFreeColumnIndex());+ m_imp->m_pegTree->saveData(os, getFirstFreeColumnIndex(), this);// os << *(m_imp->m_pegTree);os.closeChild();@@ -1369,6 +1374,7 @@ void TXsheet::moveColumn(int srcIndex, int dstIndex) {//-----------------------------------------------------------------------------TXshColumn *TXsheet::getColumn(int col) const {+ if (col < 0) return m_cameraColumn;return m_imp->m_columnSet.getColumn(col).getPointer();}