[Bf-blender-cvs] [f41d4735e99] master: Nodes: support transparency for link highlight color

Dorian noreply at git.blender.org
Tue Oct 26 15:58:39 CEST 2021


Commit: f41d4735e99aae2a5247092b91106b1afcf52085
Author: Dorian
Date:   Tue Oct 26 15:54:52 2021 +0200
Branches: master
https://developer.blender.org/rBf41d4735e99aae2a5247092b91106b1afcf52085

Nodes: support transparency for link highlight color

Node links that are connected to selected nodes are highlighted
using the Wire Select theme color. Now it is possible to change the
transparency of this color to allow the actual link color to be visible
through the highlight (or to turn of the highlight entirely).

Differential Revision: https://developer.blender.org/D12973

===================================================================

M	source/blender/editors/space_node/drawnode.cc
M	source/blender/makesrna/intern/rna_userdef.c

===================================================================

diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc
index dfbb2132f1b..24f5decacdf 100644
--- a/source/blender/editors/space_node/drawnode.cc
+++ b/source/blender/editors/space_node/drawnode.cc
@@ -4329,6 +4329,25 @@ void node_draw_link_bezier(const View2D *v2d,
       UI_GetThemeColor4fv(th_col2, colors[2]);
     }
 
+    /* Highlight links connected to selected nodes. */
+    const bool is_fromnode_selected = link->fromnode && link->fromnode->flag & SELECT;
+    const bool is_tonode_selected = link->tonode && link->tonode->flag & SELECT;
+    if (is_fromnode_selected || is_tonode_selected) {
+      float color_selected[4];
+      UI_GetThemeColor4fv(TH_EDGE_SELECT, color_selected);
+      const float alpha = color_selected[3];
+
+      /* Interpolate color if highlight color is not fully transparent. */
+      if (alpha != 0.0) {
+        if (is_fromnode_selected) {
+          interp_v3_v3v3(colors[1], colors[1], color_selected, alpha);
+        }
+        if (is_tonode_selected) {
+          interp_v3_v3v3(colors[2], colors[2], color_selected, alpha);
+        }
+      }
+    }
+
     if (g_batch_link.enabled && !highlighted) {
       /* Add link to batch. */
       nodelink_batch_add_link(snode,
@@ -4402,15 +4421,6 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link)
       else if (link->flag & NODE_LINK_MUTED) {
         th_col1 = th_col2 = TH_REDALERT;
       }
-      else {
-        /* Regular link, highlight if connected to selected node. */
-        if (link->fromnode && link->fromnode->flag & SELECT) {
-          th_col1 = TH_EDGE_SELECT;
-        }
-        if (link->tonode && link->tonode->flag & SELECT) {
-          th_col2 = TH_EDGE_SELECT;
-        }
-      }
     }
     else {
       /* Invalid link. */
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index d6a46cbcc82..2514a604087 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -2844,7 +2844,7 @@ static void rna_def_userdef_theme_space_node(BlenderRNA *brna)
 
   prop = RNA_def_property(srna, "wire_select", PROP_FLOAT, PROP_COLOR_GAMMA);
   RNA_def_property_float_sdna(prop, NULL, "edge_select");
-  RNA_def_property_array(prop, 3);
+  RNA_def_property_array(prop, 4);
   RNA_def_property_ui_text(prop, "Wire Select", "");
   RNA_def_property_update(prop, 0, "rna_userdef_theme_update");



More information about the Bf-blender-cvs mailing list