nodes: allow inserting inputs at arbitrary indexes

This commit is contained in:
itsmattkc
2021-04-13 13:06:52 +10:00
parent e141b486ae
commit 2ff04f2045
3 changed files with 21 additions and 5 deletions
+3 -3
View File
@@ -1245,7 +1245,7 @@ bool Node::AreLinked(Node *a, Node *b)
return a->links_.contains(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()) { if (id.isEmpty()) {
qWarning() << "Rejected adding input with an empty ID on node" << this->id(); qWarning() << "Rejected adding input with an empty ID on node" << this->id();
@@ -1264,8 +1264,8 @@ void Node::AddInput(const QString &id, NodeValue::Type type, const QVariant &def
i.flags = flags; i.flags = flags;
i.array_size = 0; i.array_size = 0;
input_ids_.append(id); input_ids_.insert(index, id);
input_data_.append(i); input_data_.insert(index, i);
if (!standard_immediates_.value(id, nullptr)) { if (!standard_immediates_.value(id, nullptr)) {
standard_immediates_.insert(id, CreateImmediate(id)); standard_immediates_.insert(id, CreateImmediate(id));
+17 -1
View File
@@ -799,7 +799,23 @@ protected:
}; };
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)) void AddInput(const QString& id, NodeValue::Type type, InputFlags flags = InputFlags(kInputFlagNormal))
{ {
AddInput(id, type, QVariant(), flags); AddInput(id, type, QVariant(), flags);
+1 -1
View File
@@ -43,7 +43,7 @@ Footage::Footage(const QString &filename) :
ViewerOutput(false), ViewerOutput(false),
cancelled_(nullptr) cancelled_(nullptr)
{ {
AddInput(kFilenameInput, NodeValue::kFile, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable)); PrependInput(kFilenameInput, NodeValue::kFile, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
Clear(); Clear();