feat: socket padding, fix floating edge start pos

This commit is contained in:
parker
2025-06-21 01:25:47 +01:00
parent 1cfcb0e429
commit b10f9322b2
4 changed files with 6 additions and 4 deletions

View File

@@ -53,13 +53,14 @@ Network::Network(QWidget* parent)
mainLayout_->addWidget(view_);
}
void Network::socketClicked(SocketGraphic* socket)
void Network::socketClicked(SocketGraphic* socket, QMouseEvent *event)
{
std::cout << "socket clicked\n";
if(!floatingEdge_)
{
std::cout << "creating floating edge\n";
floatingEdge_ = new FloatingEdgeGraphic(socket);
floatingEdge_->setFloatPos(view_->mapToScene(event->pos()));
scene_->addItem(floatingEdge_);
}
}

View File

@@ -10,7 +10,7 @@ class Network
{
public:
Network(QWidget* parent = nullptr);
void socketClicked(SocketGraphic* socket);
void socketClicked(SocketGraphic* socket, QMouseEvent *event);
void mouseMoved(QMouseEvent *event);
private:
QLayout* mainLayout_;

View File

@@ -61,7 +61,7 @@ void NetworkGraphicsView::leftMousePress(QMouseEvent *event)
if(isSocket)
{
std::cout << "SOCKET!\n";
network_->socketClicked(static_cast<SocketGraphic*>(itemClicked));
network_->socketClicked(static_cast<SocketGraphic*>(itemClicked), event);
}
}

View File

@@ -11,7 +11,8 @@ SocketGraphic::SocketGraphic(QGraphicsItem *parent)
QRectF SocketGraphic::boundingRect() const
{
auto boundRect = QRect(-socketSize_/2, -socketSize_/2, socketSize_, socketSize_);
float paddingScale = 10;
auto boundRect = QRect(-socketSize_/2.0f*paddingScale, -socketSize_/2.0f*paddingScale, socketSize_*paddingScale, socketSize_*paddingScale);
return boundRect;
}