nodeparamview: make keyframes on every key track by default
Fixes #1437
This commit is contained in:
@@ -36,7 +36,7 @@ bool NodeInputDragger::IsStarted() const
|
||||
return input_.IsValid();
|
||||
}
|
||||
|
||||
void NodeInputDragger::Start(const NodeKeyframeTrackReference &input, const rational &time)
|
||||
void NodeInputDragger::Start(const NodeKeyframeTrackReference &input, const rational &time, bool create_key_on_all_tracks)
|
||||
{
|
||||
Q_ASSERT(!IsStarted());
|
||||
|
||||
@@ -52,9 +52,8 @@ void NodeInputDragger::Start(const NodeKeyframeTrackReference &input, const rati
|
||||
// Determine whether we are creating a keyframe or not
|
||||
if (input_.input().IsKeyframing()) {
|
||||
dragging_key_ = node->GetKeyframeAtTimeOnTrack(input_, time);
|
||||
drag_created_key_ = !dragging_key_;
|
||||
|
||||
if (drag_created_key_) {
|
||||
if (!dragging_key_) {
|
||||
dragging_key_ = new NodeKeyframe(time,
|
||||
start_value_,
|
||||
node->GetBestKeyframeTypeForTimeOnTrack(input_, time),
|
||||
@@ -62,6 +61,19 @@ void NodeInputDragger::Start(const NodeKeyframeTrackReference &input, const rati
|
||||
input_.input().element(),
|
||||
input_.input().input(),
|
||||
node);
|
||||
created_keys_.append(dragging_key_);
|
||||
|
||||
if (create_key_on_all_tracks) {
|
||||
int nb_tracks = NodeValue::get_number_of_keyframe_tracks(input.input().node()->GetInputDataType(input.input().input()));
|
||||
for (int i=0; i<nb_tracks; i++) {
|
||||
if (i != input.track()) {
|
||||
NodeKeyframeTrackReference this_ref(input.input(), i);
|
||||
created_keys_.append(new NodeKeyframe(time, node->GetSplitValueAtTimeOnTrack(this_ref, time),
|
||||
node->GetBestKeyframeTypeForTimeOnTrack(this_ref, time),
|
||||
i, input.input().element(), input.input().input(), node));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,9 +124,9 @@ void NodeInputDragger::End()
|
||||
MultiUndoCommand* command = new MultiUndoCommand();
|
||||
|
||||
if (input_.input().node()->IsInputKeyframing(input_.input())) {
|
||||
if (drag_created_key_) {
|
||||
for (int i=0; i<created_keys_.size(); i++) {
|
||||
// We created a keyframe in this process
|
||||
command->add_child(new NodeParamInsertKeyframeCommand(input_.input().node(), dragging_key_));
|
||||
command->add_child(new NodeParamInsertKeyframeCommand(input_.input().node(), created_keys_.at(i)));
|
||||
}
|
||||
|
||||
// We just set a keyframe's value
|
||||
@@ -129,6 +141,7 @@ void NodeInputDragger::End()
|
||||
Core::instance()->undo_stack()->push(command);
|
||||
|
||||
input_.Reset();
|
||||
created_keys_.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
|
||||
bool IsStarted() const;
|
||||
|
||||
void Start(const NodeKeyframeTrackReference& input, const rational& time);
|
||||
void Start(const NodeKeyframeTrackReference& input, const rational& time, bool create_key_on_all_tracks = true);
|
||||
|
||||
void Drag(QVariant value);
|
||||
|
||||
@@ -50,8 +50,7 @@ private:
|
||||
QVariant end_value_;
|
||||
|
||||
NodeKeyframe* dragging_key_;
|
||||
|
||||
bool drag_created_key_;
|
||||
QVector<NodeKeyframe*> created_keys_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -207,14 +207,25 @@ void NodeParamViewWidgetBridge::SetInputValueInternal(const QVariant &value, int
|
||||
command->add_child(new NodeParamSetKeyframeValueCommand(existing_key, value));
|
||||
} else {
|
||||
// No existing key, create a new one
|
||||
NodeKeyframe* new_key = new NodeKeyframe(node_time,
|
||||
value,
|
||||
input_.node()->GetBestKeyframeTypeForTimeOnTrack(NodeKeyframeTrackReference(input_, track), node_time),
|
||||
track,
|
||||
input_.element(),
|
||||
input_.input());
|
||||
int nb_tracks = NodeValue::get_number_of_keyframe_tracks(input_.node()->GetInputDataType(input_.input()));
|
||||
for (int i=0; i<nb_tracks; i++) {
|
||||
QVariant track_value;
|
||||
|
||||
command->add_child(new NodeParamInsertKeyframeCommand(input_.node(), new_key));
|
||||
if (i == track) {
|
||||
track_value = value;
|
||||
} else {
|
||||
track_value = input_.node()->GetValueAtTime(input_.input(), node_time, input_.element());
|
||||
}
|
||||
|
||||
NodeKeyframe* new_key = new NodeKeyframe(node_time,
|
||||
track_value,
|
||||
input_.node()->GetBestKeyframeTypeForTimeOnTrack(NodeKeyframeTrackReference(input_, i), node_time),
|
||||
i,
|
||||
input_.element(),
|
||||
input_.input());
|
||||
|
||||
command->add_child(new NodeParamInsertKeyframeCommand(input_.node(), new_key));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
command->add_child(new NodeParamSetStandardValueCommand(NodeKeyframeTrackReference(input_, track), value));
|
||||
|
||||
Reference in New Issue
Block a user