Skip to content

Commit ba099ee

Browse files
authored
Add entire setBackgroundColor dynamics (#504)
1 parent c52d977 commit ba099ee

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

include/QtNodes/internal/NodeDelegateModel.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <QMetaType>
66
#include <QPixmap>
7+
#include <QtGui/QColor>
78
#include <QtWidgets/QWidget>
89

910
#include "Definitions.hpp"
@@ -103,6 +104,9 @@ class NODE_EDITOR_PUBLIC NodeDelegateModel
103104

104105
void setNodeStyle(NodeStyle const &style);
105106

107+
/// Convenience helper to change the node background color.
108+
void setBackgroundColor(QColor const &color);
109+
106110
QPixmap processingStatusIcon() const;
107111

108112
void setStatusIcon(NodeProcessingStatus status, const QPixmap &pixmap);

include/QtNodes/internal/NodeStyle.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ class NODE_EDITOR_PUBLIC NodeStyle : public Style
4646

4747
QJsonObject toJson() const override;
4848

49+
/// Set uniform background color for the node.
50+
void setBackgroundColor(QColor const &color);
51+
52+
/// Current uniform background color.
53+
QColor backgroundColor() const;
54+
4955
public:
5056
QColor NormalBoundaryColor;
5157
QColor SelectedBoundaryColor;

src/NodeDelegateModel.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,9 @@ void NodeDelegateModel::setNodeProcessingStatus(NodeProcessingStatus status)
115115
_processingStatus = status;
116116
}
117117

118+
void NodeDelegateModel::setBackgroundColor(QColor const &color)
119+
{
120+
_nodeStyle.setBackgroundColor(color);
121+
}
122+
118123
} // namespace QtNodes

src/NodeStyle.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,16 @@ QJsonObject NodeStyle::toJson() const
156156

157157
return root;
158158
}
159+
160+
void NodeStyle::setBackgroundColor(QColor const &color)
161+
{
162+
GradientColor0 = color;
163+
GradientColor1 = color;
164+
GradientColor2 = color;
165+
GradientColor3 = color;
166+
}
167+
168+
QColor NodeStyle::backgroundColor() const
169+
{
170+
return GradientColor0;
171+
}

0 commit comments

Comments
 (0)