Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

Add frame navigation past scene end and Insert Blank Drawing

Rodney61f2e6630349
diff --git a/toonz/sources/toonz/cellselection.cpp b/toonz/sources/toonz/cellselection.cpp
index f696ed377..249a08b19 100644
--- a/toonz/sources/toonz/cellselection.cpp
+++ b/toonz/sources/toonz/cellselection.cpp
@@ -421,7 +421,7 @@ public:
class InsertUndo final : public TUndo {
TCellSelection::Range m_range;
- bool m_containsSoundColumn;
+ bool m_containsSoundColumn = false;
public:
InsertUndo(const TCellSelection::Range &range) : m_range(range) {
@@ -2763,7 +2763,8 @@ void TCellSelection::pasteKeyframesInto() {
//-----------------------------------------------------------------------------
-void TCellSelection::createBlankDrawing(int row, int col, bool multiple) {
+static void createBlankDrawingImpl(int row, int col, bool multiple,
+ bool insert) {
TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
if (col < 0) {
@@ -2780,7 +2781,9 @@ void TCellSelection::createBlankDrawing(int row, int col, bool multiple) {
}
TApp::instance()->getCurrentColumn()->setColumnIndex(col);
- TApp::instance()->getCurrentFrame()->setCurrentFrame(row + 1);
+ // Validate the level preceding an inserted cell, rather than the drawing
+ // that will be shifted down. Insertion is only requested after a hold.
+ TApp::instance()->getCurrentFrame()->setCurrentFrame(insert ? row : row + 1);
TXshLevel *level = TApp::instance()->getCurrentLevel()->getLevel();
if (!level && Preferences::instance()->isAutoCreateEnabled() &&
@@ -2812,6 +2815,17 @@ void TCellSelection::createBlankDrawing(int row, int col, bool multiple) {
}
}
+ // Do not add insertion to history until blank creation succeeds.
+ std::unique_ptr<InsertUndo> insertUndo;
+ if (insert) {
+ TCellSelection::Range range;
+ range.m_r0 = range.m_r1 = row;
+ range.m_c0 = range.m_c1 = col;
+ insertUndo.reset(new InsertUndo(range));
+ xsh->insertCells(row, col, 1);
+ TApp::instance()->getCurrentFrame()->setCurrentFrame(row + 1);
+ }
+
ToolHandle *toolHandle = TApp::instance()->getCurrentTool();
// If autocreate disabled, let's turn it on temporarily
@@ -2830,6 +2844,7 @@ void TCellSelection::createBlankDrawing(int row, int col, bool multiple) {
TXshSimpleLevel *sl = cell.getSimpleLevel();
if (!img || !sl) {
+ if (insertUndo) insertUndo->undo();
if (!isAutoCreateEnabled)
Preferences::instance()->setValue(EnableAutocreation, false, false);
if (!isCreationInHoldCellsEnabled)
@@ -2842,6 +2857,7 @@ void TCellSelection::createBlankDrawing(int row, int col, bool multiple) {
}
if (!toolHandle->getTool()->m_isFrameCreated) {
+ if (insertUndo) insertUndo->undo();
if (!isAutoCreateEnabled)
Preferences::instance()->setValue(EnableAutocreation, false, false);
if (!isCreationInHoldCellsEnabled)
@@ -2860,7 +2876,13 @@ void TCellSelection::createBlankDrawing(int row, int col, bool multiple) {
CreateBlankDrawingUndo *undo = new CreateBlankDrawingUndo(
sl, frame, toolHandle->getTool()->m_isLevelCreated, palette);
+ if (insertUndo) {
+ TUndoManager::manager()->beginBlock();
+ TUndoManager::manager()->add(insertUndo.release());
+ TApp::instance()->getCurrentScene()->setDirtyFlag(true);
+ }
TUndoManager::manager()->add(undo);
+ if (insert) TUndoManager::manager()->endBlock();
IconGenerator::instance()->invalidate(sl, frame);
@@ -2873,6 +2895,12 @@ void TCellSelection::createBlankDrawing(int row, int col, bool multiple) {
//-----------------------------------------------------------------------------
+void TCellSelection::createBlankDrawing(int row, int col, bool multiple) {
+ createBlankDrawingImpl(row, col, multiple, false);
+}
+
+//-----------------------------------------------------------------------------
+
void TCellSelection::createBlankDrawings() {
int col = TApp::instance()->getCurrentColumn()->getColumnIndex();
int row = TApp::instance()->getCurrentFrame()->getFrameIndex();
@@ -2896,6 +2924,46 @@ void TCellSelection::createBlankDrawings() {
//-----------------------------------------------------------------------------
+void TCellSelection::insertBlankDrawing() {
+ TFrameHandle *fh = TApp::instance()->getCurrentFrame();
+ if (!fh->isEditingScene()) {
+ DVGui::warning(QObject::tr(
+ "Insert Blank Drawing is available when editing the scene"));
+ return;
+ }
+
+ int col = TApp::instance()->getCurrentColumn()->getColumnIndex();
+ int row = fh->getFrameIndex();
+ TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
+
+ if (col < 0) {
+ DVGui::warning(
+ QObject::tr("Unable to create a blank drawing on the camera column"));
+ return;
+ }
+
+ TXshColumn *column = xsh->getColumn(col);
+ if (column && column->isLocked()) {
+ DVGui::warning(QObject::tr("The current column is locked"));
+ return;
+ }
+
+ TXshCell cell = xsh->getCell(row, col);
+ int targetRow = row;
+ bool needInsert = false;
+
+ if (!cell.isEmpty()) {
+ targetRow = row + 1;
+ while (xsh->getCell(targetRow, col) == cell) ++targetRow;
+ // Insert only when the next cell is already a drawing.
+ needInsert = !xsh->getCell(targetRow, col).isEmpty();
+ }
+
+ createBlankDrawingImpl(targetRow, col, false, needInsert);
+}
+
+//-----------------------------------------------------------------------------
+
void TCellSelection::duplicateFrame(int row, int col, bool multiple) {
TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
@@ -3925,3 +3993,14 @@ void TCellSelection::fillEmptyCell() {
TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
}
+
+//-----------------------------------------------------------------------------
+
+class InsertBlankDrawingCommand final : public MenuItemHandler {
+public:
+ InsertBlankDrawingCommand() : MenuItemHandler(MI_InsertBlankDrawing) {}
+ void execute() override {
+ TCellSelection selection;
+ selection.insertBlankDrawing();
+ }
+} insertBlankDrawingCommand;
diff --git a/toonz/sources/toonz/cellselection.h b/toonz/sources/toonz/cellselection.h
index adf83cc8c..fce686b4c 100644
--- a/toonz/sources/toonz/cellselection.h
+++ b/toonz/sources/toonz/cellselection.h
@@ -130,6 +130,7 @@ public:
void createBlankDrawing(int row, int col, bool multiple);
void createBlankDrawings();
+ void insertBlankDrawing();
void fillEmptyCell();
int getResizePivotRow() const { return m_resizePivotRow; }
};
diff --git a/toonz/sources/toonz/icons/dark/actions/16x16/insert_blank_cell.svg b/toonz/sources/toonz/icons/dark/actions/16x16/insert_blank_cell.svg
new file mode 100644
index 000000000..8a2fd8f84
--- /dev/null
+++ b/toonz/sources/toonz/icons/dark/actions/16x16/insert_blank_cell.svg
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg width="100%" height="100%" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
+ <g id="insert_blank_cell">
+ <rect id="bg" x="0.011" y="-0" width="15.999" height="16" style="fill:#878787;fill-opacity:0;"/>
+ <path d="M12.01,8.028l-0,-3.028l-9,-0l0,7l5.028,-0c-0.019,0.164 -0.028,0.331 -0.028,0.5c0,0.169 0.009,0.336 0.028,0.5l-6.028,-0l0,-9l11,-0l-0,4.028c-0.164,-0.019 -0.331,-0.028 -0.5,-0.028c-0.169,-0 -0.336,0.009 -0.5,0.028Z" style="fill-opacity:0.5;"/>
+ <path d="M12.51,9c1.931,-0 3.499,1.568 3.499,3.5c0,1.932 -1.568,3.5 -3.499,3.5c-1.932,-0 -3.5,-1.568 -3.5,-3.5c-0,-1.932 1.568,-3.5 3.5,-3.5Z" style="fill-opacity:0;"/>
+ <path id="insert_arrow" d="M1.001,6.018l-0.001,2.964l6.003,0l-0.003,2.518l5.001,-4l-5.001,-4l0.003,2.518l-6.002,-0Z" transform="matrix(0.68,0,0,0.68,8.09,6.72)"/>
+ <path d="M14.01,8.256l-0,-7.256l-12.999,-0l-0,13l7.255,-0c0.126,0.356 0.296,0.691 0.503,1l-7.758,-0c-0.553,-0 -1,-0.448 -1,-1l-0,-13c-0,-0.552 0.447,-1 1,-1l12.999,-0c0.552,-0 1,0.448 1,1l-0,7.759c-0.309,-0.207 -0.644,-0.377 -1,-0.503Zm-5.5,-5.756c-0,0.133 -0.053,0.26 -0.146,0.354c-0.094,0.093 -0.221,0.146 -0.354,0.146l-1,-0c-0.132,0 -0.26,-0.053 -0.353,-0.146c-0.094,-0.094 -0.147,-0.221 -0.147,-0.354c0,-0.133 0.053,-0.26 0.147,-0.354c0.093,-0.093 0.221,-0.146 0.353,-0.146l1,-0c0.133,-0 0.26,0.053 0.354,0.146c0.093,0.094 0.146,0.221 0.146,0.354Z"/>
+ <path d="M5.01,2.3c0,-0.166 -0.134,-0.3 -0.3,-0.3l-2.4,-0c-0.165,-0 -0.3,0.134 -0.3,0.3l0,0.4c0,0.166 0.135,0.3 0.3,0.3l2.4,-0c0.166,-0 0.3,-0.134 0.3,-0.3l0,-0.4Z"/>
+ <path d="M13.01,2.3c-0,-0.166 -0.135,-0.3 -0.3,-0.3l-2.4,-0c-0.166,-0 -0.3,0.134 -0.3,0.3l-0,0.4c-0,0.166 0.134,0.3 0.3,0.3l2.4,-0c0.165,-0 0.3,-0.134 0.3,-0.3l-0,-0.4Z"/>
+ </g>
+</svg>
\ No newline at end of file
diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cpp
index bf998d088..84e6514c7 100644
--- a/toonz/sources/toonz/mainwindow.cpp
+++ b/toonz/sources/toonz/mainwindow.cpp
@@ -2590,6 +2590,9 @@ void MainWindow::defineActions() {
createMenuCellsAction(MI_CreateBlankDrawing,
QT_TR_NOOP("&Create Blank Drawing"), "Alt+D",
"add_cell");
+ createMenuCellsAction(MI_InsertBlankDrawing,
+ QT_TR_NOOP("&Insert Blank Drawing"), "",
+ "insert_blank_cell");
createMenuCellsAction(MI_Duplicate, QT_TR_NOOP("&Duplicate Drawing "), "D",
"duplicate_drawing");
createMenuCellsAction(MI_Autorenumber, QT_TR_NOOP("&Autorenumber"), "",
@@ -2635,6 +2638,10 @@ void MainWindow::defineActions() {
"frameprev");
createMenuPlayAction(MI_NextFrame, QT_TR_NOOP("Next Frame"), "Shift+.",
"framenext");
+ createMenuPlayAction(MI_PrevFramePastEnd,
+ QT_TR_NOOP("Previous Frame Past End"), "", "frameprev");
+ createMenuPlayAction(MI_NextFramePastEnd, QT_TR_NOOP("Next Frame Past End"),
+ "", "framenext");
createMenuPlayAction(MI_NextDrawing, QT_TR_NOOP("Next Drawing"), ".",
"next_drawing");
createMenuPlayAction(MI_PrevDrawing, QT_TR_NOOP("Previous Drawing"), ",",
diff --git a/toonz/sources/toonz/menubar.cpp b/toonz/sources/toonz/menubar.cpp
index 4390d9e34..77de8392d 100644
--- a/toonz/sources/toonz/menubar.cpp
+++ b/toonz/sources/toonz/menubar.cpp
@@ -1476,6 +1476,7 @@ QMenuBar *StackedMenuBar::createFullMenuBar() {
cellsMenu->addSeparator();
addMenuItem(cellsMenu, MI_Autorenumber);
addMenuItem(cellsMenu, MI_CreateBlankDrawing);
+ addMenuItem(cellsMenu, MI_InsertBlankDrawing);
addMenuItem(cellsMenu, MI_Duplicate);
addMenuItem(cellsMenu, MI_MergeFrames);
addMenuItem(cellsMenu, MI_CloneLevel);
@@ -1492,6 +1493,8 @@ QMenuBar *StackedMenuBar::createFullMenuBar() {
addMenuItem(playMenu, MI_LastFrame);
addMenuItem(playMenu, MI_PrevFrame);
addMenuItem(playMenu, MI_NextFrame);
+ addMenuItem(playMenu, MI_PrevFramePastEnd);
+ addMenuItem(playMenu, MI_NextFramePastEnd);
addMenuItem(playMenu, MI_PrevStep);
addMenuItem(playMenu, MI_NextStep);
playMenu->addSeparator();
diff --git a/toonz/sources/toonz/menubarcommandids.h b/toonz/sources/toonz/menubarcommandids.h
index 042e494c5..a2ff522cd 100644
--- a/toonz/sources/toonz/menubarcommandids.h
+++ b/toonz/sources/toonz/menubarcommandids.h
@@ -152,6 +152,7 @@
#define MI_PasteNew "MI_PasteNew"
#define MI_Autorenumber "MI_Autorenumber"
#define MI_CreateBlankDrawing "MI_CreateBlankDrawing"
+#define MI_InsertBlankDrawing "MI_InsertBlankDrawing"
#define MI_FillEmptyCell "MI_FillEmptyCell"
#define MI_MergeFrames "MI_MergeFrames"
@@ -212,6 +213,8 @@
#define MI_LastFrame "MI_LastFrame"
#define MI_NextFrame "MI_NextFrame"
#define MI_PrevFrame "MI_PrevFrame"
+#define MI_NextFramePastEnd "MI_NextFramePastEnd"
+#define MI_PrevFramePastEnd "MI_PrevFramePastEnd"
#define MI_NextDrawing "MI_NextDrawing"
#define MI_PrevDrawing "MI_PrevDrawing"
#define MI_NextStep "MI_NextStep"
diff --git a/toonz/sources/toonz/toonz.qrc b/toonz/sources/toonz/toonz.qrc
index 5115b0e00..ca86fc1e0 100644
--- a/toonz/sources/toonz/toonz.qrc
+++ b/toonz/sources/toonz/toonz.qrc
@@ -360,6 +360,7 @@
<file>icons/dark/actions/16x16/insert_frame.svg</file>
<file>icons/dark/actions/16x16/remove_frame.svg</file>
<file>icons/dark/actions/16x16/add_cell.svg</file>
+ <file>icons/dark/actions/16x16/insert_blank_cell.svg</file>
<file>icons/dark/actions/16x16/add_cells.svg</file>
<file>icons/dark/actions/16x16/remove_cell.svg</file>
<file>icons/dark/actions/16x16/remove_cells.svg</file>
diff --git a/toonz/sources/toonz/vcrcommand.cpp b/toonz/sources/toonz/vcrcommand.cpp
index c091f8ff9..b16128149 100644
--- a/toonz/sources/toonz/vcrcommand.cpp
+++ b/toonz/sources/toonz/vcrcommand.cpp
@@ -136,6 +136,52 @@ public:
//-----------------------------------------------------------------------------
+class NextFramePastEndCommand final : public MenuItemHandler {
+public:
+ NextFramePastEndCommand() : MenuItemHandler(MI_NextFramePastEnd) {}
+
+ void execute() override {
+ TFrameHandle *fh = TApp::instance()->getCurrentFrame();
+ if (!fh->isEditingScene()) {
+ FlipConsole *console = FlipConsole::getCurrent();
+ if (console) console->pressButton(FlipConsole::eNext);
+ return;
+ }
+
+ int next = fh->getFrame() + 1;
+ if (next > fh->getMaxFrameIndex()) fh->setSceneFrameSize(next + 1);
+ fh->setFrame(next);
+
+ // Keep the viewer on the new empty frame.
+ FlipConsole *console = FlipConsole::getCurrent();
+ if (!console) return;
+ int from, to, step;
+ console->getFrameRange(from, to, step);
+ int current = next + 1;
+ if (current > to) console->setFrameRange(from, current, step, current);
+ }
+};
+
+//-----------------------------------------------------------------------------
+
+class PrevFramePastEndCommand final : public MenuItemHandler {
+public:
+ PrevFramePastEndCommand() : MenuItemHandler(MI_PrevFramePastEnd) {}
+
+ void execute() override {
+ TFrameHandle *fh = TApp::instance()->getCurrentFrame();
+ if (!fh->isEditingScene()) {
+ FlipConsole *console = FlipConsole::getCurrent();
+ if (console) console->pressButton(FlipConsole::ePrev);
+ return;
+ }
+
+ fh->setFrame(std::max(fh->getFrame() - 1, 0));
+ }
+};
+
+//-----------------------------------------------------------------------------
+
class NextStepCommand final : public MenuItemHandler {
public:
NextStepCommand() : MenuItemHandler(MI_NextStep) {}
@@ -267,6 +313,8 @@ VcrCommand playCommand(MI_Play, FlipConsole::ePlay),
NextDrawingCommand nextDrawingCommand;
PrevDrawingCommand prevDrawingCommand;
+NextFramePastEndCommand nextFramePastEndCommand;
+PrevFramePastEndCommand prevFramePastEndCommand;
NextStepCommand nextStepCommand;
PrevStepCommand prevStepCommand;
ShortPlayCommand shortPlayCommand;
diff --git a/toonz/sources/toonz/xshcellviewer.cpp b/toonz/sources/toonz/xshcellviewer.cpp
index ff25f0973..1046a3bb3 100644
--- a/toonz/sources/toonz/xshcellviewer.cpp
+++ b/toonz/sources/toonz/xshcellviewer.cpp
@@ -3994,6 +3994,7 @@ void CellArea::createCellMenu(QMenu &menu, bool isCellSelected, TXshCell cell,
menu.addAction(cmdManager->getAction(MI_Insert));
if (!soundTextCellsSelected) {
menu.addAction(cmdManager->getAction(MI_CreateBlankDrawing));
+ menu.addAction(cmdManager->getAction(MI_InsertBlankDrawing));
menu.addAction(cmdManager->getAction(MI_Duplicate));
}
menu.addSeparator();
@@ -4047,6 +4048,7 @@ void CellArea::createCellMenu(QMenu &menu, bool isCellSelected, TXshCell cell,
} else {
menu.addAction(cmdManager->getAction(MI_CreateBlankDrawing));
+ menu.addAction(cmdManager->getAction(MI_InsertBlankDrawing));
menu.addSeparator();
menu.addAction(cmdManager->getAction(MI_FillEmptyCell));
if (cameraCellsSelected) {