implemented the ability to make inputs that can't be connected
This commit is contained in:
@@ -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_);
|
||||
}
|
||||
|
||||
+16
-1
@@ -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<NodeEdgePtr> &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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -199,8 +199,11 @@ void NodeViewItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
for (int i=0;i<node_->parameters().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;
|
||||
|
||||
Reference in New Issue
Block a user