Skip to content

Commit dea439b

Browse files
authored
Merge pull request #7 from fabns-nano/codex/expose-setbackgroundcolor-method
Add setBackgroundColor support
2 parents 21b55ac + 87e219b commit dea439b

File tree

5 files changed

+29
-1
lines changed

5 files changed

+29
-1
lines changed

include/QtNodes/internal/NodeDelegateModel.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "Export.hpp"
1010
#include "NodeData.hpp"
1111
#include "NodeStyle.hpp"
12+
#include <QtGui/QColor>
1213
#include "Serializable.hpp"
1314

1415
namespace 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+
105109
public:
106110
virtual void setInData(std::shared_ptr<NodeData> nodeData, PortIndex const portIndex) = 0;
107111

include/QtNodes/internal/NodeStyle.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
2935
public:
3036
QColor NormalBoundaryColor;
3137
QColor SelectedBoundaryColor;

include/QtNodes/internal/UndoCommands.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
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

src/NodeDelegateModel.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff 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

src/NodeStyle.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
}

0 commit comments

Comments
 (0)