From 16a4897236e36b92ee4832e457de64c15070b4c4 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Tue, 17 Sep 2019 21:25:00 +1000 Subject: [PATCH] minor improvements --- app/core.cpp | 7 ------- app/node/node.cpp | 34 ++++++++++++++++++++++++++++++++++ app/node/node.h | 22 ++++++++++++++++++++++ 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/app/core.cpp b/app/core.cpp index 2b90efdaa..a127c0cfd 100644 --- a/app/core.cpp +++ b/app/core.cpp @@ -310,13 +310,6 @@ void Core::CreateNewSequence() // Connect timeline end point to renderer NodeParam::ConnectEdge(tb->length_output(), rp->length_input()); - // FIXME: Test code - AlphaOverBlend* blend = new AlphaOverBlend(); - new_sequence->AddNode(blend); - OpacityNode* opac = new OpacityNode(); - new_sequence->AddNode(opac); - // End test code - vo->AttachViewer(olive::panel_focus_manager->MostRecentlyFocused()); tb->AttachTimeline(olive::panel_focus_manager->MostRecentlyFocused()); olive::panel_focus_manager->MostRecentlyFocused()->SetGraph(new_sequence.get()); diff --git a/app/node/node.cpp b/app/node/node.cpp index 4159093b3..e62e732fe 100644 --- a/app/node/node.cpp +++ b/app/node/node.cpp @@ -327,6 +327,26 @@ bool Node::OutputsTo(Node *n) return false; } +bool Node::HasInputs() +{ + return HasParamOfType(NodeParam::kInput, false); +} + +bool Node::HasOutputs() +{ + return HasParamOfType(NodeParam::kOutput, false); +} + +bool Node::HasConnectedInputs() +{ + return HasParamOfType(NodeParam::kInput, true); +} + +bool Node::HasConnectedOutputs() +{ + return HasParamOfType(NodeParam::kOutput, true); +} + void Node::Hash(QCryptographicHash *hash, NodeOutput* from, const rational &time) { // Add this Node's ID @@ -373,6 +393,20 @@ bool Node::HasParamWithID(const QString &id) return false; } +bool Node::HasParamOfType(NodeParam::Type type, bool must_be_connected) +{ + QList params = parameters(); + + foreach (NodeParam* p, params) { + if (p->type() == type + && (p->IsConnected() || !must_be_connected)) { + return true; + } + } + + return false; +} + void Node::InputChanged(rational start, rational end) { InvalidateCache(start, end, static_cast(sender())); diff --git a/app/node/node.h b/app/node/node.h index 571339afb..39c31a37b 100644 --- a/app/node/node.h +++ b/app/node/node.h @@ -153,6 +153,26 @@ public: */ bool OutputsTo(Node* n); + /** + * @brief Return whether this Node has input parameters + */ + bool HasInputs(); + + /** + * @brief Return whether this Node has output parameters + */ + bool HasOutputs(); + + /** + * @brief Return whether this Node has input parameters and at least one of them is connected + */ + bool HasConnectedInputs(); + + /** + * @brief Return whether this Node has output parameters and at least one of them is connected + */ + bool HasConnectedOutputs(); + /** * @brief Add's unique information about this Node at the given time to a QCryptographicHash */ @@ -270,6 +290,8 @@ private: */ bool HasParamWithID(const QString& id); + bool HasParamOfType(NodeParam::Type type, bool must_be_connected); + /** * @brief The last timecode Process() was called with */