Commit deb51c9f authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix keyframe incorrectly moved when attempting to seek in keyframe view

parent d7c528b2
...@@ -29,6 +29,7 @@ KeyframeView::KeyframeView(std::shared_ptr<KeyframeModelList> model, int duratio ...@@ -29,6 +29,7 @@ KeyframeView::KeyframeView(std::shared_ptr<KeyframeModelList> model, int duratio
, m_zoomFactor(1) , m_zoomFactor(1)
, m_zoomStart(0) , m_zoomStart(0)
, m_moveKeyframeMode(false) , m_moveKeyframeMode(false)
, m_keyframeZonePress(false)
, m_clickPoint(-1) , m_clickPoint(-1)
, m_clickEnd(-1) , m_clickEnd(-1)
, m_zoomHandle(0,1) , m_zoomHandle(0,1)
...@@ -285,6 +286,7 @@ void KeyframeView::mousePressEvent(QMouseEvent *event) ...@@ -285,6 +286,7 @@ void KeyframeView::mousePressEvent(QMouseEvent *event)
int pos = int(((event->x() - m_offset) / zoomFactor + zoomStart ) / m_scale); int pos = int(((event->x() - m_offset) / zoomFactor + zoomStart ) / m_scale);
pos = qBound(0, pos, m_duration - 1); pos = qBound(0, pos, m_duration - 1);
m_moveKeyframeMode = false; m_moveKeyframeMode = false;
m_keyframeZonePress = false;
if (event->button() == Qt::LeftButton) { if (event->button() == Qt::LeftButton) {
if (event->y() < m_lineHeight) { if (event->y() < m_lineHeight) {
// mouse click in keyframes area // mouse click in keyframes area
...@@ -294,6 +296,7 @@ void KeyframeView::mousePressEvent(QMouseEvent *event) ...@@ -294,6 +296,7 @@ void KeyframeView::mousePressEvent(QMouseEvent *event)
m_clickPoint = pos; m_clickPoint = pos;
return; return;
} }
m_keyframeZonePress = true;
auto keyframe = m_model->getClosestKeyframe(position, &ok); auto keyframe = m_model->getClosestKeyframe(position, &ok);
if (ok && qAbs(keyframe.first.frames(pCore->getCurrentFps()) - pos - offset) * m_scale * m_zoomFactor < QApplication::startDragDistance()) { if (ok && qAbs(keyframe.first.frames(pCore->getCurrentFps()) - pos - offset) * m_scale * m_zoomFactor < QApplication::startDragDistance()) {
int currentIx = m_model->getIndexForPos(keyframe.first); int currentIx = m_model->getIndexForPos(keyframe.first);
...@@ -400,7 +403,7 @@ void KeyframeView::mouseMoveEvent(QMouseEvent *event) ...@@ -400,7 +403,7 @@ void KeyframeView::mouseMoveEvent(QMouseEvent *event)
if (m_model->activeKeyframe() == pos) { if (m_model->activeKeyframe() == pos) {
return; return;
} }
if (m_model->activeKeyframe() > 0 && m_currentKeyframeOriginal > -1 && m_clickPoint == -1 && (m_moveKeyframeMode || qAbs(pos - (m_currentKeyframeOriginal - offset)) * m_scale * m_zoomFactor < QApplication::startDragDistance())) { if (m_model->activeKeyframe() > 0 && m_currentKeyframeOriginal > -1 && m_clickPoint == -1 && (m_moveKeyframeMode || (qAbs(pos - (m_currentKeyframeOriginal - offset)) * m_scale * m_zoomFactor < QApplication::startDragDistance() && m_keyframeZonePress))) {
m_moveKeyframeMode = true; m_moveKeyframeMode = true;
if (!m_model->hasKeyframe(pos + offset)) { if (!m_model->hasKeyframe(pos + offset)) {
int delta = pos - (m_model->getPosAtIndex(m_model->activeKeyframe()).frames(pCore->getCurrentFps()) - offset); int delta = pos - (m_model->getPosAtIndex(m_model->activeKeyframe()).frames(pCore->getCurrentFps()) - offset);
...@@ -554,6 +557,7 @@ void KeyframeView::mouseReleaseEvent(QMouseEvent *event) ...@@ -554,6 +557,7 @@ void KeyframeView::mouseReleaseEvent(QMouseEvent *event)
qDebug() << "RELEASING keyframe move" << delta; qDebug() << "RELEASING keyframe move" << delta;
} }
m_moveKeyframeMode = false; m_moveKeyframeMode = false;
m_keyframeZonePress = false;
} }
void KeyframeView::mouseDoubleClickEvent(QMouseEvent *event) void KeyframeView::mouseDoubleClickEvent(QMouseEvent *event)
......
...@@ -75,6 +75,7 @@ private: ...@@ -75,6 +75,7 @@ private:
double m_zoomFactor; double m_zoomFactor;
double m_zoomStart; double m_zoomStart;
bool m_moveKeyframeMode; bool m_moveKeyframeMode;
bool m_keyframeZonePress;
int m_clickPoint; int m_clickPoint;
int m_clickEnd; int m_clickEnd;
/** @brief The zoom factor (start, end - between 0 and 1) */ /** @brief The zoom factor (start, end - between 0 and 1) */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment