diff --git a/app/node/block/block.cpp b/app/node/block/block.cpp index 41c9dff88..200073325 100644 --- a/app/node/block/block.cpp +++ b/app/node/block/block.cpp @@ -29,11 +29,13 @@ Block::Block() : next_(nullptr) { length_input_ = new NodeInput("length_in"); + length_input_->SetConnectable(false); length_input_->set_data_type(NodeParam::kRational); AddInput(length_input_); connect(length_input_, SIGNAL(ValueChanged(const rational&, const rational&)), this, SLOT(LengthInputChanged())); media_in_input_ = new NodeInput("media_in_in"); + media_in_input_->SetConnectable(false); media_in_input_->set_data_type(NodeParam::kRational); AddInput(media_in_input_); } diff --git a/app/node/param.cpp b/app/node/param.cpp index 2c01a2d25..3b1696b8e 100644 --- a/app/node/param.cpp +++ b/app/node/param.cpp @@ -32,7 +32,8 @@ #include "node/output.h" NodeParam::NodeParam(const QString &id) : - id_(id) + id_(id), + connectable_(true) { Q_ASSERT(!id_.isEmpty()); } @@ -91,6 +92,16 @@ bool NodeParam::IsConnected() return !edges_.isEmpty(); } +bool NodeParam::IsConnectable() const +{ + return connectable_; +} + +void NodeParam::SetConnectable(bool connectable) +{ + connectable_ = connectable; +} + const QVector &NodeParam::edges() { return edges_; @@ -105,6 +116,10 @@ void NodeParam::DisconnectAll() NodeEdgePtr NodeParam::ConnectEdge(NodeOutput *output, NodeInput *input, bool lock) { + if (!input->IsConnectable()) { + return nullptr; + } + // If the input can only accept one input (the default) and has one already, disconnect it DisconnectForNewOutput(input); diff --git a/app/node/param.h b/app/node/param.h index 1c84d612c..d2e6983fe 100644 --- a/app/node/param.h +++ b/app/node/param.h @@ -266,6 +266,9 @@ public: */ bool IsConnected(); + bool IsConnectable() const; + void SetConnectable(bool connectable); + /** * @brief Return a list of edges (aka connections to other nodes) * @@ -387,6 +390,11 @@ private: */ QString id_; + /** + * @brief Internal connectable value + */ + bool connectable_; + }; #endif // NODEPARAM_H diff --git a/app/widget/nodeview/nodeviewitem.cpp b/app/widget/nodeview/nodeviewitem.cpp index a08a7d91c..40eb6799e 100644 --- a/app/widget/nodeview/nodeviewitem.cpp +++ b/app/widget/nodeview/nodeviewitem.cpp @@ -199,8 +199,11 @@ void NodeViewItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti for (int i=0;iparameters().size();i++) { NodeParam* param = node_->parameters().at(i); - // Draw connector square - painter->fillRect(GetParameterConnectorRect(i), connector_brush); + // If parameter is not connectable, don't draw its slot + if (param->IsConnectable()) { + // Draw connector square + painter->fillRect(GetParameterConnectorRect(i), connector_brush); + } // Draw text QPointF text_pt = GetParameterTextPoint(i); @@ -380,7 +383,7 @@ void NodeViewItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) // Get the parameter we're dragging into NodeParam* comp_param = drop_item->node()->parameters().at(i); - if (param_hitbox.contains(drop_item->mapFromScene(event->scenePos()))) { // See if we're dragging inside the hitbox + if (comp_param->IsConnectable() && param_hitbox.contains(drop_item->mapFromScene(event->scenePos()))) { // See if we're dragging inside the hitbox // Prevent circular dependency - check if the Node we'll be outputting to already outputs to this Node Node* outputting_node;