diff options
author | Jacques Lucke <jacques@blender.org> | 2021-08-24 14:38:53 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-08-24 14:38:53 +0300 |
commit | ec5160ee946ae625991556a056f0379a1faefb6d (patch) | |
tree | 6690eccb21706e19507c170b27844ac9277eddc0 /source/blender/editors/space_node | |
parent | 7be52f69850b361c41c54c2d6afa62ef83a3db3d (diff) |
change link colors slightly
Diffstat (limited to 'source/blender/editors/space_node')
-rw-r--r-- | source/blender/editors/space_node/drawnode.cc | 22 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_draw.cc | 17 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_intern.h | 11 |
3 files changed, 41 insertions, 9 deletions
diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc index 0f7a911e3ce..6f8c0a513da 100644 --- a/source/blender/editors/space_node/drawnode.cc +++ b/source/blender/editors/space_node/drawnode.cc @@ -4278,6 +4278,28 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link) } } + if (link->fromsock) { + const SocketSingleState from_single_state = get_socket_single_state( + snode->edittree, link->fromnode, link->fromsock); + if (ELEM(from_single_state, + SocketSingleState::RequiredSingle, + SocketSingleState::CurrentlySingle)) { + th_col1 = th_col2 = TH_ACTIVE; + } + } + + if (link->fromsock && link->tosock) { + const SocketSingleState to_single_state = get_socket_single_state( + snode->edittree, link->tonode, link->tosock); + const SocketSingleState from_single_state = get_socket_single_state( + snode->edittree, link->fromnode, link->fromsock); + + if (to_single_state == SocketSingleState::RequiredSingle && + from_single_state == SocketSingleState::MaybeField) { + th_col1 = th_col2 = TH_REDALERT; + } + } + node_draw_link_bezier(v2d, snode, link, th_col1, th_col2, th_col3); } diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 23169809fc7..2de8cbaf7ee 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -789,12 +789,6 @@ static void node_socket_draw_rounded_rectangle(const float color[4], &rect, color, nullptr, 1.0f, color_outline, outline_width, width - outline_width * 0.5f); } -enum class SocketSingleState { - RequiredSingle, - CurrentlySingle, - MaybeField, -}; - #define PRIMITIVE_SOCKETS SOCK_FLOAT, SOCK_VECTOR, SOCK_INT, SOCK_BOOLEAN, SOCK_RGBA static bool is_required_single(const bNodeTree *node_tree, @@ -833,13 +827,18 @@ static bool is_maybe_field(const bNodeTree *node_tree, return true; } if (socket->in_out == SOCK_IN) { + bool found_link = false; LISTBASE_FOREACH (const bNodeLink *, link, &node_tree->links) { if (link->tosock == socket) { + found_link = true; if (is_maybe_field(node_tree, link->fromnode, link->fromsock)) { return true; } } } + if (!found_link && (socket->flag & SOCK_HIDE_VALUE) && socket->type == SOCK_VECTOR) { + return true; + } } else { LISTBASE_FOREACH (const bNodeSocket *, input, &node->inputs) { @@ -853,9 +852,9 @@ static bool is_maybe_field(const bNodeTree *node_tree, return false; } -static SocketSingleState get_socket_single_state(const bNodeTree *node_tree, - const bNode *node, - const bNodeSocket *socket) +SocketSingleState get_socket_single_state(const bNodeTree *node_tree, + const bNode *node, + const bNodeSocket *socket) { if (node_tree->type != NTREE_GEOMETRY) { return SocketSingleState::MaybeField; diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index df20420e472..394abb5e207 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -340,3 +340,14 @@ extern const char *node_context_dir[]; #ifdef __cplusplus } #endif + +#ifdef __cplusplus +enum class SocketSingleState { + RequiredSingle, + CurrentlySingle, + MaybeField, +}; +SocketSingleState get_socket_single_state(const struct bNodeTree *node_tree, + const struct bNode *node, + const struct bNodeSocket *socket); +#endif |