improved connector UI in node view

This commit is contained in:
itsmattkc
2021-11-10 21:59:54 -08:00
parent 9c650883c2
commit 6033039046
15 changed files with 352 additions and 148 deletions
+18 -4
View File
@@ -28,6 +28,7 @@
#include "node/node.h"
#include "nodeviewcommon.h"
#include "nodeviewitemconnector.h"
namespace olive {
@@ -40,8 +41,9 @@ class NodeViewEdge;
*
* To retrieve the NodeViewItem for a certain Node, use NodeView::NodeToUIObject().
*/
class NodeViewItem : public QGraphicsRectItem
class NodeViewItem : public QObject, public QGraphicsRectItem
{
Q_OBJECT
public:
NodeViewItem(QGraphicsItem* parent = nullptr);
@@ -125,11 +127,13 @@ public:
return prevent_removing_;
}
const QPolygonF &GetOutputTriangle() const
QPolygonF GetOutputTriangle() const
{
return output_triangle_;
return output_connector_->polygon();
}
void SetLabelAsOutput(bool e);
protected:
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
@@ -143,6 +147,8 @@ protected:
private:
void ReadjustAllEdges();
void UpdateContextRect();
void DrawNodeTitle(QPainter *painter, QString text, const QRectF &rect, Qt::Alignment vertical_align, int icon_size, bool draw_arrow);
/**
@@ -160,6 +166,8 @@ private:
*/
void UpdateNodePosition();
void UpdateConnectorPositions();
/**
* @brief Reference to attached Node
*/
@@ -195,7 +203,13 @@ private:
bool prevent_removing_;
QPolygonF output_triangle_;
NodeViewItemConnector *input_connector_;
NodeViewItemConnector *output_connector_;
bool label_as_output_;
private slots:
void NodeAppearanceChanged();
};