Skip to content

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

C

Feat(next/prev Drawing): Add support of level Editing mode

Abel You6a175ee06395
diff --git a/toonz/sources/toonz/vcrcommand.cpp b/toonz/sources/toonz/vcrcommand.cpp
index 32aeac949..c091f8ff9 100644
--- a/toonz/sources/toonz/vcrcommand.cpp
+++ b/toonz/sources/toonz/vcrcommand.cpp
@@ -16,6 +16,8 @@
#include "toonz/tframehandle.h"
#include "toonz/tcolumnhandle.h"
#include "toonz/preferences.h"
+#include "toonz/txshsimplelevel.h"
+#include "toonz/txshlevelhandle.h"
#include <QApplication>
@@ -50,20 +52,35 @@ public:
NextDrawingCommand() : MenuItemHandler(MI_NextDrawing) {}
void execute() override {
- TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
+ auto app = TApp::instance();
- int row = TApp::instance()->getCurrentFrame()->getFrame();
- int col = TApp::instance()->getCurrentColumn()->getColumnIndex();
+ if (app->getCurrentFrame()->isEditingScene()) {
+ TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
- const TXshCell &cell = xsh->getCell(row, col);
+ int row = app->getCurrentFrame()->getFrame();
+ int col = app->getCurrentColumn()->getColumnIndex();
- int frameCount = xsh->getFrameCount();
- while (row < frameCount) {
- row++;
- if (xsh->getCell(row, col).isEmpty()) continue;
- if (xsh->getCell(row, col) != cell) {
- TApp::instance()->getCurrentFrame()->setFrame(row);
- break;
+ const TXshCell &cell = xsh->getCell(row, col);
+ int frameCount = xsh->getFrameCount();
+ while (row < frameCount) {
+ row++;
+ if (xsh->getCell(row, col).isEmpty()) continue;
+ if (xsh->getCell(row, col) != cell) {
+ TApp::instance()->getCurrentFrame()->setFrame(row);
+ break;
+ }
+ }
+ } else {
+ TXshSimpleLevel *sl = app->getCurrentLevel()->getSimpleLevel();
+ if (!sl) return;
+
+ TFrameId currentFid = app->getCurrentFrame()->getFid();
+ int currentIndex = sl->fid2index(currentFid);
+ int frameCount = sl->getFrameCount();
+ int i = currentIndex + 1;
+ if (i < frameCount) {
+ TFrameId fid = sl->getFrameId(i);
+ if (fid != TFrameId()) app->getCurrentFrame()->setFid(fid);
}
}
}
@@ -76,28 +93,43 @@ public:
PrevDrawingCommand() : MenuItemHandler(MI_PrevDrawing) {}
void execute() override {
- TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
+ auto app = TApp::instance();
- int row = TApp::instance()->getCurrentFrame()->getFrame();
- int col = TApp::instance()->getCurrentColumn()->getColumnIndex();
+ if (app->getCurrentFrame()->isEditingScene()) {
+ TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
- TXshCell cell = xsh->getCell(row, col);
+ int row = TApp::instance()->getCurrentFrame()->getFrame();
+ int col = TApp::instance()->getCurrentColumn()->getColumnIndex();
- // Get *last* cell in previous uniform cell block
- while (row >= 0) {
- row--;
- if (xsh->getCell(row, col).isEmpty()) continue;
- if (xsh->getCell(row, col) != cell) {
- cell = xsh->getCell(row, col);
- break;
+ TXshCell cell = xsh->getCell(row, col);
+
+ // Get *last* cell in previous uniform cell block
+ while (row >= 0) {
+ row--;
+ if (xsh->getCell(row, col).isEmpty()) continue;
+ if (xsh->getCell(row, col) != cell) {
+ cell = xsh->getCell(row, col);
+ break;
+ }
}
- }
- if (row >= 0) {
- cell = xsh->getCell(row, col);
- // Get *first* cell in current uniform cell block
- while (row > 0 && xsh->getCell(row - 1, col) == cell) --row;
- TApp::instance()->getCurrentFrame()->setFrame(row);
+ if (row >= 0) {
+ cell = xsh->getCell(row, col);
+ // Get *first* cell in current uniform cell block
+ while (row > 0 && xsh->getCell(row - 1, col) == cell) --row;
+ TApp::instance()->getCurrentFrame()->setFrame(row);
+ }
+ } else {
+ TXshSimpleLevel *sl = app->getCurrentLevel()->getSimpleLevel();
+ if (!sl) return;
+
+ TFrameId currentFid = app->getCurrentFrame()->getFid();
+ int currentIndex = sl->fid2index(currentFid);
+ int i = currentIndex - 1;
+ if (i >= 0) {
+ TFrameId fid = sl->getFrameId(i);
+ if (fid != TFrameId()) app->getCurrentFrame()->setFid(fid);
+ }
}
}
};
@@ -137,11 +169,11 @@ public:
ShortPlayCommand() : MenuItemHandler(MI_ShortPlay) {}
void execute() override {
- int currentFrame = TApp::instance()->getCurrentFrame()->getFrame();
+ int currentFrame = TApp::instance()->getCurrentFrame()->getFrame();
int shortPlayFrameCount = Preferences::instance()->getShortPlayFrameCount();
int frameCount =
TApp::instance()->getCurrentXsheet()->getXsheet()->getFrameCount();
- int stopFrame = std::min(currentFrame, frameCount);
+ int stopFrame = std::min(currentFrame, frameCount);
int startFrame = std::max(0, stopFrame - shortPlayFrameCount);
FlipConsole::getCurrent()->setStopAt(stopFrame + 1);