From 52d808a245eff86ebd2be31c4c7571acdbe71ff3 Mon Sep 17 00:00:00 2001 From: g-abilio Date: Mon, 8 Dec 2025 12:36:10 -0300 Subject: [PATCH] add entire setBackgroundColor dynamics --- include/QtNodes/internal/NodeDelegateModel.hpp | 4 ++++ include/QtNodes/internal/NodeStyle.hpp | 6 ++++++ src/NodeDelegateModel.cpp | 5 +++++ src/NodeStyle.cpp | 13 +++++++++++++ 4 files changed, 28 insertions(+) diff --git a/include/QtNodes/internal/NodeDelegateModel.hpp b/include/QtNodes/internal/NodeDelegateModel.hpp index 8730805c..04cc78a1 100644 --- a/include/QtNodes/internal/NodeDelegateModel.hpp +++ b/include/QtNodes/internal/NodeDelegateModel.hpp @@ -4,6 +4,7 @@ #include #include +#include #include #include "Definitions.hpp" @@ -103,6 +104,9 @@ class NODE_EDITOR_PUBLIC NodeDelegateModel void setNodeStyle(NodeStyle const &style); + /// Convenience helper to change the node background color. + void setBackgroundColor(QColor const &color); + QPixmap processingStatusIcon() const; void setStatusIcon(NodeProcessingStatus status, const QPixmap &pixmap); diff --git a/include/QtNodes/internal/NodeStyle.hpp b/include/QtNodes/internal/NodeStyle.hpp index 9ecd953c..f3fb04bb 100644 --- a/include/QtNodes/internal/NodeStyle.hpp +++ b/include/QtNodes/internal/NodeStyle.hpp @@ -46,6 +46,12 @@ class NODE_EDITOR_PUBLIC NodeStyle : public Style QJsonObject toJson() const override; + /// Set uniform background color for the node. + void setBackgroundColor(QColor const &color); + + /// Current uniform background color. + QColor backgroundColor() const; + public: QColor NormalBoundaryColor; QColor SelectedBoundaryColor; diff --git a/src/NodeDelegateModel.cpp b/src/NodeDelegateModel.cpp index 81f1d08c..fc8f3e8d 100644 --- a/src/NodeDelegateModel.cpp +++ b/src/NodeDelegateModel.cpp @@ -115,4 +115,9 @@ void NodeDelegateModel::setNodeProcessingStatus(NodeProcessingStatus status) _processingStatus = status; } +void NodeDelegateModel::setBackgroundColor(QColor const &color) +{ + _nodeStyle.setBackgroundColor(color); +} + } // namespace QtNodes diff --git a/src/NodeStyle.cpp b/src/NodeStyle.cpp index 2c232fb4..4b469ea1 100644 --- a/src/NodeStyle.cpp +++ b/src/NodeStyle.cpp @@ -156,3 +156,16 @@ QJsonObject NodeStyle::toJson() const return root; } + +void NodeStyle::setBackgroundColor(QColor const &color) +{ + GradientColor0 = color; + GradientColor1 = color; + GradientColor2 = color; + GradientColor3 = color; +} + +QColor NodeStyle::backgroundColor() const +{ + return GradientColor0; +}