diff options
author | Ines Almeida <britalmeida@gmail.com> | 2018-01-08 00:29:25 +0300 |
---|---|---|
committer | Ines Almeida <britalmeida@gmail.com> | 2018-01-08 00:29:25 +0300 |
commit | 87607254d6d3f9ca5ebbc696a4066bf0c8fbbed4 (patch) | |
tree | 0fd4aedc48f05c87e722250e2c00dca04cac1974 /source | |
parent | add580beeea0e1d5bd8be2336c8a5b25bc8c601a (diff) |
(Nodes) Display image name if any in the Image and Texture Image node title
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 6 | ||||
-rw-r--r-- | source/blender/nodes/composite/nodes/node_composite_image.c | 1 | ||||
-rw-r--r-- | source/blender/nodes/intern/node_util.c | 6 | ||||
-rw-r--r-- | source/blender/nodes/intern/node_util.h | 1 | ||||
-rw-r--r-- | source/blender/nodes/texture/nodes/node_texture_image.c | 3 |
5 files changed, 15 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 2ca414c5e6e..6be6514b5ec 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -3173,13 +3173,17 @@ void nodeSynchronizeID(bNode *node, bool copy_to_id) void nodeLabel(bNodeTree *ntree, bNode *node, char *label, int maxlen) { + label[0] = '\0'; + if (node->label[0] != '\0') { BLI_strncpy(label, node->label, maxlen); } else if (node->typeinfo->labelfunc) { node->typeinfo->labelfunc(ntree, node, label, maxlen); } - else { + + /* The previous methods (labelfunc) could not provide an adequate label for the node. */ + if (label[0] == '\0') { /* Kind of hacky and weak... Ideally would be better to use RNA here. :| */ const char *tmp = CTX_IFACE_(BLT_I18NCONTEXT_ID_NODETREE, node->typeinfo->ui_name); if (tmp == node->typeinfo->ui_name) { diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c index a95c3233132..1e240c2f84b 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.c +++ b/source/blender/nodes/composite/nodes/node_composite_image.c @@ -340,6 +340,7 @@ void register_node_type_cmp_image(void) node_type_init(&ntype, node_composit_init_image); node_type_storage(&ntype, "ImageUser", node_composit_free_image, node_composit_copy_image); node_type_update(&ntype, cmp_node_image_update, NULL); + node_type_label(&ntype, node_image_label); nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.c index dd5715891d5..43d4136d556 100644 --- a/source/blender/nodes/intern/node_util.c +++ b/source/blender/nodes/intern/node_util.c @@ -91,6 +91,12 @@ void node_blend_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int ma BLI_strncpy(label, IFACE_(name), maxlen); } +void node_image_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen) +{ + /* if there is no loaded image, return an empty string, and let nodeLabel() fill in the proper type translation. */ + BLI_strncpy(label, (node->id) ? node->id->name + 2 : "", maxlen); +} + void node_math_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen) { const char *name; diff --git a/source/blender/nodes/intern/node_util.h b/source/blender/nodes/intern/node_util.h index 2e20a8e79d4..b4437dfcb78 100644 --- a/source/blender/nodes/intern/node_util.h +++ b/source/blender/nodes/intern/node_util.h @@ -72,6 +72,7 @@ extern void *node_initexec_curves(struct bNodeExecContext *context, struct bNode /**** Labels ****/ void node_blend_label(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen); +void node_image_label(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen); void node_math_label(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen); void node_vect_math_label(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen); void node_filter_label(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen); diff --git a/source/blender/nodes/texture/nodes/node_texture_image.c b/source/blender/nodes/texture/nodes/node_texture_image.c index 9b13589f3e1..8e9821c0fcb 100644 --- a/source/blender/nodes/texture/nodes/node_texture_image.c +++ b/source/blender/nodes/texture/nodes/node_texture_image.c @@ -106,6 +106,7 @@ void register_node_type_tex_image(void) node_type_init(&ntype, init); node_type_storage(&ntype, "ImageUser", node_free_standard_storage, node_copy_standard_storage); node_type_exec(&ntype, NULL, NULL, exec); - + node_type_label(&ntype, node_image_label); + nodeRegisterType(&ntype); } |