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

Effect keyframe minor fixes (improve hover color and allow pasting param to keyframe 0)

parent 9d4018a6
...@@ -297,7 +297,7 @@ void KeyframeView::mousePressEvent(QMouseEvent *event) ...@@ -297,7 +297,7 @@ void KeyframeView::mousePressEvent(QMouseEvent *event)
if (m_selectedKeyframes.contains(m_currentKeyframeOriginal)) { if (m_selectedKeyframes.contains(m_currentKeyframeOriginal)) {
m_selectedKeyframes.removeAll(m_currentKeyframeOriginal); m_selectedKeyframes.removeAll(m_currentKeyframeOriginal);
m_currentKeyframeOriginal = -1; m_currentKeyframeOriginal = -1;
} else if (m_currentKeyframeOriginal > 0) { } else {
m_selectedKeyframes << m_currentKeyframeOriginal; m_selectedKeyframes << m_currentKeyframeOriginal;
} }
} else if (!m_selectedKeyframes.contains(m_currentKeyframeOriginal)) { } else if (!m_selectedKeyframes.contains(m_currentKeyframeOriginal)) {
...@@ -396,7 +396,9 @@ void KeyframeView::mouseMoveEvent(QMouseEvent *event) ...@@ -396,7 +396,9 @@ void KeyframeView::mouseMoveEvent(QMouseEvent *event)
int delta = pos - m_currentKeyframe; int delta = pos - m_currentKeyframe;
// Check that the move is possible // Check that the move is possible
for (int kf : m_selectedKeyframes) { for (int kf : m_selectedKeyframes) {
if (m_model->hasKeyframe(kf + offset + delta)) { int updatedPos = kf + offset + delta;
if (!m_selectedKeyframes.contains(updatedPos) && m_model->hasKeyframe(updatedPos)) {
// Don't allow moving over another keyframe
return; return;
} }
} }
...@@ -452,7 +454,7 @@ void KeyframeView::mouseMoveEvent(QMouseEvent *event) ...@@ -452,7 +454,7 @@ void KeyframeView::mouseMoveEvent(QMouseEvent *event)
if (event->y() < m_lineHeight) { if (event->y() < m_lineHeight) {
bool ok; bool ok;
auto keyframe = m_model->getClosestKeyframe(position, &ok); auto keyframe = m_model->getClosestKeyframe(position, &ok);
if (ok && qAbs(((position.frames(pCore->getCurrentFps()) - keyframe.first.frames(pCore->getCurrentFps())) * m_scale - m_zoomStart) * m_zoomFactor) < QApplication::startDragDistance()) { if (ok && qAbs(((position.frames(pCore->getCurrentFps()) - keyframe.first.frames(pCore->getCurrentFps())) * m_scale) * m_zoomFactor) < QApplication::startDragDistance()) {
m_hoverKeyframe = keyframe.first.frames(pCore->getCurrentFps()) - offset; m_hoverKeyframe = keyframe.first.frames(pCore->getCurrentFps()) - offset;
setCursor(Qt::PointingHandCursor); setCursor(Qt::PointingHandCursor);
m_hoverZoomIn = false; m_hoverZoomIn = false;
...@@ -689,9 +691,9 @@ void KeyframeView::paintEvent(QPaintEvent *event) ...@@ -689,9 +691,9 @@ void KeyframeView::paintEvent(QPaintEvent *event)
if (pos == m_currentKeyframe) { if (pos == m_currentKeyframe) {
p.setBrush(Qt::red); p.setBrush(Qt::red);
} else if (m_selectedKeyframes.contains(pos)) { } else if (m_selectedKeyframes.contains(pos)) {
p.setBrush(m_colSelected); p.setBrush(Qt::darkRed);
} else if (pos == m_currentKeyframe || pos == m_hoverKeyframe) { } else if (pos == m_currentKeyframe || pos == m_hoverKeyframe) {
p.setBrush(Qt::yellow); p.setBrush(m_colSelected);
} else { } else {
p.setBrush(m_colKeyframe); p.setBrush(m_colKeyframe);
} }
...@@ -796,9 +798,10 @@ void KeyframeView::copyCurrentValue(QModelIndex ix, const QString paramName) ...@@ -796,9 +798,10 @@ void KeyframeView::copyCurrentValue(QModelIndex ix, const QString paramName)
newVal = val; newVal = val;
parentCommand->setText(i18n("Update keyframes value")); parentCommand->setText(i18n("Update keyframes value"));
} }
qDebug()<<"=== UPDATED VAL: "<<newVal; bool result = m_model->updateKeyframe(GenTime(kf + offset, pCore->getCurrentFps()), newVal, ix, parentCommand);
m_model->updateKeyframe(GenTime(kf + offset, pCore->getCurrentFps()), newVal, ix, parentCommand); if (result) {
pCore->displayMessage(i18n("Keyframe value copied"), InformationMessage);
}
} }
pCore->pushUndo(parentCommand); pCore->pushUndo(parentCommand);
//m_model->copyCurrentValue(paramName);
} }
Markdown is supported
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