Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * Contributor(s): Blender Foundation (2008). 00019 * 00020 * ***** END GPL LICENSE BLOCK ***** 00021 */ 00022 00023 #ifndef RNA_DEFINE_H 00024 #define RNA_DEFINE_H 00025 00030 #include <float.h> 00031 #include <limits.h> 00032 00033 #include "DNA_listBase.h" 00034 #include "RNA_types.h" 00035 00036 #ifdef __cplusplus 00037 extern "C" { 00038 #endif 00039 00040 /* Blender RNA */ 00041 00042 BlenderRNA *RNA_create(void); 00043 void RNA_define_free(BlenderRNA *brna); 00044 void RNA_free(BlenderRNA *brna); 00045 void RNA_define_verify_sdna(int verify); 00046 00047 void RNA_init(void); 00048 void RNA_exit(void); 00049 00050 /* Struct */ 00051 00052 StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from); 00053 void RNA_def_struct_sdna(StructRNA *srna, const char *structname); 00054 void RNA_def_struct_sdna_from(StructRNA *srna, const char *structname, const char *propname); 00055 void RNA_def_struct_name_property(StructRNA *srna, PropertyRNA *prop); 00056 void RNA_def_struct_nested(BlenderRNA *brna, StructRNA *srna, const char *structname); 00057 void RNA_def_struct_flag(StructRNA *srna, int flag); 00058 void RNA_def_struct_clear_flag(StructRNA *srna, int flag); 00059 void RNA_def_struct_refine_func(StructRNA *srna, const char *refine); 00060 void RNA_def_struct_idprops_func(StructRNA *srna, const char *refine); 00061 void RNA_def_struct_register_funcs(StructRNA *srna, const char *reg, const char *unreg, const char *instance); 00062 void RNA_def_struct_path_func(StructRNA *srna, const char *path); 00063 void RNA_def_struct_identifier(StructRNA *srna, const char *identifier); 00064 void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description); 00065 void RNA_def_struct_ui_icon(StructRNA *srna, int icon); 00066 void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *ext); 00067 void RNA_struct_free(BlenderRNA *brna, StructRNA *srna); 00068 00069 /* Compact Property Definitions */ 00070 00071 typedef void StructOrFunctionRNA; 00072 00073 PropertyRNA *RNA_def_boolean(StructOrFunctionRNA *cont, const char *identifier, int default_value, const char *ui_name, const char *ui_description); 00074 PropertyRNA *RNA_def_boolean_array(StructOrFunctionRNA *cont, const char *identifier, int len, int *default_value, const char *ui_name, const char *ui_description); 00075 PropertyRNA *RNA_def_boolean_layer(StructOrFunctionRNA *cont, const char *identifier, int len, int *default_value, const char *ui_name, const char *ui_description); 00076 PropertyRNA *RNA_def_boolean_layer_member(StructOrFunctionRNA *cont, const char *identifier, int len, int *default_value, const char *ui_name, const char *ui_description); 00077 PropertyRNA *RNA_def_boolean_vector(StructOrFunctionRNA *cont, const char *identifier, int len, int *default_value, const char *ui_name, const char *ui_description); 00078 00079 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); 00080 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); 00081 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); 00082 00083 PropertyRNA *RNA_def_string(StructOrFunctionRNA *cont, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description); 00084 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); 00085 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); 00086 PropertyRNA *RNA_def_string_file_name(StructOrFunctionRNA *cont, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description); 00087 PropertyRNA *RNA_def_string_translate(StructOrFunctionRNA *cont, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description); 00088 00089 PropertyRNA *RNA_def_enum(StructOrFunctionRNA *cont, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description); 00090 PropertyRNA *RNA_def_enum_flag(StructOrFunctionRNA *cont, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description); 00091 void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc); 00092 void RNA_def_enum_py_data(PropertyRNA *prop, void *py_data); 00093 00094 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); 00095 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); 00096 PropertyRNA *RNA_def_float_vector_xyz(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); 00097 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); 00098 PropertyRNA *RNA_def_float_matrix(StructOrFunctionRNA *cont, const char *identifier, int rows, int columns, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax); 00099 PropertyRNA *RNA_def_float_rotation(StructOrFunctionRNA *cont, const char *identifier, int len, const float *default_value, 00100 float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax); 00101 PropertyRNA *RNA_def_float_array(StructOrFunctionRNA *cont, const char *identifier, int len, const float *default_value, 00102 float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax); 00103 /* 00104 PropertyRNA *RNA_def_float_dynamic_array(StructOrFunctionRNA *cont, const char *identifier, float hardmin, float hardmax, 00105 const char *ui_name, const char *ui_description, float softmin, float softmax, unsigned int dimension, unsigned short dim_size[]); 00106 */ 00107 PropertyRNA *RNA_def_float_percentage(StructOrFunctionRNA *cont, const char *identifier, float default_value, float hardmin, float hardmax, 00108 const char *ui_name, const char *ui_description, float softmin, float softmax); 00109 PropertyRNA *RNA_def_float_factor(StructOrFunctionRNA *cont, const char *identifier, float default_value, float hardmin, float hardmax, 00110 const char *ui_name, const char *ui_description, float softmin, float softmax); 00111 00112 PropertyRNA *RNA_def_pointer(StructOrFunctionRNA *cont, const char *identifier, const char *type, 00113 const char *ui_name, const char *ui_description); 00114 PropertyRNA *RNA_def_pointer_runtime(StructOrFunctionRNA *cont, const char *identifier, StructRNA *type, 00115 const char *ui_name, const char *ui_description); 00116 00117 PropertyRNA *RNA_def_collection(StructOrFunctionRNA *cont, const char *identifier, const char *type, 00118 const char *ui_name, const char *ui_description); 00119 PropertyRNA *RNA_def_collection_runtime(StructOrFunctionRNA *cont, const char *identifier, StructRNA *type, 00120 const char *ui_name, const char *ui_description); 00121 00122 /* Extended Property Definitions */ 00123 00124 PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont, const char *identifier, int type, int subtype); 00125 00126 void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int bit); 00127 void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname, const char *propname, int bit); 00128 void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname); 00129 void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname); 00130 void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname); 00131 void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname); 00132 void RNA_def_property_enum_bitflag_sdna(PropertyRNA *prop, const char *structname, const char *propname); 00133 void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname); 00134 void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname); 00135 00136 void RNA_def_property_flag(PropertyRNA *prop, int flag); 00137 void RNA_def_property_clear_flag(PropertyRNA *prop, int flag); 00138 void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype); 00139 void RNA_def_property_array(PropertyRNA *prop, int length); 00140 void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[]); 00141 void RNA_def_property_range(PropertyRNA *prop, double min, double max); 00142 00143 void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item); 00144 void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength); 00145 void RNA_def_property_struct_type(PropertyRNA *prop, const char *type); 00146 void RNA_def_property_struct_runtime(PropertyRNA *prop, StructRNA *type); 00147 00148 void RNA_def_property_boolean_default(PropertyRNA *prop, int value); 00149 void RNA_def_property_boolean_array_default(PropertyRNA *prop, const int *array); 00150 void RNA_def_property_int_default(PropertyRNA *prop, int value); 00151 void RNA_def_property_int_array_default(PropertyRNA *prop, const int *array); 00152 void RNA_def_property_float_default(PropertyRNA *prop, float value); 00153 void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array); 00154 void RNA_def_property_enum_default(PropertyRNA *prop, int value); 00155 void RNA_def_property_string_default(PropertyRNA *prop, const char *value); 00156 00157 void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description); 00158 void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision); 00159 void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive); 00160 00161 void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *updatefunc); 00162 void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable); 00163 void RNA_def_property_editable_array_func(PropertyRNA *prop, const char *editable); 00164 00165 void RNA_def_property_update_runtime(PropertyRNA *prop, void *func); 00166 00167 void RNA_def_property_dynamic_array_funcs(PropertyRNA *prop, const char *getlength); 00168 void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set); 00169 void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range); 00170 void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range); 00171 void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item); 00172 void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set); 00173 void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *typef, const char *poll); 00174 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 *assignint); 00175 void RNA_def_property_srna(PropertyRNA *prop, const char *type); 00176 void RNA_def_py_data(PropertyRNA *prop, void *py_data); 00177 00178 void RNA_def_property_translation_context(PropertyRNA *prop, const char *context); 00179 00180 /* Function */ 00181 00182 FunctionRNA *RNA_def_function(StructRNA *srna, const char *identifier, const char *call); 00183 FunctionRNA *RNA_def_function_runtime(StructRNA *srna, const char *identifier, CallFunc call); 00184 void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret); 00185 void RNA_def_function_output(FunctionRNA *func, PropertyRNA *ret); 00186 void RNA_def_function_flag(FunctionRNA *func, int flag); 00187 void RNA_def_function_ui_description(FunctionRNA *func, const char *description); 00188 00189 /* Dynamic Enums 00190 * strings are not freed, assumed pointing to static location. */ 00191 00192 void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item); 00193 void RNA_enum_item_add_separator(EnumPropertyItem **items, int *totitem); 00194 void RNA_enum_items_add(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item); 00195 void RNA_enum_items_add_value(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item, int value); 00196 void RNA_enum_item_end(EnumPropertyItem **items, int *totitem); 00197 00198 /* Memory management */ 00199 00200 void RNA_def_struct_duplicate_pointers(StructRNA *srna); 00201 void RNA_def_struct_free_pointers(StructRNA *srna); 00202 void RNA_def_func_duplicate_pointers(FunctionRNA *func); 00203 void RNA_def_func_free_pointers(FunctionRNA *func); 00204 void RNA_def_property_duplicate_pointers(StructOrFunctionRNA *cont_, PropertyRNA *prop); 00205 void RNA_def_property_free_pointers(PropertyRNA *prop); 00206 int RNA_def_property_free_identifier(StructOrFunctionRNA *cont_, const char *identifier); 00207 00208 /* utilities */ 00209 const char *RNA_property_typename(PropertyType type); 00210 #define IS_DNATYPE_FLOAT_COMPAT(_str) (strcmp(_str, "float") == 0 || strcmp(_str, "double") == 0) 00211 #define IS_DNATYPE_INT_COMPAT(_str) (strcmp(_str, "int") == 0 || strcmp(_str, "short") == 0 || strcmp(_str, "char") == 0) 00212 00213 /* max size for dynamic defined type descriptors, 00214 * this value is arbitrary */ 00215 #define RNA_DYN_DESCR_MAX 240 00216 00217 #ifdef __cplusplus 00218 } 00219 #endif 00220 00221 #endif /* RNA_DEFINE_H */ 00222