Skip to content

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

C

Add removal of selected Xsheet frames

Rodney623308ffee8f
diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cpp
index 39029aaf1..217c15c99 100644
--- a/toonz/sources/toonz/mainwindow.cpp
+++ b/toonz/sources/toonz/mainwindow.cpp
@@ -2500,6 +2500,9 @@ void MainWindow::defineActions() {
"insert_frame");
createMenuXsheetAction(MI_RemoveSceneFrame, QT_TR_NOOP("Remove Frame"), "",
"remove_frame");
+ createMenuXsheetAction(MI_RemoveSelectedSceneFrames,
+ QT_TR_NOOP("Remove Selected Frames"), "",
+ "remove_frame");
createMenuXsheetAction(MI_InsertGlobalKeyframe,
QT_TR_NOOP("Insert Multiple Keys"), "",
"insert_multiple_keys");
diff --git a/toonz/sources/toonz/menubarcommandids.h b/toonz/sources/toonz/menubarcommandids.h
index 684a8d297..636e67d92 100644
--- a/toonz/sources/toonz/menubarcommandids.h
+++ b/toonz/sources/toonz/menubarcommandids.h
@@ -136,6 +136,7 @@
#define MI_DeleteInk "MI_DeleteInk"
#define MI_InsertSceneFrame "MI_InsertSceneFrame"
#define MI_RemoveSceneFrame "MI_RemoveSceneFrame"
+#define MI_RemoveSelectedSceneFrames "MI_RemoveSelectedSceneFrames"
#define MI_InsertGlobalKeyframe "MI_InsertGlobalKeyframe"
#define MI_RemoveGlobalKeyframe "MI_RemoveGlobalKeyframe"
diff --git a/toonz/sources/toonz/xshcellviewer.cpp b/toonz/sources/toonz/xshcellviewer.cpp
index b52f6767b..f44e64341 100644
--- a/toonz/sources/toonz/xshcellviewer.cpp
+++ b/toonz/sources/toonz/xshcellviewer.cpp
@@ -4053,6 +4053,13 @@ void CellArea::createCellMenu(QMenu &menu, bool isCellSelected, TXshCell cell,
}
}
+ int r0, c0, r1, c1;
+ m_viewer->getCellSelection()->getSelectedCells(r0, c0, r1, c1);
+ if (r1 > r0) {
+ menu.addSeparator();
+ menu.addAction(cmdManager->getAction(MI_RemoveSelectedSceneFrames));
+ }
+
// cell mark menu
TXshCellColumn *cellColumn =
(m_viewer->getXsheet()->getColumn(col))
diff --git a/toonz/sources/toonz/xsheetcmd.cpp b/toonz/sources/toonz/xsheetcmd.cpp
index 33802850b..ab7860abf 100644
--- a/toonz/sources/toonz/xsheetcmd.cpp
+++ b/toonz/sources/toonz/xsheetcmd.cpp
@@ -47,6 +47,7 @@
// TnzQt includes
#include "toonzqt/tselectionhandle.h"
#include "toonzqt/gutil.h"
+#include "toonzqt/dvdialog.h"
#include "toonzqt/menubarcommand.h"
#include "toonzqt/stageobjectsdata.h"
#include "historytypes.h"
@@ -343,6 +344,52 @@ public:
}
} removeSceneFrameCommand;
+//*****************************************************************************
+// RemoveSelectedSceneFrames command
+//*****************************************************************************
+
+class RemoveSelectedSceneFramesCommand final : public MenuItemHandler {
+public:
+ RemoveSelectedSceneFramesCommand()
+ : MenuItemHandler(MI_RemoveSelectedSceneFrames) {}
+
+ void execute() override {
+ TCellSelection *selection = dynamic_cast<TCellSelection *>(
+ TApp::instance()->getCurrentSelection()->getSelection());
+ if (!selection || selection->isEmpty()) return;
+
+ TCellSelection::Range range = selection->getSelectedCells();
+ if (range.getRowCount() < 2) return;
+
+ TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
+ bool hasExposedContent = false;
+ for (int row = range.m_r0; row <= range.m_r1 && !hasExposedContent; ++row) {
+ for (int col = 0; col < xsh->getColumnCount(); ++col) {
+ if (!xsh->getCell(row, col).isEmpty()) {
+ hasExposedContent = true;
+ break;
+ }
+ }
+ }
+
+ if (hasExposedContent) {
+ QString question = QObject::tr(
+ "The selected Xsheet frames contain exposed content. Removing them "
+ "will remove these rows across all columns and shift later frames "
+ "upward. Continue?");
+ int ret = DVGui::MsgBox(question, QObject::tr("Remove Frames"),
+ QObject::tr("Cancel"), 1);
+ if (ret != 1) return;
+ }
+
+ TUndoScopedBlock undoBlock;
+ for (int row = range.m_r1; row >= range.m_r0; --row) removeSceneFrame(row);
+
+ selection->selectCells(range.m_r0, range.m_c0, range.m_r0, range.m_c1);
+ TApp::instance()->getCurrentSelection()->notifySelectionChanged();
+ }
+} removeSelectedSceneFramesCommand;
+
//*****************************************************************************
// GlobalKeyframeUndo definition
//*****************************************************************************