2008-10-31 23:50:02 +00:00
|
|
|
/**
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation (2008).
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef RNA_DEFINE_H
|
|
|
|
#define RNA_DEFINE_H
|
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
/* Functions used during preprocess and runtime, for defining the RNA. */
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2009-01-16 23:53:11 +00:00
|
|
|
#include <float.h>
|
|
|
|
#include <limits.h>
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
#include "DNA_listBase.h"
|
2008-11-14 14:34:19 +00:00
|
|
|
#include "RNA_types.h"
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2009-03-14 23:17:55 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
/* Blender RNA */
|
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
BlenderRNA *RNA_create(void);
|
|
|
|
void RNA_define_free(BlenderRNA *brna);
|
|
|
|
void RNA_free(BlenderRNA *brna);
|
2009-06-19 23:05:21 +00:00
|
|
|
|
|
|
|
void RNA_init(void);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
void RNA_exit(void);
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
/* Struct */
|
|
|
|
|
2008-12-19 04:06:24 +00:00
|
|
|
StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from);
|
2008-11-14 14:34:19 +00:00
|
|
|
void RNA_def_struct_sdna(StructRNA *srna, const char *structname);
|
2008-12-02 23:45:11 +00:00
|
|
|
void RNA_def_struct_sdna_from(StructRNA *srna, const char *structname, const char *propname);
|
2008-11-14 14:34:19 +00:00
|
|
|
void RNA_def_struct_name_property(StructRNA *srna, PropertyRNA *prop);
|
2009-01-10 22:57:33 +00:00
|
|
|
void RNA_def_struct_nested(BlenderRNA *brna, StructRNA *srna, const char *structname);
|
2008-11-14 14:34:19 +00:00
|
|
|
void RNA_def_struct_flag(StructRNA *srna, int flag);
|
2009-05-29 15:12:31 +00:00
|
|
|
void RNA_def_struct_clear_flag(StructRNA *srna, int flag);
|
2009-01-01 15:52:51 +00:00
|
|
|
void RNA_def_struct_refine_func(StructRNA *srna, const char *refine);
|
2009-05-20 09:52:02 +00:00
|
|
|
void RNA_def_struct_idproperties_func(StructRNA *srna, const char *refine);
|
2009-04-19 13:37:59 +00:00
|
|
|
void RNA_def_struct_register_funcs(StructRNA *srna, const char *reg, const char *unreg);
|
2009-03-25 20:29:01 +00:00
|
|
|
void RNA_def_struct_path_func(StructRNA *srna, const char *path);
|
2008-12-19 04:06:24 +00:00
|
|
|
void RNA_def_struct_identifier(StructRNA *srna, const char *identifier);
|
|
|
|
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description);
|
2009-06-03 23:16:51 +00:00
|
|
|
void RNA_def_struct_ui_icon(StructRNA *srna, int icon);
|
python operators (in bpy_opwrapper.*)
This means you can define an operator in python that is called from C or Python - like any other operator.
Python functions for invoke and exec can be registered with an operator name.
keywords are read from the python exec() function, then used to create operator properties. The default python values are used to set the property type and defaults.
def exec(size=2.0, text="blah"): ...
is equivalent to...
prop = RNA_def_property(ot->srna, "size", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_default(prop, 2.0f);
prop = RNA_def_property(ot->srna, "size", PROP_STRING, PROP_NONE);
RNA_def_property_string_default(prop, "blah");
TODO -
* make use of events
* return OPERATOR_CANCELLED/OPERATOR_FINISHED.. etc
* add support for array args
* more testing
2008-12-27 14:52:49 +00:00
|
|
|
void RNA_struct_free(BlenderRNA *brna, StructRNA *srna);
|
2009-01-01 15:52:51 +00:00
|
|
|
|
2009-01-16 23:53:11 +00:00
|
|
|
/* Compact Property Definitions */
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
typedef void StructOrFunctionRNA;
|
2009-01-16 23:53:11 +00:00
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_boolean(StructOrFunctionRNA *cont, const char *identifier, int default_value, const char *ui_name, const char *ui_description);
|
|
|
|
PropertyRNA *RNA_def_boolean_array(StructOrFunctionRNA *cont, const char *identifier, int len, int *default_value, const char *ui_name, const char *ui_description);
|
|
|
|
PropertyRNA *RNA_def_boolean_vector(StructOrFunctionRNA *cont, const char *identifier, int len, int *default_value, const char *ui_name, const char *ui_description);
|
2009-01-16 23:53:11 +00:00
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_int(StructOrFunctionRNA *cont, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax);
|
|
|
|
PropertyRNA *RNA_def_int_vector(StructOrFunctionRNA *cont, const char *identifier, int len, const int *default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax);
|
|
|
|
PropertyRNA *RNA_def_int_array(StructOrFunctionRNA *cont, const char *identifier, int len, const int *default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax);
|
2009-01-16 23:53:11 +00:00
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_string(StructOrFunctionRNA *cont, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description);
|
|
|
|
PropertyRNA *RNA_def_string_file_path(StructOrFunctionRNA *cont, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description);
|
|
|
|
PropertyRNA *RNA_def_string_dir_path(StructOrFunctionRNA *cont, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description);
|
2009-01-16 23:53:11 +00:00
|
|
|
|
2009-06-24 21:27:10 +00:00
|
|
|
PropertyRNA *RNA_def_enum(StructOrFunctionRNA *cont, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description);
|
2009-04-07 00:49:39 +00:00
|
|
|
|
|
|
|
PropertyRNA *RNA_def_float(StructOrFunctionRNA *cont, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax);
|
|
|
|
PropertyRNA *RNA_def_float_vector(StructOrFunctionRNA *cont, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax);
|
|
|
|
PropertyRNA *RNA_def_float_color(StructOrFunctionRNA *cont, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax);
|
|
|
|
PropertyRNA *RNA_def_float_matrix(StructOrFunctionRNA *cont, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax);
|
|
|
|
PropertyRNA *RNA_def_float_rotation(StructOrFunctionRNA *cont, const char *identifier, int len, const float *default_value,
|
2009-01-16 23:53:11 +00:00
|
|
|
float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax);
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_float_array(StructOrFunctionRNA *cont, const char *identifier, int len, const float *default_value,
|
2009-01-16 23:53:11 +00:00
|
|
|
float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax);
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_float_percentage(StructOrFunctionRNA *cont, const char *identifier, float default_value, float hardmin, float hardmax,
|
2009-02-17 21:07:01 +00:00
|
|
|
const char *ui_name, const char *ui_description, float softmin, float softmax);
|
2009-01-16 23:53:11 +00:00
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_pointer(StructOrFunctionRNA *cont, const char *identifier, const char *type,
|
|
|
|
const char *ui_name, const char *ui_description);
|
|
|
|
PropertyRNA *RNA_def_pointer_runtime(StructOrFunctionRNA *cont, const char *identifier, StructRNA *type,
|
2009-01-16 23:53:11 +00:00
|
|
|
const char *ui_name, const char *ui_description);
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_collection(StructOrFunctionRNA *cont, const char *identifier, const char *type,
|
|
|
|
const char *ui_name, const char *ui_description);
|
|
|
|
PropertyRNA *RNA_def_collection_runtime(StructOrFunctionRNA *cont, const char *identifier, StructRNA *type,
|
2009-01-16 23:53:11 +00:00
|
|
|
const char *ui_name, const char *ui_description);
|
|
|
|
|
|
|
|
/* Extended Property Definitions */
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont, const char *identifier, int type, int subtype);
|
2008-11-14 14:34:19 +00:00
|
|
|
|
|
|
|
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int bit);
|
2008-12-03 21:13:47 +00:00
|
|
|
void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname, const char *propname, int bit);
|
2008-11-14 14:34:19 +00:00
|
|
|
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname);
|
|
|
|
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname);
|
|
|
|
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname);
|
2008-12-03 21:13:47 +00:00
|
|
|
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname);
|
|
|
|
void RNA_def_property_enum_bitflag_sdna(PropertyRNA *prop, const char *structname, const char *propname);
|
2008-11-14 14:34:19 +00:00
|
|
|
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname);
|
|
|
|
void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname);
|
|
|
|
|
|
|
|
void RNA_def_property_flag(PropertyRNA *prop, int flag);
|
2009-03-23 13:24:48 +00:00
|
|
|
void RNA_def_property_clear_flag(PropertyRNA *prop, int flag);
|
2008-11-14 14:34:19 +00:00
|
|
|
void RNA_def_property_array(PropertyRNA *prop, int arraylength);
|
|
|
|
void RNA_def_property_range(PropertyRNA *prop, double min, double max);
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item);
|
2008-11-14 14:34:19 +00:00
|
|
|
void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength);
|
|
|
|
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type);
|
RNA:
* Added support for using pointers + collections as operator properties,
but with the restriction that they must point to other type derived from
ID property groups. The "add" function for these properties will allocate
a new ID property group and point to that.
* Added support for arrays with type IDP_GROUP in ID properties.
* Fix bug getting/setting float array values.
Example code for collections, note the "OperatorMousePath" type is defined
in rna_wm.c and has a float[2] property named "loc".
Defining the operator property:
prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
Adding values:
PointerRNA itemptr;
float loc[2] = {1, 1},
RNA_collection_add(op->ptr, "path", &itemptr);
RNA_float_set_array(&itemptr, "loc", loc);
Iterating:
RNA_BEGIN(op->ptr, itemptr, "path") {
float loc[2];
RNA_float_get_array(&itemptr, "loc", loc);
printf("Location: %f %f\n", loc[0], loc[1]);
}
RNA_END;
2008-12-26 20:38:52 +00:00
|
|
|
void RNA_def_property_struct_runtime(PropertyRNA *prop, StructRNA *type);
|
2008-11-14 14:34:19 +00:00
|
|
|
|
|
|
|
void RNA_def_property_boolean_default(PropertyRNA *prop, int value);
|
|
|
|
void RNA_def_property_boolean_array_default(PropertyRNA *prop, const int *array);
|
|
|
|
void RNA_def_property_int_default(PropertyRNA *prop, int value);
|
|
|
|
void RNA_def_property_int_array_default(PropertyRNA *prop, const int *array);
|
|
|
|
void RNA_def_property_float_default(PropertyRNA *prop, float value);
|
|
|
|
void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array);
|
|
|
|
void RNA_def_property_enum_default(PropertyRNA *prop, int value);
|
|
|
|
void RNA_def_property_string_default(PropertyRNA *prop, const char *value);
|
|
|
|
|
|
|
|
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description);
|
2008-11-14 18:46:57 +00:00
|
|
|
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision);
|
2009-06-16 00:52:21 +00:00
|
|
|
void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive);
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2009-01-01 15:52:51 +00:00
|
|
|
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *updatefunc);
|
|
|
|
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable);
|
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set);
|
2008-11-24 12:12:24 +00:00
|
|
|
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range);
|
|
|
|
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range);
|
2009-05-28 23:23:47 +00:00
|
|
|
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item);
|
2008-11-14 14:34:19 +00:00
|
|
|
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set);
|
2009-06-07 13:09:18 +00:00
|
|
|
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *typef);
|
2009-06-18 19:48:55 +00:00
|
|
|
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *add, const char *remove);
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
/* Function */
|
|
|
|
|
|
|
|
FunctionRNA *RNA_def_function(StructRNA *srna, const char *identifier, const char *call);
|
|
|
|
FunctionRNA *RNA_def_function_runtime(StructRNA *srna, const char *identifier, CallFunc call);
|
|
|
|
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret);
|
|
|
|
void RNA_def_function_flag(FunctionRNA *func, int flag);
|
|
|
|
void RNA_def_function_ui_description(FunctionRNA *func, const char *description);
|
|
|
|
|
2009-03-14 23:17:55 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2009-03-14 23:17:55 +00:00
|
|
|
#endif /* RNA_DEFINE_H */
|
2008-12-19 04:06:24 +00:00
|
|
|
|