Allows Click+Drag to move tag
This commit is contained in:
parent
f51ba296f9
commit
9ad880a7b6
4 changed files with 57 additions and 1 deletions
|
@ -50,6 +50,7 @@
|
|||
#include "toutputproperties.h"
|
||||
#include "toonz/preferences.h"
|
||||
#include "toonz/columnfan.h"
|
||||
#include "toonz/navigationtags.h"
|
||||
|
||||
// TnzBase includes
|
||||
#include "tfx.h"
|
||||
|
@ -2207,3 +2208,49 @@ XsheetGUI::DragTool *XsheetGUI::DragTool::makeDragAndDropDataTool(
|
|||
XsheetViewer *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);
|
||||
}
|
||||
|
|
|
@ -69,6 +69,8 @@ public:
|
|||
static DragTool *makeColumnLinkTool(XsheetViewer *viewer);
|
||||
static DragTool *makeColumnMoveTool(XsheetViewer *viewer);
|
||||
static DragTool *makeVolumeDragTool(XsheetViewer *viewer);
|
||||
|
||||
static DragTool *makeNavigationTagDragTool(XsheetViewer *viewer);
|
||||
};
|
||||
|
||||
void setPlayRange(int r0, int r1, int step, bool withUndo = true);
|
||||
|
|
|
@ -1040,7 +1040,13 @@ void RowArea::mousePressEvent(QMouseEvent *event) {
|
|||
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(
|
||||
XsheetGUI::DragTool::makeCurrentFrameModifierTool(m_viewer));
|
||||
frameAreaIsClicked = true;
|
||||
|
|
|
@ -72,6 +72,7 @@ void NavigationTags::moveTag(int fromFrame, int toFrame) {
|
|||
for (int i = 0; i < m_tags.size(); i++)
|
||||
if (m_tags[i].m_frame == fromFrame) {
|
||||
m_tags[i].m_frame = toFrame;
|
||||
std::sort(m_tags.begin(), m_tags.end());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue