Fix incorrect keyframe cell pasting and redo (#2398)
* Fix incorrect keyframe pasting * Fix keyframe redo
This commit is contained in:
parent
09549bc679
commit
9c3f7d50a6
5 changed files with 37 additions and 7 deletions
|
@ -71,7 +71,9 @@ void TCellKeyframeSelection::copyCellsKeyframes() {
|
||||||
QClipboard *clipboard = QApplication::clipboard();
|
QClipboard *clipboard = QApplication::clipboard();
|
||||||
TXsheet *xsh = m_xsheetHandle->getXsheet();
|
TXsheet *xsh = m_xsheetHandle->getXsheet();
|
||||||
TKeyframeData *keyframeData = new TKeyframeData();
|
TKeyframeData *keyframeData = new TKeyframeData();
|
||||||
keyframeData->setKeyframes(m_keyframeSelection->getSelection(), xsh);
|
TKeyframeData::Position startPos(r0, c0);
|
||||||
|
keyframeData->setKeyframes(m_keyframeSelection->getSelection(), xsh,
|
||||||
|
startPos);
|
||||||
data->setKeyframeData(keyframeData);
|
data->setKeyframeData(keyframeData);
|
||||||
}
|
}
|
||||||
// Set the cliboard
|
// Set the cliboard
|
||||||
|
|
|
@ -1629,9 +1629,11 @@ void TCellSelection::pasteCells() {
|
||||||
// (r0,c0)
|
// (r0,c0)
|
||||||
std::set<TKeyframeSelection::Position> positions;
|
std::set<TKeyframeSelection::Position> positions;
|
||||||
int newC0 = c0;
|
int newC0 = c0;
|
||||||
if (viewer && !viewer->orientation()->isVerticalTimeline())
|
if (viewer && !viewer->orientation()->isVerticalTimeline() && !cellData)
|
||||||
newC0 = c0 - keyframeData->getColumnSpanCount() + 1;
|
newC0 = c0 - keyframeData->getColumnSpanCount() + 1;
|
||||||
positions.insert(TKeyframeSelection::Position(r0, newC0));
|
TKeyframeSelection::Position offset(keyframeData->getKeyframesOffset());
|
||||||
|
positions.insert(TKeyframeSelection::Position(r0 + offset.first,
|
||||||
|
newC0 + offset.second));
|
||||||
keyframeData->getKeyframes(positions);
|
keyframeData->getKeyframes(positions);
|
||||||
selection.select(positions);
|
selection.select(positions);
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,8 @@ TKeyframeData::TKeyframeData() {}
|
||||||
|
|
||||||
TKeyframeData::TKeyframeData(const TKeyframeData *src)
|
TKeyframeData::TKeyframeData(const TKeyframeData *src)
|
||||||
: m_keyData(src->m_keyData)
|
: m_keyData(src->m_keyData)
|
||||||
, m_isPegbarsCycleEnabled(src->m_isPegbarsCycleEnabled) {}
|
, m_isPegbarsCycleEnabled(src->m_isPegbarsCycleEnabled)
|
||||||
|
, m_offset(src->m_offset) {}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -32,6 +33,12 @@ TKeyframeData::~TKeyframeData() {}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// data <- xsheet
|
// data <- xsheet
|
||||||
void TKeyframeData::setKeyframes(std::set<Position> positions, TXsheet *xsh) {
|
void TKeyframeData::setKeyframes(std::set<Position> positions, TXsheet *xsh) {
|
||||||
|
Position startPos(-1, -1);
|
||||||
|
setKeyframes(positions, xsh, startPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TKeyframeData::setKeyframes(std::set<Position> positions, TXsheet *xsh,
|
||||||
|
Position startPos) {
|
||||||
if (positions.empty()) return;
|
if (positions.empty()) return;
|
||||||
|
|
||||||
TStageObjectId cameraId = xsh->getStageObjectTree()->getCurrentCameraId();
|
TStageObjectId cameraId = xsh->getStageObjectTree()->getCurrentCameraId();
|
||||||
|
@ -51,6 +58,9 @@ void TKeyframeData::setKeyframes(std::set<Position> positions, TXsheet *xsh) {
|
||||||
m_columnSpanCount = c1 - c0 + 1;
|
m_columnSpanCount = c1 - c0 + 1;
|
||||||
m_rowSpanCount = r1 - r0 + 1;
|
m_rowSpanCount = r1 - r0 + 1;
|
||||||
|
|
||||||
|
if (startPos.first >= 0 && startPos.second >= 0)
|
||||||
|
m_offset = std::make_pair(r0 - startPos.first, c0 - startPos.second);
|
||||||
|
|
||||||
for (it = positions.begin(); it != positions.end(); ++it) {
|
for (it = positions.begin(); it != positions.end(); ++it) {
|
||||||
int row = it->first;
|
int row = it->first;
|
||||||
int col = it->second;
|
int col = it->second;
|
||||||
|
@ -126,3 +136,7 @@ void TKeyframeData::getKeyframes(std::set<Position> &positions) const {
|
||||||
TKeyframeSelection::Position(pos.first + r0, pos.second + c0));
|
TKeyframeSelection::Position(pos.first + r0, pos.second + c0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TKeyframeData::setKeyframesOffset(int row, int col) {
|
||||||
|
m_offset = std::make_pair(row, col);
|
||||||
|
}
|
||||||
|
|
|
@ -25,6 +25,8 @@ public:
|
||||||
int m_columnSpanCount;
|
int m_columnSpanCount;
|
||||||
int m_rowSpanCount;
|
int m_rowSpanCount;
|
||||||
|
|
||||||
|
Position m_offset = std::make_pair(0, 0);
|
||||||
|
|
||||||
// Numero di colonna della pegbar associato al booleano isCycleEnabled della
|
// Numero di colonna della pegbar associato al booleano isCycleEnabled della
|
||||||
// pegbar
|
// pegbar
|
||||||
std::map<int, bool> m_isPegbarsCycleEnabled;
|
std::map<int, bool> m_isPegbarsCycleEnabled;
|
||||||
|
@ -37,6 +39,8 @@ public:
|
||||||
|
|
||||||
// data <- xsh
|
// data <- xsh
|
||||||
void setKeyframes(std::set<Position> positions, TXsheet *xsh);
|
void setKeyframes(std::set<Position> positions, TXsheet *xsh);
|
||||||
|
void setKeyframes(std::set<Position> positions, TXsheet *xsh,
|
||||||
|
Position startPos);
|
||||||
|
|
||||||
// data -> xsh
|
// data -> xsh
|
||||||
bool getKeyframes(std::set<Position> &positions, TXsheet *xsh) const;
|
bool getKeyframes(std::set<Position> &positions, TXsheet *xsh) const;
|
||||||
|
@ -52,6 +56,9 @@ public:
|
||||||
|
|
||||||
int getColumnSpanCount() const { return m_columnSpanCount; }
|
int getColumnSpanCount() const { return m_columnSpanCount; }
|
||||||
int getRowSpanCount() const { return m_rowSpanCount; }
|
int getRowSpanCount() const { return m_rowSpanCount; }
|
||||||
|
|
||||||
|
void setKeyframesOffset(int row, int col);
|
||||||
|
Position getKeyframesOffset() const { return m_offset; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEYFRAMEDATA_INCLUDED
|
#endif // KEYFRAMEDATA_INCLUDED
|
||||||
|
|
|
@ -144,12 +144,17 @@ public:
|
||||||
// data->xsh
|
// data->xsh
|
||||||
void setXshFromData(QMimeData *data) const {
|
void setXshFromData(QMimeData *data) const {
|
||||||
const TKeyframeData *keyframeData = dynamic_cast<TKeyframeData *>(data);
|
const TKeyframeData *keyframeData = dynamic_cast<TKeyframeData *>(data);
|
||||||
if (keyframeData)
|
if (keyframeData) {
|
||||||
pasteKeyframesWithoutUndo(keyframeData, &m_selection->getSelection());
|
TKeyframeSelection *selection =
|
||||||
|
new TKeyframeSelection(m_selection->getSelection());
|
||||||
|
pasteKeyframesWithoutUndo(keyframeData, &selection->getSelection());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void undo() const override {
|
void undo() const override {
|
||||||
// Delete merged data
|
// Delete merged data
|
||||||
deleteKeyframesWithoutUndo(&m_selection->getSelection());
|
TKeyframeSelection *selection =
|
||||||
|
new TKeyframeSelection(m_selection->getSelection());
|
||||||
|
deleteKeyframesWithoutUndo(&selection->getSelection());
|
||||||
if (-(m_r1 - m_r0 + 1) != 0)
|
if (-(m_r1 - m_r0 + 1) != 0)
|
||||||
shiftKeyframesWithoutUndo(m_r0, m_r1, m_c0, m_c1, true);
|
shiftKeyframesWithoutUndo(m_r0, m_r1, m_c0, m_c1, true);
|
||||||
if (m_oldData) setXshFromData(m_oldData);
|
if (m_oldData) setXshFromData(m_oldData);
|
||||||
|
|
Loading…
Reference in a new issue