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-06-14 12:59:21 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2013-06-14 12:59:21 +0400
commit49065fcbe8ddd90c3f8053ca87552433ddd1298d (patch)
tree73c4bb7964ca1d8a23a24851ed9e0ba26cb5999f /source/blender/makesrna
parent1fe21f29ec9134175aeb6ba9bf4bf3ddf9753e89 (diff)
Added a read-only dimensions property for Nodes. This returns the actual node size as calculated in the node_update functions. It can be useful for node layout scripts, since the width/height properties
are not an accurate representation of the actual node size which is determined by the uiLayout. Please note that the dimensions calculation depends on the drawing of nodes, so it may not get updated if nodes are not visible in any editor. Also the node height in particular can change dramatically based on previews, visible sockets, etc.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 0bb6ec01333..e96578beecc 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -1653,6 +1653,13 @@ static void rna_Node_height_range(PointerRNA *ptr, float *min, float *max, float
*max = *softmax = node->typeinfo->maxheight;
}
+static void rna_Node_dimensions_get(PointerRNA *ptr, float *value)
+{
+ bNode *node = ptr->data;
+ value[0] = node->totr.xmax - node->totr.xmin;
+ value[1] = node->totr.ymax - node->totr.ymin;
+}
+
/* ******** Node Socket ******** */
@@ -6653,6 +6660,12 @@ static void rna_def_node(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Height", "Height of the node");
RNA_def_property_update(prop, NC_NODE | ND_DISPLAY, NULL);
+ prop = RNA_def_property(srna, "dimensions", PROP_FLOAT, PROP_XYZ_LENGTH);
+ RNA_def_property_array(prop, 2);
+ RNA_def_property_float_funcs(prop, "rna_Node_dimensions_get", NULL, NULL);
+ RNA_def_property_ui_text(prop, "Dimensions", "Absolute bounding box dimensions of the node");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(prop, "Name", "Unique node identifier");
RNA_def_struct_name_property(srna, prop);