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>2013-11-12 22:18:04 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2013-11-12 22:18:04 +0400
commit4d4ef0434b0078364824c2fe5ebfb8153fb44956 (patch)
treed3f5d286cca7b7bfa34fab18c57e4a38da0f80e4 /source/blender/makesrna/intern/rna_nodetree.c
parent8663b940eda703c45baf664c9aa379a9ecb684f9 (diff)
Make dynamic node labels possible as a registerable function 'draw_label' (simple 'label' identifier is already in use, need to avoid API breakage). This should simply return a string. The dynamic label can still be overridden by the user-defined node.label string.
Diffstat (limited to 'source/blender/makesrna/intern/rna_nodetree.c')
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 2b9c2bd4e9a..6b5bced75bd 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -1280,6 +1280,29 @@ static void rna_Node_draw_buttons_ext(struct uiLayout *layout, bContext *C, Poin
RNA_parameter_list_free(&list);
}
+static void rna_Node_draw_label(bNodeTree *ntree, bNode *node, char *label, int maxlen)
+{
+ extern FunctionRNA rna_Node_draw_label_func;
+
+ PointerRNA ptr;
+ ParameterList list;
+ FunctionRNA *func;
+ void *ret;
+ char *rlabel;
+
+ func = &rna_Node_draw_label_func; /* RNA_struct_find_function(&ptr, "draw_label"); */
+
+ RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr);
+ RNA_parameter_list_create(&list, &ptr, func);
+ node->typeinfo->ext.call(NULL, &ptr, func, &list);
+
+ RNA_parameter_get_lookup(&list, "label", &ret);
+ rlabel = *(char **)ret;
+ BLI_strncpy(label, rlabel != NULL ? rlabel : "", maxlen);
+
+ RNA_parameter_list_free(&list);
+}
+
static int rna_Node_is_registered_node_type(StructRNA *type)
{
return (RNA_struct_blender_type_get(type) != NULL);
@@ -1321,7 +1344,7 @@ static bNodeType *rna_Node_register_base(Main *bmain, ReportList *reports, Struc
PointerRNA dummyptr;
FunctionRNA *func;
PropertyRNA *parm;
- int have_function[8];
+ int have_function[9];
/* setup dummy node & node type to store static properties in */
memset(&dummynt, 0, sizeof(bNodeType));
@@ -1379,6 +1402,7 @@ static bNodeType *rna_Node_register_base(Main *bmain, ReportList *reports, Struc
nt->freefunc_api = (have_function[5]) ? rna_Node_free : NULL;
nt->draw_buttons = (have_function[6]) ? rna_Node_draw_buttons : NULL;
nt->draw_buttons_ex = (have_function[7]) ? rna_Node_draw_buttons_ext : NULL;
+ nt->labelfunc = (have_function[8]) ? rna_Node_draw_label : NULL;
/* sanitize size values in case not all have been registered */
if (nt->maxwidth < nt->minwidth)
@@ -7149,6 +7173,14 @@ static void rna_def_node(BlenderRNA *brna)
RNA_def_property_struct_type(parm, "UILayout");
RNA_def_property_ui_text(parm, "Layout", "Layout in the UI");
RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+
+ /* dynamic label */
+ func = RNA_def_function(srna, "draw_label", NULL);
+ RNA_def_function_ui_description(func, "Returns a dynamic label string");
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ parm = RNA_def_string(func, "label", "", MAX_NAME, "Label", "");
+ RNA_def_property_flag(parm, PROP_THICK_WRAP); /* needed for string return value */
+ RNA_def_function_output(func, parm);
}
static void rna_def_node_link(BlenderRNA *brna)