feat: socket hover colors
This commit is contained in:
@@ -21,7 +21,6 @@ void FloatingEdgeGraphic::paint(QPainter *painter, const QStyleOptionGraphicsIte
|
|||||||
{
|
{
|
||||||
// auto pen = QPen("white");
|
// auto pen = QPen("white");
|
||||||
|
|
||||||
std::cout << "draw\n";
|
|
||||||
QLinearGradient gradient(socket1_->scenePos(), floatPos_);
|
QLinearGradient gradient(socket1_->scenePos(), floatPos_);
|
||||||
gradient.setColorAt(0.0, QColor(255, 255, 255, 255));
|
gradient.setColorAt(0.0, QColor(255, 255, 255, 255));
|
||||||
gradient.setColorAt(1.0, QColor(255, 255, 255, 50));
|
gradient.setColorAt(1.0, QColor(255, 255, 255, 50));
|
||||||
@@ -35,7 +34,6 @@ void FloatingEdgeGraphic::paint(QPainter *painter, const QStyleOptionGraphicsIte
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FloatingEdgeGraphic::setFloatPos(QPointF floatPos) {
|
void FloatingEdgeGraphic::setFloatPos(QPointF floatPos) {
|
||||||
std::cout << "moving" << floatPos.x() << " " << floatPos.y() << "\n";
|
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
floatPos_ = floatPos;
|
floatPos_ = floatPos;
|
||||||
update();
|
update();
|
||||||
|
|||||||
@@ -6,7 +6,10 @@
|
|||||||
SocketGraphic::SocketGraphic(QGraphicsItem *parent)
|
SocketGraphic::SocketGraphic(QGraphicsItem *parent)
|
||||||
: QGraphicsItem(parent)
|
: QGraphicsItem(parent)
|
||||||
{
|
{
|
||||||
|
brushActive_ = QBrush("white");
|
||||||
|
brushInactive_ = QBrush("#9f9f9f");
|
||||||
socketSize_ = 3;
|
socketSize_ = 3;
|
||||||
|
setAcceptHoverEvents(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF SocketGraphic::boundingRect() const
|
QRectF SocketGraphic::boundingRect() const
|
||||||
@@ -18,11 +21,21 @@ QRectF SocketGraphic::boundingRect() const
|
|||||||
|
|
||||||
void SocketGraphic::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void SocketGraphic::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
{
|
{
|
||||||
QBrush whiteBrush = QBrush("white");
|
|
||||||
painter->setPen(Qt::NoPen);
|
painter->setPen(Qt::NoPen);
|
||||||
painter->setBrush(whiteBrush);
|
painter->setBrush(hovered_ ? brushActive_ : brushInactive_);
|
||||||
painter->drawEllipse(QPoint(0,0), socketSize_, socketSize_);
|
painter->drawEllipse(QPoint(0,0), socketSize_, socketSize_);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SocketGraphic::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
{
|
||||||
|
hovered_ = true;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SocketGraphic::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
{
|
||||||
|
hovered_ = false;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,5 +13,11 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int socketSize_ = 1;
|
int socketSize_ = 1;
|
||||||
|
QBrush brushInactive_;
|
||||||
|
QBrush brushActive_;
|
||||||
|
bool hovered_=false;
|
||||||
|
protected:
|
||||||
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
||||||
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user