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