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

Keyframes: moving a keyframe in timeline will also move other selected keyframes

parent 12cbd496
Pipeline #93358 canceled with stage
......@@ -220,6 +220,12 @@ bool KeyframeModel::moveKeyframe(GenTime oldPos, GenTime pos, QVariant newVal, F
if (auto ptr = m_model.lock()) {
if (ptr->m_selectedKeyframes.size() > 1) {
// We have several selected keyframes, move them all
double offset = 0.;
if (newVal.isValid() && newVal.type() == QVariant::Double) {
int row = static_cast<int>(std::distance(m_keyframeList.begin(), m_keyframeList.find(oldPos)));
double oldVal = data(index(row), NormalizedValueRole).toDouble();
offset = newVal.toDouble() - oldVal;
}
QVector<GenTime> positions;
for (auto &kf : ptr->m_selectedKeyframes) {
if (kf > 0) {
......@@ -259,7 +265,14 @@ bool KeyframeModel::moveKeyframe(GenTime oldPos, GenTime pos, QVariant newVal, F
if (p == oldPos) {
res = res && moveOneKeyframe(oldPos, oldPos + delta, newVal, undo, redo, updateView);
} else {
res = res && moveOneKeyframe(p, p + delta, QVariant(), undo, redo, updateView);
if (!qFuzzyIsNull(offset)) {
// Calculate new value
int row = static_cast<int>(std::distance(m_keyframeList.begin(), m_keyframeList.find(p)));
double newVal2 = qBound(0., data(index(row), NormalizedValueRole).toDouble() + offset, 1.);
res = res && moveOneKeyframe(p, p + delta, newVal2, undo, redo, updateView);
} else {
res = res && moveOneKeyframe(p, p + delta, QVariant(), undo, redo, updateView);
}
}
}
return res;
......
......@@ -164,7 +164,7 @@ Rectangle
}
}
onEntered: {
timeline.showKeyBinding(i18n("<b>Shift drag</b> to move all keyframes after this one."))
timeline.showKeyBinding(i18n("<b>Drag</b> to move selected keyframes position. <b>Shift drag</b> to move all keyframes after this one."))
}
onExited: {
timeline.showKeyBinding()
......@@ -272,7 +272,7 @@ Rectangle
resetSelection()
}
onEntered: {
timeline.showKeyBinding(i18n("<b>Shift drag</b> to change value only, <b>Ctrl click</b> for multiple keyframe selection."))
timeline.showKeyBinding(i18n("<b>Shift drag</b> to change value of selected keyframes, <b>Ctrl click</b> for multiple keyframe selection."))
}
onExited: {
timeline.showKeyBinding()
......
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