Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Toenne <lukas.toenne@googlemail.com>2011-03-17 13:11:12 +0300
committerLukas Toenne <lukas.toenne@googlemail.com>2011-03-17 13:11:12 +0300
commitafd8865181dab5a79a7ecb638c3cd9842087c452 (patch)
tree8387575e3c8d48376ca09396fda23876b1c554e3
parente3842d1ca4dd2fdc58b8d7819a8a02a688753146 (diff)
Added an optional label string to nodes. As pointed out by Sebastian Koenig, some nodes (in particular render layer nodes) need custom labels, but it is not possible to make any useful generic abbreviation. The label string can be used as a custom user-defined label in this case, without the ugly .xxx extensions needed for unique node names. When the label string is empty, the default type label will be used.
-rw-r--r--source/blender/editors/space_node/node_buttons.c1
-rw-r--r--source/blender/editors/space_node/node_draw.c8
-rw-r--r--source/blender/makesdna/DNA_node_types.h3
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c54
4 files changed, 14 insertions, 52 deletions
diff --git a/source/blender/editors/space_node/node_buttons.c b/source/blender/editors/space_node/node_buttons.c
index b1191b616dc..f8ea6e881f7 100644
--- a/source/blender/editors/space_node/node_buttons.c
+++ b/source/blender/editors/space_node/node_buttons.c
@@ -113,6 +113,7 @@ static void active_node_panel(const bContext *C, Panel *pa)
/* draw this node's name, etc. */
uiItemR(layout, &ptr, "name", 0, NULL, ICON_NODE);
+ uiItemR(layout, &ptr, "label", 0, NULL, ICON_NODE);
// TODO: a separator would be nice...
/* draw this node's settings */
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index c5221d45837..920e670573d 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -804,7 +804,9 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
else
UI_ThemeColor(TH_TEXT); */
- if (node->typeinfo->labelfunc)
+ if (node->label[0]!='\0')
+ BLI_strncpy(showname, node->label, sizeof(showname));
+ else if (node->typeinfo->labelfunc)
BLI_strncpy(showname, node->typeinfo->labelfunc(node), sizeof(showname));
else
BLI_strncpy(showname, node->typeinfo->name, sizeof(showname));
@@ -948,7 +950,9 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
UI_ThemeColor(TH_TEXT);
if(node->miniwidth>0.0f) {
- if (node->typeinfo->labelfunc)
+ if (node->label[0]!='\0')
+ BLI_strncpy(showname, node->label, sizeof(showname));
+ else if (node->typeinfo->labelfunc)
BLI_strncpy(showname, node->typeinfo->labelfunc(node), sizeof(showname));
else
BLI_strncpy(showname, node->typeinfo->name, sizeof(showname));
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 803e5418bcc..03387c3a63a 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -136,7 +136,8 @@ typedef struct bNode {
void *storage; /* custom data, must be struct, for storage in file */
float locx, locy; /* root offset for drawing */
- float width, miniwidth;
+ float width, miniwidth;
+ char label[32]; /* custom user-defined label */
short custom1, custom2; /* to be abused for buttons */
float custom3, custom4;
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 4926c695d21..e39b71c2786 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -317,55 +317,6 @@ static void rna_Node_name_set(PointerRNA *ptr, const char *value)
BKE_all_animdata_fix_paths_rename("nodes", oldname, node->name);
}
-/* this should be done at display time! if no custom names are set */
-#if 0
-static void rna_Node_update_username(Main *bmain, Scene *scene, PointerRNA *ptr)
-{
- bNode *node= (bNode*)ptr->data;
- const char *name;
-
-
- /*
- if (!node->username[0]) {
- if(node->id) {
- BLI_strncpy(node->username, node->id->name+2, NODE_MAXSTR);
- }
- else {
-
- switch(node->typeinfo->type) {
- case SH_NODE_MIX_RGB:
- case CMP_NODE_MIX_RGB:
- case TEX_NODE_MIX_RGB:
- if(RNA_enum_name(node_blend_type_items, node->custom1, &name))
- BLI_strncpy(node->username, name, NODE_MAXSTR);
- break;
- case CMP_NODE_FILTER:
- if(RNA_enum_name(node_filter_items, node->custom1, &name))
- BLI_strncpy(node->username, name, NODE_MAXSTR);
- break;
- case CMP_NODE_FLIP:
- if(RNA_enum_name(node_flip_items, node->custom1, &name))
- BLI_strncpy(node->username, name, NODE_MAXSTR);
- break;
- case SH_NODE_MATH:
- case CMP_NODE_MATH:
- case TEX_NODE_MATH:
- if(RNA_enum_name(node_math_items, node->custom1, &name))
- BLI_strncpy(node->username, name, NODE_MAXSTR);
- break;
- case SH_NODE_VECT_MATH:
- if(RNA_enum_name(node_vec_math_items, node->custom1, &name))
- BLI_strncpy(node->username, name, NODE_MAXSTR);
- break;
- }
- */
- }
- }
-
- rna_Node_update(bmain, scene, ptr);
-}
-#endif
-
static void rna_NodeSocket_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
bNodeTree *ntree= (bNodeTree*)ptr->id.data;
@@ -2698,6 +2649,11 @@ static void rna_def_node(BlenderRNA *brna)
RNA_def_property_collection_sdna(prop, NULL, "outputs", NULL);
RNA_def_property_struct_type(prop, "NodeSocket");
RNA_def_property_ui_text(prop, "Outputs", "");
+
+ prop = RNA_def_property(srna, "label", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "label");
+ RNA_def_property_ui_text(prop, "Label", "Optional custom node label");
+ RNA_def_property_update(prop, NC_NODE, "rna_Node_update");
}
static void rna_def_node_link(BlenderRNA *brna)