feat: socket padding, fix floating edge start pos
This commit is contained in:
@@ -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_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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_;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user