Skip to content

Commit b56a7d0

Browse files
Grozamirpaceholder
authored andcommitted
Optimizing performance | Add shadow enabler
1 parent f5aad28 commit b56a7d0

6 files changed

Lines changed: 19 additions & 0 deletions

File tree

docs/features.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ the moment of writing this documentation.
196196
"GradientColor2": [64, 64, 64],
197197
"GradientColor3": [58, 58, 58],
198198
"ShadowColor": [20, 20, 20],
199+
"ShadowEnabled": false,
199200
"FontColor" : "white",
200201
"FontColorFaded" : "gray",
201202
"ConnectionPointColor": [169, 169, 169],

examples/styles/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ static void setStyle()
5252
"GradientColor2": "mintcream",
5353
"GradientColor3": "mintcream",
5454
"ShadowColor": [200, 200, 200],
55+
"ShadowEnabled": true,
5556
"FontColor": [10, 10, 10],
5657
"FontColorFaded": [100, 100, 100],
5758
"ConnectionPointColor": "white",

include/QtNodes/internal/NodeStyle.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class NODE_EDITOR_PUBLIC NodeStyle : public Style
3434
QColor GradientColor2;
3535
QColor GradientColor3;
3636
QColor ShadowColor;
37+
bool ShadowEnabled;
3738
QColor FontColor;
3839
QColor FontColorFaded;
3940

resources/DefaultStyle.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"GradientColor2": [64, 64, 64],
1313
"GradientColor3": [58, 58, 58],
1414
"ShadowColor": [20, 20, 20],
15+
"ShadowEnabled": false,
1516
"FontColor" : "white",
1617
"FontColorFaded" : "gray",
1718
"ConnectionPointColor": [169, 169, 169],

src/NodeGraphicsObject.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ NodeGraphicsObject::NodeGraphicsObject(BasicGraphicsScene &scene, NodeId nodeId)
3737

3838
NodeStyle nodeStyle(nodeStyleJson);
3939

40+
if(nodeStyle.ShadowEnabled)
4041
{
4142
auto effect = new QGraphicsDropShadowEffect;
4243
effect->setOffset(4, 4);

src/NodeStyle.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,18 @@ void NodeStyle::setNodeStyle(QString jsonText)
8888
values[#variable] = variable; \
8989
}
9090

91+
#define NODE_STYLE_READ_BOOL(values, variable) \
92+
{ \
93+
auto valueRef = values[#variable]; \
94+
NODE_STYLE_CHECK_UNDEFINED_VALUE(valueRef, variable) \
95+
variable = valueRef.toBool(); \
96+
}
97+
98+
#define NODE_STYLE_WRITE_BOOL(values, variable) \
99+
{ \
100+
values[#variable] = variable; \
101+
}
102+
91103
void NodeStyle::loadJson(QJsonObject const &json)
92104
{
93105
QJsonValue nodeStyleValues = json["NodeStyle"];
@@ -101,6 +113,7 @@ void NodeStyle::loadJson(QJsonObject const &json)
101113
NODE_STYLE_READ_COLOR(obj, GradientColor2);
102114
NODE_STYLE_READ_COLOR(obj, GradientColor3);
103115
NODE_STYLE_READ_COLOR(obj, ShadowColor);
116+
NODE_STYLE_READ_BOOL(obj, ShadowEnabled);
104117
NODE_STYLE_READ_COLOR(obj, FontColor);
105118
NODE_STYLE_READ_COLOR(obj, FontColorFaded);
106119
NODE_STYLE_READ_COLOR(obj, ConnectionPointColor);
@@ -126,6 +139,7 @@ QJsonObject NodeStyle::toJson() const
126139
NODE_STYLE_WRITE_COLOR(obj, GradientColor2);
127140
NODE_STYLE_WRITE_COLOR(obj, GradientColor3);
128141
NODE_STYLE_WRITE_COLOR(obj, ShadowColor);
142+
NODE_STYLE_WRITE_BOOL(obj, ShadowEnabled);
129143
NODE_STYLE_WRITE_COLOR(obj, FontColor);
130144
NODE_STYLE_WRITE_COLOR(obj, FontColorFaded);
131145
NODE_STYLE_WRITE_COLOR(obj, ConnectionPointColor);

0 commit comments

Comments
 (0)