Add remove cell command

This commit is contained in:
Jeremy Bullock 2020-04-11 22:11:49 -06:00
parent 5398fb265b
commit de1b6557f6
4 changed files with 93 additions and 0 deletions

View file

@ -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<std::string, QAction *>(shortcut, action));
action = NULL;
}
shortcut = "Backspace";
action = comm->getActionFromShortcut(shortcut);
if (action) {
m_oldActionMap.insert(
std::pair<std::string, QAction*>(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
//=============================================================================

View file

@ -247,6 +247,7 @@ public:
void raiseOpacity();
void lowerOpacity();
void jumpToCameraFrame();
void removeStopMotionFrame();
std::string getTEnvCameraName();
void setTEnvCameraName(std::string name);

View file

@ -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"), "");
}
//-----------------------------------------------------------------------------

View file

@ -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"