nodeeditor
nodeeditor copied to clipboard
Different color for connection
Hi guys!
In the example connection_colors, we set "UseDataDefinedColors": true. where and how to set colors for typeData?
I saw (Diffenent colors for different NodeDataTypes # 19) but did not understand. Sorry if the question is stupid
Hi
Your question is perfectly valid. The current implementation is stupid. I take the name of a data type, find a hash value of its name, and then cast to 6 bytes color. So a unique color is defined automatically in a stupid and obscure manner.
I need to add a feature for some really user/data defined colors. And of course, finally write some documentation.
Regards,
Dmitry
On Thu, Jun 7, 2018, 18:30 jetrus [email protected] wrote:
Hi guys!
In the example connection_colors, we set "UseDataDefinedColors": true. where and how to set colors for typeData?
I saw (Diffenent colors for different NodeDataTypes # 19) but did not understand. Sorry if the question is stupid
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/paceholder/nodeeditor/issues/184, or mute the thread https://github.com/notifications/unsubscribe-auth/AATtiCdqRmjuEMnuYM_F630Rv_15At5Xks5t6VUcgaJpZM4UevLY .
I solved this problem by adding the parameter QColor to the NodeDataType structure.
struct NodeDataType { QString id; QString name; QColor color; };
and changing the code where the color is set via NodeDataType.id
normalColorOut = connectionStyle.normalColor(dataTypeOut.color); normalColorIn = connectionStyle.normalColor(dataTypeIn.color);
QColor ConnectionStyle:: normalColor(QColor color) const { return color; }
painter->setBrush(connectionStyle.normalColor(dataType.color));