forked from bartvdbraak/blender
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.
This commit is contained in:
parent
1fe21f29ec
commit
49065fcbe8
@ -1653,6 +1653,13 @@ static void rna_Node_height_range(PointerRNA *ptr, float *min, float *max, float
|
|||||||
*max = *softmax = node->typeinfo->maxheight;
|
*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 ******** */
|
/* ******** 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_ui_text(prop, "Height", "Height of the node");
|
||||||
RNA_def_property_update(prop, NC_NODE | ND_DISPLAY, NULL);
|
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);
|
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
|
||||||
RNA_def_property_ui_text(prop, "Name", "Unique node identifier");
|
RNA_def_property_ui_text(prop, "Name", "Unique node identifier");
|
||||||
RNA_def_struct_name_property(srna, prop);
|
RNA_def_struct_name_property(srna, prop);
|
||||||
|
Loading…
Reference in New Issue
Block a user