keyframes: implemented same single frame strategy on bezier control points

This commit is contained in:
itsmattkc
2020-01-25 18:00:35 +11:00
parent b713ab47eb
commit 0e82ec600d
+30 -10
View File
@@ -97,9 +97,6 @@ void KeyframeViewBase::mousePressEvent(QMouseEvent *event)
for (int i=0;i<selected_items.size();i++) {
KeyframeViewItem* key = static_cast<KeyframeViewItem*>(selected_items.at(i));
// Block signals for dragging for now
key->key()->parent()->blockSignals(true);
selected_keys_.replace(i, {key, key->x(), key->key()->time(), key->key()->value().toDouble()});
}
}
@@ -127,6 +124,8 @@ void KeyframeViewBase::mouseMoveEvent(QMouseEvent *event)
false);
} else if (!selected_keys_.isEmpty()) {
foreach (const KeyframeItemAndTime& keypair, selected_keys_) {
keypair.key->key()->parent()->blockSignals(true);
keypair.key->key()->set_time(CalculateNewTimeFromScreen(keypair.time, mouse_diff_scaled.x()));
if (y_axis_enabled_) {
@@ -136,8 +135,8 @@ void KeyframeViewBase::mouseMoveEvent(QMouseEvent *event)
// We emit a custom value changed signal while the keyframe is being dragged so only the currently viewed
// frame gets rendered in this time
keypair.key->key()->parent()->blockSignals(false);
emit keypair.key->key()->parent()->ValueChanged(GetPlayheadTime(), GetPlayheadTime());
keypair.key->key()->parent()->blockSignals(true);
}
}
}
@@ -170,6 +169,8 @@ void KeyframeViewBase::mouseReleaseEvent(QMouseEvent *event)
foreach (const KeyframeItemAndTime& keypair, selected_keys_) {
KeyframeViewItem* item = keypair.key;
keypair.key->key()->parent()->blockSignals(true);
// Calculate the new time for this keyframe
rational new_time = CalculateNewTimeFromScreen(keypair.time, mouse_diff_scaled.x());
@@ -280,15 +281,17 @@ void KeyframeViewBase::ProcessBezierDrag(QPointF mouse_diff_scaled, bool include
new_opposing_pos = dragging_bezier_point_opposing_start_;
}
dragging_bezier_point_->key()->set_bezier_control(dragging_bezier_point_->mode(),
new_bezier_pos);
dragging_bezier_point_->key()->set_bezier_control(opposing_type,
new_opposing_pos);
if (undoable) {
QUndoCommand* command = new QUndoCommand();
// Similar to the code in MouseRelease, we manipulated the signalling earlier and need to set the keys back to their
// original position to allow the input to signal correctly when the undo command is pushed.
dragging_bezier_point_->key()->parent()->blockSignals(true);
dragging_bezier_point_->key()->set_bezier_control(dragging_bezier_point_->mode(),
dragging_bezier_point_start_);
new KeyframeSetBezierControlPoint(dragging_bezier_point_->key(),
dragging_bezier_point_->mode(),
new_bezier_pos,
@@ -296,6 +299,9 @@ void KeyframeViewBase::ProcessBezierDrag(QPointF mouse_diff_scaled, bool include
command);
if (include_opposing) {
dragging_bezier_point_->key()->set_bezier_control(opposing_type,
dragging_bezier_point_opposing_start_);
new KeyframeSetBezierControlPoint(dragging_bezier_point_->key(),
opposing_type,
new_opposing_pos,
@@ -303,7 +309,21 @@ void KeyframeViewBase::ProcessBezierDrag(QPointF mouse_diff_scaled, bool include
command);
}
dragging_bezier_point_->key()->parent()->blockSignals(false);
Core::instance()->undo_stack()->push(command);
} else {
dragging_bezier_point_->key()->parent()->blockSignals(true);
dragging_bezier_point_->key()->set_bezier_control(dragging_bezier_point_->mode(),
new_bezier_pos);
dragging_bezier_point_->key()->set_bezier_control(opposing_type,
new_opposing_pos);
dragging_bezier_point_->key()->parent()->blockSignals(false);
emit dragging_bezier_point_->key()->parent()->ValueChanged(GetPlayheadTime(), GetPlayheadTime());
}
}