diff --git a/toonz/sources/stopmotion/stopmotion.cpp b/toonz/sources/stopmotion/stopmotion.cpp index 95817098..f3f35f15 100644 --- a/toonz/sources/stopmotion/stopmotion.cpp +++ b/toonz/sources/stopmotion/stopmotion.cpp @@ -523,6 +523,66 @@ void StopMotion::jumpToCameraFrame() { //----------------------------------------------------------------- +void StopMotion::removeStopMotionFrame() { + if (m_xSheetFrameNumber == 1) return; + TApp* app = TApp::instance(); + ToonzScene* scene = app->getCurrentScene()->getScene(); + TXsheet* xsh = scene->getXsheet(); + + int row = m_xSheetFrameNumber - 2; + + // find which column the level is on. + // check with the current column first + int col = app->getCurrentColumn()->getColumnIndex(); + TXshCell cell = xsh->getCell(row, col); + TXshSimpleLevelP sl; + bool found = false; + if (!cell.isEmpty()) { + if (cell.getSimpleLevel() != 0) { + sl = cell.getSimpleLevel(); + if (sl.getPointer()->getName() == m_levelName.toStdWString()) { + found = true; + } + } + } + + if (!found) { + + int cols = xsh->getColumnCount(); + for (int i = 0; i < cols; i++) { + cell = xsh->getCell(row, i); + if (!cell.isEmpty()) { + if (cell.getSimpleLevel() != 0) { + sl = cell.getSimpleLevel(); + if (sl.getPointer()->getName() == m_levelName.toStdWString()) { + found = true; + col = i; + break; + } + } + } + } + } + if (!found) { + //DVGui::error(tr("Could not find an xsheet level with the current level")); + return; + } + + TXshCellColumn* xshCellColumn = xsh->getColumn(col)->getCellColumn(); + if (!xshCellColumn) return; + + int oldColRowCount = xshCellColumn->getMaxFrame() + 1; + xshCellColumn->removeCells(row, 1); + + app->getCurrentScene()->getScene()->getXsheet()->updateFrameCount(); + setXSheetFrameNumber(m_xSheetFrameNumber - 1); + app->getCurrentFrame()->prevFrame(); + app->getCurrentScene()->notifySceneChanged(); + app->getCurrentXsheet()->notifyXsheetChanged(); +} + +//----------------------------------------------------------------- + void StopMotion::setUseNumpadShortcuts(bool on) { m_useNumpadShortcuts = on; StopMotionUseNumpad = int(on); @@ -584,6 +644,13 @@ void StopMotion::toggleNumpadShortcuts(bool on) { std::pair(shortcut, action)); action = NULL; } + shortcut = "Backspace"; + action = comm->getActionFromShortcut(shortcut); + if (action) { + m_oldActionMap.insert( + std::pair(shortcut, action)); + action = NULL; + } shortcut = "Return"; action = comm->getActionFromShortcut(shortcut); if (action) { @@ -647,6 +714,11 @@ void StopMotion::toggleNumpadShortcuts(bool on) { action->setShortcut(QKeySequence("Return")); action = NULL; } + action = comm->getAction(MI_StopMotionRemoveFrame); + if (action) { + action->setShortcut(QKeySequence("Backspace")); + action = NULL; + } action = comm->getAction(MI_StopMotionToggleLiveView); if (action) { action->setShortcut(QKeySequence("5")); @@ -744,6 +816,12 @@ void StopMotion::toggleNumpadShortcuts(bool on) { QKeySequence(comm->getShortcutFromAction(action).c_str())); action = NULL; } + action = comm->getAction(MI_StopMotionRemoveFrame); + if (action) { + action->setShortcut( + QKeySequence(comm->getShortcutFromAction(action).c_str())); + action = NULL; + } // now put back the old shortcuts auto it = m_oldActionMap.begin(); @@ -4658,6 +4736,18 @@ public: } } StopMotionExportImageSequence; +//============================================================================= + +class StopMotionRemoveFrame : public MenuItemHandler { +public: + StopMotionRemoveFrame() + : MenuItemHandler(MI_StopMotionRemoveFrame) {} + void execute() { + StopMotion* sm = StopMotion::instance(); + sm->removeStopMotionFrame(); + } +} StopMotionRemoveFrame; + #if WITH_CANON //============================================================================= diff --git a/toonz/sources/stopmotion/stopmotion.h b/toonz/sources/stopmotion/stopmotion.h index 30bc73cc..902ddd97 100644 --- a/toonz/sources/stopmotion/stopmotion.h +++ b/toonz/sources/stopmotion/stopmotion.h @@ -247,6 +247,7 @@ public: void raiseOpacity(); void lowerOpacity(); void jumpToCameraFrame(); + void removeStopMotionFrame(); std::string getTEnvCameraName(); void setTEnvCameraName(std::string name); diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cpp index cf28548b..b2e9337c 100644 --- a/toonz/sources/toonz/mainwindow.cpp +++ b/toonz/sources/toonz/mainwindow.cpp @@ -2379,6 +2379,7 @@ void MainWindow::defineActions() { tr("Raise Stop Motion Level Subsampling"), ""); createAction(MI_StopMotionJumpToCamera, tr("Go to Stop Motion Insert Frame"), ""); + createAction(MI_StopMotionRemoveFrame, tr("Remove frame before Stop Motion Camera"), ""); } //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonz/menubarcommandids.h b/toonz/sources/toonz/menubarcommandids.h index de046392..0c9ce9e3 100644 --- a/toonz/sources/toonz/menubarcommandids.h +++ b/toonz/sources/toonz/menubarcommandids.h @@ -363,6 +363,7 @@ #define MI_StopMotionJumpToCamera "MI_StopMotionJumpToCamera" #define MI_StopMotionPickFocusCheck "MI_StopMotionPickFocusCheck" #define MI_StopMotionExportImageSequence "MI_StopMotionExportImageSequence" +#define MI_StopMotionRemoveFrame "MI_StopMotionRemoveFrame" #define MI_OpenOnlineManual "MI_OpenOnlineManual" #define MI_OpenWhatsNew "MI_OpenWhatsNew"