File tree Expand file tree Collapse file tree 5 files changed +29
-1
lines changed
Expand file tree Collapse file tree 5 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 99#include " Export.hpp"
1010#include " NodeData.hpp"
1111#include " NodeStyle.hpp"
12+ #include < QtGui/QColor>
1213#include " Serializable.hpp"
1314
1415namespace QtNodes {
@@ -102,6 +103,9 @@ class NODE_EDITOR_PUBLIC NodeDelegateModel
102103
103104 void setNodeStyle (NodeStyle const &style);
104105
106+ // / Convenience helper to change the node background color.
107+ void setBackgroundColor (QColor const &color);
108+
105109public:
106110 virtual void setInData (std::shared_ptr<NodeData> nodeData, PortIndex const portIndex) = 0;
107111
Original file line number Diff line number Diff line change @@ -26,6 +26,12 @@ class NODE_EDITOR_PUBLIC NodeStyle : public Style
2626
2727 QJsonObject toJson () const override ;
2828
29+ // / Set uniform background color for the node.
30+ void setBackgroundColor (QColor const &color);
31+
32+ // / Current uniform background color.
33+ QColor backgroundColor () const ;
34+
2935public:
3036 QColor NormalBoundaryColor;
3137 QColor SelectedBoundaryColor;
Original file line number Diff line number Diff line change 33#include " Definitions.hpp"
44#include " Export.hpp"
55
6+ #include < QUndoCommand>
67#include < QtCore/QJsonObject>
78#include < QtCore/QPointF>
8- #include < QUndoCommand>
99
1010#include < unordered_set>
1111
Original file line number Diff line number Diff line change @@ -61,4 +61,9 @@ void NodeDelegateModel::setNodeProcessingStatus(NodeProcessingStatus status)
6161 _processingStatus = status;
6262}
6363
64+ void NodeDelegateModel::setBackgroundColor (QColor const &color)
65+ {
66+ _nodeStyle.setBackgroundColor (color);
67+ }
68+
6469} // namespace QtNodes
Original file line number Diff line number Diff line change @@ -157,3 +157,16 @@ QJsonObject NodeStyle::toJson() const
157157
158158 return root;
159159}
160+
161+ void NodeStyle::setBackgroundColor (QColor const &color)
162+ {
163+ GradientColor0 = color;
164+ GradientColor1 = color;
165+ GradientColor2 = color;
166+ GradientColor3 = color;
167+ }
168+
169+ QColor NodeStyle::backgroundColor () const
170+ {
171+ return GradientColor0;
172+ }
You can’t perform that action at this time.
0 commit comments