[Bf-blender-cvs] [9b1b4b9e32c] master: Node Editor: Introduce color overlay and dashed wires theme setting

Pablo Vazquez noreply at git.blender.org
Thu Oct 21 21:00:40 CEST 2021


Commit: 9b1b4b9e32c8ac86e460204bb93e0ddc42ad9e49
Author: Pablo Vazquez
Date:   Thu Oct 21 21:00:17 2021 +0200
Branches: master
https://developer.blender.org/rB9b1b4b9e32c8ac86e460204bb93e0ddc42ad9e49

Node Editor: Introduce color overlay and dashed wires theme setting

This patch includes code from D9891 and D12754, so credit goes to Juanfran and Dalai.
I updated the patches to work with `master` and with the new overlay toggle.

The reason to include both changes as part of one patch is that the dimmed dashed lines work much better together with colored wires.

Theme setting for dash opacity:
{F11370574, size=full}

{F11286177, size=full, autoplay, loop}

{F11149912, size=full}

For adding the overlay I used `SpaceImageOverlay` as reference, although I'm not familiar with this code so there might be mistakes.

Reviewed By: #user_interface, HooglyBoogly

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

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

M	release/datafiles/userdef/userdef_default_theme.c
M	release/scripts/presets/interface_theme/Blender_Light.xml
M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	release/scripts/startup/bl_ui/space_node.py
M	source/blender/blenloader/intern/versioning_300.c
M	source/blender/blenloader/intern/versioning_userdef.c
M	source/blender/editors/include/UI_resources.h
M	source/blender/editors/interface/resources.c
M	source/blender/editors/space_node/drawnode.cc
M	source/blender/editors/space_node/node_draw.cc
M	source/blender/gpu/shaders/gpu_shader_2D_nodelink_frag.glsl
M	source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/makesrna/intern/rna_userdef.c

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

diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c
index eebdcf84fd2..ad93f87e962 100644
--- a/release/datafiles/userdef/userdef_default_theme.c
+++ b/release/datafiles/userdef/userdef_default_theme.c
@@ -828,6 +828,7 @@ const bTheme U_theme_default = {
     .facedot_size = 4,
     .noodle_curving = 4,
     .grid_levels = 2,
+    .dash_alpha = 0.5f,
     .syntaxl = RGBA(0x565656ff),
     .syntaxs = RGBA(0x975b5bff),
     .syntaxb = RGBA(0xccb83dff),
diff --git a/release/scripts/presets/interface_theme/Blender_Light.xml b/release/scripts/presets/interface_theme/Blender_Light.xml
index 8b7995cef4c..8074371c450 100644
--- a/release/scripts/presets/interface_theme/Blender_Light.xml
+++ b/release/scripts/presets/interface_theme/Blender_Light.xml
@@ -956,6 +956,7 @@
         distor_node="#749797"
         noodle_curving="4"
         grid_levels="2"
+        dash_alpha="0.5"
         input_node="#cb3d4a"
         output_node="#cb3d4a"
         filter_node="#6c696f"
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 3ba848e6caf..e70fe63677a 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -2064,6 +2064,8 @@ def km_node_editor(params):
          {"properties": [("data_path", 'tool_settings.use_snap')]}),
         ("wm.context_menu_enum", {"type": 'TAB', "value": 'PRESS', "shift": True, "ctrl": True},
          {"properties": [("data_path", 'tool_settings.snap_node_element')]}),
+        ("wm.context_toggle", {"type": 'Z', "value": 'PRESS', "alt": True, "shift": True},
+            {"properties": [("data_path", "space_data.overlay.show_overlays")]}),
         *_template_items_context_menu("NODE_MT_context_menu", params.context_menu_event),
     ])
 
diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py
index 8e2533edac6..da3db48d962 100644
--- a/release/scripts/startup/bl_ui/space_node.py
+++ b/release/scripts/startup/bl_ui/space_node.py
@@ -49,6 +49,7 @@ class NODE_HT_header(Header):
 
         scene = context.scene
         snode = context.space_data
+        overlay = snode.overlay
         snode_id = snode.id
         id_from = snode.id_from
         tool_settings = context.tool_settings
@@ -205,6 +206,13 @@ class NODE_HT_header(Header):
         if tool_settings.snap_node_element != 'GRID':
             row.prop(tool_settings, "snap_target", text="")
 
+        # Overlay toggle & popover
+        row = layout.row(align=True)
+        row.prop(overlay, "show_overlays", icon='OVERLAY', text="")
+        sub = row.row(align=True)
+        sub.active = overlay.show_overlays
+        sub.popover(panel="NODE_PT_overlay", text="")
+
 
 class NODE_MT_editor_menus(Menu):
     bl_idname = "NODE_MT_editor_menus"
@@ -680,6 +688,29 @@ class NODE_PT_quality(bpy.types.Panel):
         col.prop(snode, "use_auto_render")
 
 
+class NODE_PT_overlay(Panel):
+    bl_space_type = 'NODE_EDITOR'
+    bl_region_type = 'HEADER'
+    bl_label = "Overlays"
+    bl_ui_units_x = 7
+
+    def draw(self, context):
+        layout = self.layout
+        layout.label(text="Node Editor Overlays")
+
+        snode = context.space_data
+        overlay = snode.overlay
+
+        layout.active = overlay.show_overlays
+
+        col = layout.column()
+        col.prop(overlay, "show_wire_color", text="Wire Colors")
+
+        col.separator()
+
+        col.prop(snode, "show_annotation", text="Annotations")
+
+
 class NODE_UL_interface_sockets(bpy.types.UIList):
     def draw_item(self, context, layout, _data, item, icon, _active_data, _active_propname, _index):
         socket = item
@@ -848,6 +879,7 @@ classes = (
     NODE_PT_backdrop,
     NODE_PT_quality,
     NODE_PT_annotation,
+    NODE_PT_overlay,
     NODE_UL_interface_sockets,
     NODE_PT_node_tree_interface_inputs,
     NODE_PT_node_tree_interface_outputs,
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index bdee5194c9a..d5064f411c2 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -1988,6 +1988,23 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
     }
   }
 
+  if (!MAIN_VERSION_ATLEAST(bmain, 300, 37)) {
+    /* Node Editor: toggle overlays on. */
+    if (!DNA_struct_find(fd->filesdna, "SpaceNodeOverlay")) {
+      LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
+        LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+          LISTBASE_FOREACH (SpaceLink *, space, &area->spacedata) {
+            if (space->spacetype == SPACE_NODE) {
+              SpaceNode *snode = (SpaceNode *)space;
+              snode->overlay.flag |= SN_OVERLAY_SHOW_OVERLAYS;
+              snode->overlay.flag |= SN_OVERLAY_SHOW_WIRE_COLORS;
+            }
+          }
+        }
+      }
+    }
+  }
+
   /**
    * Versioning code until next subversion bump goes here.
    *
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index 2c01fae3d6a..b95de52a0cd 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -310,6 +310,10 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme)
     btheme->tui.panel_roundness = 0.4f;
   }
 
+  if (!USER_VERSION_ATLEAST(300, 37)) {
+    btheme->space_node.dash_alpha = 0.5f;
+  }
+
   /**
    * Versioning code until next subversion bump goes here.
    *
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index 61da496d344..7235d57d667 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -240,6 +240,7 @@ typedef enum ThemeColorID {
 
   TH_NODE_CURVING,
   TH_NODE_GRID_LEVELS,
+  TH_NODE_DASH_ALPHA,
 
   TH_MARKER_OUTLINE,
   TH_MARKER,
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index ad7c6332ee9..91832e1437c 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -657,6 +657,9 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
         case TH_NODE_GRID_LEVELS:
           cp = &ts->grid_levels;
           break;
+        case TH_NODE_DASH_ALPHA:
+          cp = &ts->dash_alpha;
+          break;
 
         case TH_SEQ_MOVIE:
           cp = ts->movie;
diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc
index afe36922b09..7bb35ab37d5 100644
--- a/source/blender/editors/space_node/drawnode.cc
+++ b/source/blender/editors/space_node/drawnode.cc
@@ -3944,15 +3944,17 @@ static struct {
   GPUBatch *batch_single; /* for single line */
   GPUVertBuf *inst_vbo;
   uint p0_id, p1_id, p2_id, p3_id;
-  uint colid_id, muted_id;
+  uint colid_id, muted_id, start_color_id, end_color_id;
   uint dim_factor_id;
   uint thickness_id;
   uint dash_factor_id;
+  uint dash_alpha_id;
   GPUVertBufRaw p0_step, p1_step, p2_step, p3_step;
-  GPUVertBufRaw colid_step, muted_step;
+  GPUVertBufRaw colid_step, muted_step, start_color_step, end_color_step;
   GPUVertBufRaw dim_factor_step;
   GPUVertBufRaw thickness_step;
   GPUVertBufRaw dash_factor_step;
+  GPUVertBufRaw dash_alpha_step;
   uint count;
   bool enabled;
 } g_batch_link;
@@ -3973,6 +3975,12 @@ static void nodelink_batch_reset()
       g_batch_link.inst_vbo, g_batch_link.thickness_id, &g_batch_link.thickness_step);
   GPU_vertbuf_attr_get_raw_data(
       g_batch_link.inst_vbo, g_batch_link.dash_factor_id, &g_batch_link.dash_factor_step);
+  GPU_vertbuf_attr_get_raw_data(
+      g_batch_link.inst_vbo, g_batch_link.dash_alpha_id, &g_batch_link.dash_alpha_step);
+  GPU_vertbuf_attr_get_raw_data(
+      g_batch_link.inst_vbo, g_batch_link.start_color_id, &g_batch_link.start_color_step);
+  GPU_vertbuf_attr_get_raw_data(
+      g_batch_link.inst_vbo, g_batch_link.end_color_id, &g_batch_link.end_color_step);
   g_batch_link.count = 0;
 }
 
@@ -4088,6 +4096,10 @@ static void nodelink_batch_init()
       &format_inst, "P3", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
   g_batch_link.colid_id = GPU_vertformat_attr_add(
       &format_inst, "colid_doarrow", GPU_COMP_U8, 4, GPU_FETCH_INT);
+  g_batch_link.start_color_id = GPU_vertformat_attr_add(
+      &format_inst, "start_color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
+  g_batch_link.end_color_id = GPU_vertformat_attr_add(
+      &format_inst, "end_color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
   g_batch_link.muted_id = GPU_vertformat_attr_add(
       &format_inst, "domuted", GPU_COMP_U8, 2, GPU_FETCH_INT);
   g_batch_link.dim_factor_id = GPU_vertformat_attr_add(
@@ -4096,6 +4108,8 @@ static void nodelink_batch_init()
       &format_inst, "thickness", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
   g_batch_link.dash_factor_id = GPU_vertformat_attr_add(
       &format_inst, "dash_factor", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
+  g_batch_link.dash_alpha_id = GPU_vertformat_attr_add(
+      &format_inst, "dash_alpha", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
   g_batch_link.inst_vbo = GPU_vertbuf_create_with_format_ex(&format_inst, GPU_USAGE_STREAM);
   /* Alloc max count but only draw the range we need. */
   GPU_vertbuf_data_alloc(g_batch_link.inst_vbo, NODELINK_GROUP_SIZE);
@@ -4170,11 +4184,14 @@ static void nodelink_batch_add_link(const SpaceNode *snode,
                                     int th_col1,
                                     int th_col2,
                                     int th_col3,
+                                    const float start_color[4],
+                                    const float end_color[4],
                                     bool drawarrow,
                                     bool drawmuted,
                                     float dim_factor,
                                     float thickness,
-                                    float dash_factor)
+        

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list