Skip to content

Commit

Permalink
nodes: allow inserting inputs at arbitrary indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmattkc committed Apr 13, 2021
1 parent e141b48 commit 2ff04f2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@ bool Node::AreLinked(Node *a, Node *b)
return a->links_.contains(b);
}

void Node::AddInput(const QString &id, NodeValue::Type type, const QVariant &default_value, Node::InputFlags flags)
void Node::InsertInput(const QString &id, NodeValue::Type type, const QVariant &default_value, Node::InputFlags flags, int index)
{
if (id.isEmpty()) {
qWarning() << "Rejected adding input with an empty ID on node" << this->id();
Expand All @@ -1264,8 +1264,8 @@ void Node::AddInput(const QString &id, NodeValue::Type type, const QVariant &def
i.flags = flags;
i.array_size = 0;

input_ids_.append(id);
input_data_.append(i);
input_ids_.insert(index, id);
input_data_.insert(index, i);

if (!standard_immediates_.value(id, nullptr)) {
standard_immediates_.insert(id, CreateImmediate(id));
Expand Down
18 changes: 17 additions & 1 deletion app/node/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,23 @@ class Node : public QObject

};

void AddInput(const QString& id, NodeValue::Type type, const QVariant& default_value, InputFlags flags = InputFlags(kInputFlagNormal));
void InsertInput(const QString& id, NodeValue::Type type, const QVariant& default_value, InputFlags flags, int index);

void PrependInput(const QString& id, NodeValue::Type type, const QVariant& default_value, InputFlags flags = InputFlags(kInputFlagNormal))
{
InsertInput(id, type, default_value, flags, 0);
}

void PrependInput(const QString& id, NodeValue::Type type, InputFlags flags = InputFlags(kInputFlagNormal))
{
PrependInput(id, type, QVariant(), flags);
}

void AddInput(const QString& id, NodeValue::Type type, const QVariant& default_value, InputFlags flags = InputFlags(kInputFlagNormal))
{
InsertInput(id, type, default_value, flags, input_ids_.size());
}

void AddInput(const QString& id, NodeValue::Type type, InputFlags flags = InputFlags(kInputFlagNormal))
{
AddInput(id, type, QVariant(), flags);
Expand Down
2 changes: 1 addition & 1 deletion app/node/project/footage/footage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Footage::Footage(const QString &filename) :
ViewerOutput(false),
cancelled_(nullptr)
{
AddInput(kFilenameInput, NodeValue::kFile, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
PrependInput(kFilenameInput, NodeValue::kFile, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));

Clear();

Expand Down

0 comments on commit 2ff04f2

Please sign in to comment.