Allows Click+Drag to move tag

This commit is contained in:
manongjohn 2022-03-31 10:42:03 -04:00
parent f51ba296f9
commit 9ad880a7b6
4 changed files with 57 additions and 1 deletions

View file

@ -50,6 +50,7 @@
#include "toutputproperties.h" #include "toutputproperties.h"
#include "toonz/preferences.h" #include "toonz/preferences.h"
#include "toonz/columnfan.h" #include "toonz/columnfan.h"
#include "toonz/navigationtags.h"
// TnzBase includes // TnzBase includes
#include "tfx.h" #include "tfx.h"
@ -2207,3 +2208,49 @@ XsheetGUI::DragTool *XsheetGUI::DragTool::makeDragAndDropDataTool(
XsheetViewer *viewer) { XsheetViewer *viewer) {
return new DataDragTool(viewer); return new DataDragTool(viewer);
} }
//=============================================================================
// NavigationTagDragTool
//-----------------------------------------------------------------------------
namespace {
class NavigationTagDragTool final : public XsheetGUI::DragTool {
int m_taggedRow;
public:
NavigationTagDragTool(XsheetViewer *viewer) : DragTool(viewer) {}
void onClick(const CellPosition &pos) override {
int row = pos.frame();
m_taggedRow = row;
refreshRowsArea();
}
void onDrag(const CellPosition &pos) override {
int row = pos.frame();
if (row < 0) row = 0;
onRowChange(row);
refreshRowsArea();
}
void onRowChange(int row) {
if (row < 0) return;
TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
NavigationTags *navTags = xsh->getNavigationTags();
if (m_taggedRow == row || navTags->isTagged(row)) return;
navTags->moveTag(m_taggedRow, row);
m_taggedRow = row;
}
};
//-----------------------------------------------------------------------------
} // namespace
//-----------------------------------------------------------------------------
XsheetGUI::DragTool *XsheetGUI::DragTool::makeNavigationTagDragTool(
XsheetViewer *viewer) {
return new NavigationTagDragTool(viewer);
}

View file

@ -69,6 +69,8 @@ public:
static DragTool *makeColumnLinkTool(XsheetViewer *viewer); static DragTool *makeColumnLinkTool(XsheetViewer *viewer);
static DragTool *makeColumnMoveTool(XsheetViewer *viewer); static DragTool *makeColumnMoveTool(XsheetViewer *viewer);
static DragTool *makeVolumeDragTool(XsheetViewer *viewer); static DragTool *makeVolumeDragTool(XsheetViewer *viewer);
static DragTool *makeNavigationTagDragTool(XsheetViewer *viewer);
}; };
void setPlayRange(int r0, int r1, int step, bool withUndo = true); void setPlayRange(int r0, int r1, int step, bool withUndo = true);

View file

@ -1040,7 +1040,13 @@ void RowArea::mousePressEvent(QMouseEvent *event) {
playR0 = 0; playR0 = 0;
} }
if (playR1 == -1) { // getFrameCount = 0 i.e. xsheet is empty if (xsh->getNavigationTags()->isTagged(row) &&
o->rect(PredefinedRect::NAVIGATION_TAG_AREA)
.adjusted(0, 0, -frameAdj.x(), -frameAdj.y())
.contains(mouseInCell)) {
setDragTool(XsheetGUI::DragTool::makeNavigationTagDragTool(m_viewer));
frameAreaIsClicked = true;
} else if (playR1 == -1) { // getFrameCount = 0 i.e. xsheet is empty
setDragTool( setDragTool(
XsheetGUI::DragTool::makeCurrentFrameModifierTool(m_viewer)); XsheetGUI::DragTool::makeCurrentFrameModifierTool(m_viewer));
frameAreaIsClicked = true; frameAreaIsClicked = true;

View file

@ -72,6 +72,7 @@ void NavigationTags::moveTag(int fromFrame, int toFrame) {
for (int i = 0; i < m_tags.size(); i++) for (int i = 0; i < m_tags.size(); i++)
if (m_tags[i].m_frame == fromFrame) { if (m_tags[i].m_frame == fromFrame) {
m_tags[i].m_frame = toFrame; m_tags[i].m_frame = toFrame;
std::sort(m_tags.begin(), m_tags.end());
break; break;
} }
} }