diff --git a/toonz/sources/include/toonz/tstageobjecttree.h b/toonz/sources/include/toonz/tstageobjecttree.h index 03d6f00..44d94cc 100644 --- a/toonz/sources/include/toonz/tstageobjecttree.h +++ b/toonz/sources/include/toonz/tstageobjecttree.h @@ -6,6 +6,7 @@ #include #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.h index 3268d02..6dbced4 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.cpp index 2b8002b..637d698 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.cpp index 7e49697..1773777 100644 --- a/toonz/sources/toonz/keyframedata.cpp +++ b/toonz/sources/toonz/keyframedata.cpp @@ -118,9 +118,7 @@ bool TKeyframeData::getKeyframes(std::set &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.cpp index f3c9985..1b35b1e 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 positions; std::set::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.cpp index 8187f38..92e5b7d 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.cpp index 6426177..6a0d37a 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 button p.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 button else 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 button else 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-steps diff --git a/toonz/sources/toonz/xsheetcmd.cpp b/toonz/sources/toonz/xsheetcmd.cpp index fce4317..dbd4b30 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 + else objectId = 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 + else objectId = 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.cpp index 7dedef5..9733642 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.cpp index e0b02bd..96966b9 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(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::iterator it; std::map &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.cpp index 4d4982a..2dcd054 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 selezione bool 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 selezione bool 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 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(); }