OpenToonz - An open-source full-featured 2D animation creation software
C
Set auto markers (#982)
jabarreraeb0a56909e33
diff --git a/toonz/sources/toonz/xshrowviewer.cpp b/toonz/sources/toonz/xshrowviewer.cppindex 3e896937d..820bec590 100644--- a/toonz/sources/toonz/xshrowviewer.cpp+++ b/toonz/sources/toonz/xshrowviewer.cpp@@ -688,6 +688,11 @@ void RowArea::contextMenuEvent(QContextMenuEvent *event) {connect(setStartMarker, SIGNAL(triggered()), SLOT(onSetStartMarker()));QAction *setStopMarker = menu->addAction(tr("Set Stop Marker"));connect(setStopMarker, SIGNAL(triggered()), SLOT(onSetStopMarker()));++ QAction *setAutoMarkers = menu->addAction(tr("Set Auto Markers"));+ connect(setAutoMarkers, SIGNAL(triggered()), SLOT(onSetAutoMarkers()));+ setAutoMarkers->setEnabled(canSetAutoMarkers());+QAction *removeMarkers = menu->addAction(tr("Remove Markers"));connect(removeMarkers, SIGNAL(triggered()), SLOT(onRemoveMarkers()));@@ -718,6 +723,32 @@ void RowArea::contextMenuEvent(QContextMenuEvent *event) {menu->exec(event->globalPos());}+//-----------------------------------------------------------------------------+// Checks if there is a cell non empty at current row and column to enable the+// auto markers item-menu.+bool RowArea::canSetAutoMarkers() {+ TXshCell cell =+ m_viewer->getXsheet()->getCell(m_row, m_viewer->getCurrentColumn());+ return cell.isEmpty() ? false : true;+}++//-----------------------------------------------------------------------------+int RowArea::getNonEmptyCell(int row, int column, Direction direction) {+ int currentPos = row;+ bool exit = false;++ while (!exit) {+ TXshCell cell = m_viewer->getXsheet()->getCell(currentPos, column);+ if (cell.isEmpty()) {+ (direction == up) ? currentPos++ : currentPos--;+ exit = true;+ } else+ (direction == up) ? currentPos-- : currentPos++;+ }++ return currentPos;+}+//-----------------------------------------------------------------------------void RowArea::mouseDoubleClickEvent(QMouseEvent *event) {@@ -796,6 +827,20 @@ void RowArea::onPreviewThis() {update();}+// Set the playing markers to the continuous block of the cell pointed by+// current row and column+void RowArea::onSetAutoMarkers() {+ int currentColumn = m_viewer->getCurrentColumn();++ int top = getNonEmptyCell(m_row, currentColumn, Direction::up);+ int bottom = getNonEmptyCell(m_row, currentColumn, Direction::down);++ int r0, r1, step;+ getPlayRange(r0, r1, step);+ setPlayRange(top, bottom, step);+ update();+}+//-----------------------------------------------------------------------------void RowArea::onRemoveMarkers() {diff --git a/toonz/sources/toonz/xshrowviewer.h b/toonz/sources/toonz/xshrowviewer.hindex a486a22c1..53e1bdfad 100644--- a/toonz/sources/toonz/xshrowviewer.h+++ b/toonz/sources/toonz/xshrowviewer.h@@ -30,6 +30,8 @@ class RowArea final : public QWidget {Mos} m_showOnionToSet; // TODO:�����͂����Fos,Mos�ǂ�����n�C���C�g���Ă���̂����肳����I�I�I�I+ enum Direction { up = 0, down };+// Play rangesint m_r0;int m_r1;@@ -51,6 +53,12 @@ class RowArea final : public QWidget {DragTool *getDragTool() const;void setDragTool(DragTool *dragTool);+ // Return when the item-menu setAutoMarkers can be enabled.+ bool canSetAutoMarkers();+ // Return the number of the last non-empty cell finded. You can set the+ // direction of the search.+ int getNonEmptyCell(int row, int column, Direction);+public:#if QT_VERSION >= 0x050500RowArea(XsheetViewer *parent, Qt::WindowFlags flags = 0);@@ -77,6 +85,9 @@ protected slots:void onSetStopMarker();void onRemoveMarkers();+ // Set start and end marker automatically respect the current row and column.+ void onSetAutoMarkers();+// set both the from and to markers at the specified rowvoid onPreviewThis();};