feat: connect nodes
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
#include <iostream>
|
||||
#include <qgraphicsitem.h>
|
||||
|
||||
SocketGraphic::SocketGraphic(QGraphicsItem *parent)
|
||||
: QGraphicsItem(parent)
|
||||
SocketGraphic::SocketGraphic(SocketGraphic::SocketType type, QGraphicsItem *parent)
|
||||
: QGraphicsItem(parent), type_{type}
|
||||
{
|
||||
brushActive_ = QBrush("white");
|
||||
brushInactive_ = QBrush("#9f9f9f");
|
||||
@@ -15,10 +15,18 @@ SocketGraphic::SocketGraphic(QGraphicsItem *parent)
|
||||
QRectF SocketGraphic::boundingRect() const
|
||||
{
|
||||
float paddingScale = 10;
|
||||
auto boundRect = QRect(-socketSize_/2.0f*paddingScale, -socketSize_/2.0f*paddingScale, socketSize_*paddingScale, socketSize_*paddingScale);
|
||||
auto boundRect = QRect(
|
||||
-socketSize_/2.0f*paddingScale,
|
||||
type_==SocketType::Input ? -socketSize_/2.0f*paddingScale : 0,
|
||||
socketSize_*paddingScale,
|
||||
socketSize_/2.0f*paddingScale
|
||||
);
|
||||
return boundRect;
|
||||
}
|
||||
|
||||
SocketGraphic::SocketType SocketGraphic::getIO() { return type_; }
|
||||
|
||||
|
||||
void SocketGraphic::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
painter->setPen(Qt::NoPen);
|
||||
|
||||
Reference in New Issue
Block a user