[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57451] trunk/blender/source/blender/ makesrna/intern/rna_nodetree.c: Added a read-only dimensions property for Nodes.

Lukas Toenne lukas.toenne at googlemail.com
Fri Jun 14 10:59:22 CEST 2013


Revision: 57451
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57451
Author:   lukastoenne
Date:     2013-06-14 08:59:21 +0000 (Fri, 14 Jun 2013)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/intern/rna_nodetree.c

Modified: trunk/blender/source/blender/makesrna/intern/rna_nodetree.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_nodetree.c	2013-06-14 08:28:27 UTC (rev 57450)
+++ trunk/blender/source/blender/makesrna/intern/rna_nodetree.c	2013-06-14 08:59:21 UTC (rev 57451)
@@ -1653,7 +1653,14 @@
 	*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 ******** */
 
 static void rna_NodeSocket_draw(bContext *C, struct uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr, const char *text)
@@ -6653,6 +6660,12 @@
 	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);




More information about the Bf-blender-cvs mailing list