[Bf-blender-cvs] [fca8d0f91fb] spreadsheet-active-node: separate node from display name

Jacques Lucke noreply at git.blender.org
Thu Apr 1 13:55:18 CEST 2021


Commit: fca8d0f91fb54aeb6354a38e8d03b400069fa393
Author: Jacques Lucke
Date:   Thu Apr 1 09:29:01 2021 +0200
Branches: spreadsheet-active-node
https://developer.blender.org/rBfca8d0f91fb54aeb6354a38e8d03b400069fa393

separate node from display name

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

M	source/blender/blenloader/intern/versioning_290.c
M	source/blender/editors/space_node/node_draw.cc
M	source/blender/editors/space_node/space_node.c
M	source/blender/makesdna/DNA_space_types.h

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

diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index 2449e35055e..d4439a8f6ab 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -1956,5 +1956,18 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
         arm->axes_position = 1.0;
       }
     }
+
+    LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
+      LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+        LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
+          if (sl->spacetype == SPACE_NODE) {
+            SpaceNode *snode = (SpaceNode *)sl;
+            LISTBASE_FOREACH (bNodeTreePath *, path, &snode->treepath) {
+              STRNCPY(path->display_name, path->node_name);
+            }
+          }
+        }
+      }
+    }
   }
 }
diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc
index f64ce771b25..07a5dbe1d7b 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -1959,8 +1959,8 @@ void node_draw_space(const bContext *C, ARegion *region)
     ID *name_id = (path->nodetree && path->nodetree != snode->nodetree) ? &path->nodetree->id :
                                                                           snode->id;
 
-    if (name_id && UNLIKELY(!STREQ(path->node_name, name_id->name + 2))) {
-      BLI_strncpy(path->node_name, name_id->name + 2, sizeof(path->node_name));
+    if (name_id && UNLIKELY(!STREQ(path->display_name, name_id->name + 2))) {
+      BLI_strncpy(path->display_name, name_id->name + 2, sizeof(path->display_name));
     }
 
     /* Current View2D center, will be set temporarily for parent node trees. */
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index 5d14919502e..f20a9409d90 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -74,7 +74,7 @@ void ED_node_tree_start(SpaceNode *snode, bNodeTree *ntree, ID *id, ID *from)
     copy_v2_v2(path->view_center, ntree->view_center);
 
     if (id) {
-      BLI_strncpy(path->node_name, id->name + 2, sizeof(path->node_name));
+      BLI_strncpy(path->display_name, id->name + 2, sizeof(path->display_name));
     }
 
     BLI_addtail(&snode->treepath, path);
@@ -111,6 +111,7 @@ void ED_node_tree_push(SpaceNode *snode, bNodeTree *ntree, bNode *gnode)
     }
 
     BLI_strncpy(path->node_name, gnode->name, sizeof(path->node_name));
+    BLI_strncpy(path->display_name, gnode->name, sizeof(path->display_name));
   }
   else {
     path->parent_key = NODE_INSTANCE_KEY_BASE;
@@ -175,7 +176,7 @@ int ED_node_tree_path_length(SpaceNode *snode)
   int length = 0;
   int i = 0;
   LISTBASE_FOREACH_INDEX (bNodeTreePath *, path, &snode->treepath, i) {
-    length += strlen(path->node_name);
+    length += strlen(path->display_name);
     if (i > 0) {
       length += 1; /* for separator char */
     }
@@ -190,12 +191,12 @@ void ED_node_tree_path_get(SpaceNode *snode, char *value)
   value[0] = '\0';
   LISTBASE_FOREACH_INDEX (bNodeTreePath *, path, &snode->treepath, i) {
     if (i == 0) {
-      strcpy(value, path->node_name);
-      value += strlen(path->node_name);
+      strcpy(value, path->display_name);
+      value += strlen(path->display_name);
     }
     else {
-      sprintf(value, "/%s", path->node_name);
-      value += strlen(path->node_name) + 1;
+      sprintf(value, "/%s", path->display_name);
+      value += strlen(path->display_name) + 1;
     }
   }
 }
@@ -208,10 +209,10 @@ void ED_node_tree_path_get_fixedbuf(SpaceNode *snode, char *value, int max_lengt
   int i = 0;
   LISTBASE_FOREACH_INDEX (bNodeTreePath *, path, &snode->treepath, i) {
     if (i == 0) {
-      size = BLI_strncpy_rlen(value, path->node_name, max_length);
+      size = BLI_strncpy_rlen(value, path->display_name, max_length);
     }
     else {
-      size = BLI_snprintf_rlen(value, max_length, "/%s", path->node_name);
+      size = BLI_snprintf_rlen(value, max_length, "/%s", path->display_name);
     }
     max_length -= size;
     if (max_length <= 0) {
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 74d9c2bae8c..a9a1be690f4 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -1520,6 +1520,7 @@ typedef struct bNodeTreePath {
 
   /** MAX_NAME. */
   char node_name[64];
+  char display_name[64];
 } bNodeTreePath;
 
 typedef struct SpaceNode {



More information about the Bf-blender-cvs mailing list