nodeeditor icon indicating copy to clipboard operation
nodeeditor copied to clipboard

Different color for connection

Open jetrus opened this issue 6 years ago • 2 comments

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

jetrus avatar Jun 07 '18 16:06 jetrus

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 .

paceholder avatar Jun 07 '18 20:06 paceholder

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));

jetrus avatar Jun 08 '18 17:06 jetrus