feat: connect nodes

This commit is contained in:
parker
2025-06-21 03:00:38 +01:00
parent a6a0bec1c0
commit 38508293ff
6 changed files with 59 additions and 14 deletions

View File

@@ -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);