Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimizing performance | Add shadow enabler #427

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ the moment of writing this documentation.
"GradientColor2": [64, 64, 64],
"GradientColor3": [58, 58, 58],
"ShadowColor": [20, 20, 20],
"ShadowEnabled": false,
"FontColor" : "white",
"FontColorFaded" : "gray",
"ConnectionPointColor": [169, 169, 169],
Expand Down
1 change: 1 addition & 0 deletions examples/styles/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ static void setStyle()
"GradientColor2": "mintcream",
"GradientColor3": "mintcream",
"ShadowColor": [200, 200, 200],
"ShadowEnabled": true,
"FontColor": [10, 10, 10],
"FontColorFaded": [100, 100, 100],
"ConnectionPointColor": "white",
Expand Down
1 change: 1 addition & 0 deletions include/QtNodes/internal/NodeStyle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class NODE_EDITOR_PUBLIC NodeStyle : public Style
QColor GradientColor2;
QColor GradientColor3;
QColor ShadowColor;
bool ShadowEnabled;
QColor FontColor;
QColor FontColorFaded;

Expand Down
1 change: 1 addition & 0 deletions resources/DefaultStyle.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"GradientColor2": [64, 64, 64],
"GradientColor3": [58, 58, 58],
"ShadowColor": [20, 20, 20],
"ShadowEnabled": false,
"FontColor" : "white",
"FontColorFaded" : "gray",
"ConnectionPointColor": [169, 169, 169],
Expand Down
1 change: 1 addition & 0 deletions src/NodeGraphicsObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ NodeGraphicsObject::NodeGraphicsObject(BasicGraphicsScene &scene, NodeId nodeId)

NodeStyle nodeStyle(nodeStyleJson);

if(nodeStyle.ShadowEnabled)
{
auto effect = new QGraphicsDropShadowEffect;
effect->setOffset(4, 4);
Expand Down
14 changes: 14 additions & 0 deletions src/NodeStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ void NodeStyle::setNodeStyle(QString jsonText)
values[#variable] = variable; \
}

#define NODE_STYLE_READ_BOOL(values, variable) \
{ \
auto valueRef = values[#variable]; \
NODE_STYLE_CHECK_UNDEFINED_VALUE(valueRef, variable) \
variable = valueRef.toBool(); \
}

#define NODE_STYLE_WRITE_BOOL(values, variable) \
{ \
values[#variable] = variable; \
}

void NodeStyle::loadJson(QJsonObject const &json)
{
QJsonValue nodeStyleValues = json["NodeStyle"];
Expand All @@ -101,6 +113,7 @@ void NodeStyle::loadJson(QJsonObject const &json)
NODE_STYLE_READ_COLOR(obj, GradientColor2);
NODE_STYLE_READ_COLOR(obj, GradientColor3);
NODE_STYLE_READ_COLOR(obj, ShadowColor);
NODE_STYLE_READ_BOOL(obj, ShadowEnabled);
NODE_STYLE_READ_COLOR(obj, FontColor);
NODE_STYLE_READ_COLOR(obj, FontColorFaded);
NODE_STYLE_READ_COLOR(obj, ConnectionPointColor);
Expand All @@ -126,6 +139,7 @@ QJsonObject NodeStyle::toJson() const
NODE_STYLE_WRITE_COLOR(obj, GradientColor2);
NODE_STYLE_WRITE_COLOR(obj, GradientColor3);
NODE_STYLE_WRITE_COLOR(obj, ShadowColor);
NODE_STYLE_WRITE_BOOL(obj, ShadowEnabled);
NODE_STYLE_WRITE_COLOR(obj, FontColor);
NODE_STYLE_WRITE_COLOR(obj, FontColorFaded);
NODE_STYLE_WRITE_COLOR(obj, ConnectionPointColor);
Expand Down