nodeviewedge: use bezier curves instead of straight lines

This commit is contained in:
itsmattkc
2020-02-26 01:07:53 +11:00
parent 785160b86b
commit 7e7ff49777
3 changed files with 50 additions and 37 deletions
+11 -6
View File
@@ -21,7 +21,8 @@
#ifndef NODEEDGEITEM_H
#define NODEEDGEITEM_H
#include <QGraphicsLineItem>
#include <QGraphicsPathItem>
#include <QPalette>
#include "node/edge.h"
@@ -30,7 +31,7 @@
*
* A fairly simple line widget use to visualize a connection between two node parameters (a NodeEdge).
*/
class NodeViewEdge : public QGraphicsLineItem
class NodeViewEdge : public QGraphicsPathItem
{
public:
NodeViewEdge(QGraphicsItem* parent = nullptr);
@@ -75,17 +76,21 @@ public:
*/
void SetHighlighted(bool e);
protected:
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
/**
* @brief Set points to create curve from
*/
void SetPoints(const QPointF& start, const QPointF& end);
private:
void UpdatePen();
NodeEdgePtr edge_;
int edge_width_;
bool connected_;
QPalette::ColorGroup color_group_;
bool highlighted_;
QPalette::ColorRole color_role_;
};