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 00028 #include <stdlib.h> 00029 #include <stdio.h> 00030 00031 #include "RNA_access.h" 00032 #include "RNA_define.h" 00033 00034 #include "DNA_ID.h" 00035 #include "DNA_vfont_types.h" 00036 #include "DNA_material_types.h" 00037 #include "DNA_object_types.h" 00038 00039 #include "WM_types.h" 00040 00041 #include "rna_internal.h" 00042 00043 /* enum of ID-block types 00044 * NOTE: need to keep this in line with the other defines for these 00045 */ 00046 EnumPropertyItem id_type_items[] = { 00047 {ID_AC, "ACTION", ICON_ACTION, "Action", ""}, 00048 {ID_AR, "ARMATURE", ICON_ARMATURE_DATA, "Armature", ""}, 00049 {ID_BR, "BRUSH", ICON_BRUSH_DATA, "Brush", ""}, 00050 {ID_CA, "CAMERA", ICON_CAMERA_DATA, "Camera", ""}, 00051 {ID_CU, "CURVE", ICON_CURVE_DATA, "Curve", ""}, 00052 {ID_VF, "FONT", ICON_FONT_DATA, "Font", ""}, 00053 {ID_GD, "GREASEPENCIL", ICON_GREASEPENCIL, "Grease Pencil", ""}, 00054 {ID_GR, "GROUP", ICON_GROUP, "Group", ""}, 00055 {ID_IM, "IMAGE", ICON_IMAGE_DATA, "Image", ""}, 00056 {ID_KE, "KEY", ICON_SHAPEKEY_DATA, "Key", ""}, 00057 {ID_LA, "LAMP", ICON_LAMP_DATA, "Lamp", ""}, 00058 {ID_LI, "LIBRARY", ICON_LIBRARY_DATA_DIRECT, "Library", ""}, 00059 {ID_LT, "LATTICE", ICON_LATTICE_DATA, "Lattice", ""}, 00060 {ID_MA, "MATERIAL", ICON_MATERIAL_DATA, "Material", ""}, 00061 {ID_MB, "META", ICON_META_DATA, "MetaBall", ""}, 00062 {ID_ME, "MESH", ICON_MESH_DATA, "Mesh", ""}, 00063 {ID_NT, "NODETREE", ICON_NODETREE, "NodeTree", ""}, 00064 {ID_OB, "OBJECT", ICON_OBJECT_DATA, "Object", ""}, 00065 {ID_PA, "PARTICLE", ICON_PARTICLE_DATA, "Particle", ""}, 00066 {ID_SCE, "SCENE", ICON_SCENE_DATA, "Scene", ""}, 00067 {ID_SCR, "SCREEN", ICON_SPLITSCREEN, "Screen", ""}, 00068 {ID_SPK, "SPEAKER", ICON_SPEAKER, "Speaker", ""}, 00069 {ID_SO, "SOUND", ICON_PLAY_AUDIO, "Sound", ""}, 00070 {ID_TXT, "TEXT", ICON_TEXT, "Text", ""}, 00071 {ID_TE, "TEXTURE", ICON_TEXTURE_DATA, "Texture", ""}, 00072 {ID_WO, "WORLD", ICON_WORLD_DATA, "World", ""}, 00073 {ID_WM, "WINDOWMANAGER", ICON_FULLSCREEN, "Window Manager", ""}, 00074 {0, NULL, 0, NULL, NULL}}; 00075 00076 #ifdef RNA_RUNTIME 00077 00078 #include "BKE_idprop.h" 00079 #include "BKE_library.h" 00080 #include "BKE_animsys.h" 00081 #include "BKE_material.h" 00082 #include "BKE_depsgraph.h" 00083 00084 /* name functions that ignore the first two ID characters */ 00085 void rna_ID_name_get(PointerRNA *ptr, char *value) 00086 { 00087 ID *id= (ID*)ptr->data; 00088 BLI_strncpy(value, id->name+2, sizeof(id->name)-2); 00089 } 00090 00091 int rna_ID_name_length(PointerRNA *ptr) 00092 { 00093 ID *id= (ID*)ptr->data; 00094 return strlen(id->name+2); 00095 } 00096 00097 void rna_ID_name_set(PointerRNA *ptr, const char *value) 00098 { 00099 ID *id= (ID*)ptr->data; 00100 BLI_strncpy_utf8(id->name+2, value, sizeof(id->name)-2); 00101 test_idbutton(id->name+2); 00102 } 00103 00104 static int rna_ID_name_editable(PointerRNA *ptr) 00105 { 00106 ID *id= (ID*)ptr->data; 00107 00108 if (GS(id->name) == ID_VF) { 00109 VFont *vf= (VFont *)id; 00110 if (strcmp(vf->name, FO_BUILTIN_NAME)==0) 00111 return 0; 00112 } 00113 00114 return 1; 00115 } 00116 00117 short RNA_type_to_ID_code(StructRNA *type) 00118 { 00119 if(RNA_struct_is_a(type, &RNA_Action)) return ID_AC; 00120 if(RNA_struct_is_a(type, &RNA_Armature)) return ID_AR; 00121 if(RNA_struct_is_a(type, &RNA_Brush)) return ID_BR; 00122 if(RNA_struct_is_a(type, &RNA_Camera)) return ID_CA; 00123 if(RNA_struct_is_a(type, &RNA_Curve)) return ID_CU; 00124 if(RNA_struct_is_a(type, &RNA_GreasePencil)) return ID_GD; 00125 if(RNA_struct_is_a(type, &RNA_Group)) return ID_GR; 00126 if(RNA_struct_is_a(type, &RNA_Image)) return ID_IM; 00127 if(RNA_struct_is_a(type, &RNA_Key)) return ID_KE; 00128 if(RNA_struct_is_a(type, &RNA_Lamp)) return ID_LA; 00129 if(RNA_struct_is_a(type, &RNA_Library)) return ID_LI; 00130 if(RNA_struct_is_a(type, &RNA_Lattice)) return ID_LT; 00131 if(RNA_struct_is_a(type, &RNA_Material)) return ID_MA; 00132 if(RNA_struct_is_a(type, &RNA_MetaBall)) return ID_MB; 00133 if(RNA_struct_is_a(type, &RNA_NodeTree)) return ID_NT; 00134 if(RNA_struct_is_a(type, &RNA_Mesh)) return ID_ME; 00135 if(RNA_struct_is_a(type, &RNA_Object)) return ID_OB; 00136 if(RNA_struct_is_a(type, &RNA_ParticleSettings)) return ID_PA; 00137 if(RNA_struct_is_a(type, &RNA_Scene)) return ID_SCE; 00138 if(RNA_struct_is_a(type, &RNA_Screen)) return ID_SCR; 00139 if(RNA_struct_is_a(type, &RNA_Speaker)) return ID_SPK; 00140 if(RNA_struct_is_a(type, &RNA_Sound)) return ID_SO; 00141 if(RNA_struct_is_a(type, &RNA_Text)) return ID_TXT; 00142 if(RNA_struct_is_a(type, &RNA_Texture)) return ID_TE; 00143 if(RNA_struct_is_a(type, &RNA_VectorFont)) return ID_VF; 00144 if(RNA_struct_is_a(type, &RNA_World)) return ID_WO; 00145 if(RNA_struct_is_a(type, &RNA_WindowManager)) return ID_WM; 00146 if(RNA_struct_is_a(type, &RNA_MovieClip)) return ID_MC; 00147 00148 return 0; 00149 } 00150 00151 StructRNA *ID_code_to_RNA_type(short idcode) 00152 { 00153 switch(idcode) { 00154 case ID_AC: return &RNA_Action; 00155 case ID_AR: return &RNA_Armature; 00156 case ID_BR: return &RNA_Brush; 00157 case ID_CA: return &RNA_Camera; 00158 case ID_CU: return &RNA_Curve; 00159 case ID_GD: return &RNA_GreasePencil; 00160 case ID_GR: return &RNA_Group; 00161 case ID_IM: return &RNA_Image; 00162 case ID_KE: return &RNA_Key; 00163 case ID_LA: return &RNA_Lamp; 00164 case ID_LI: return &RNA_Library; 00165 case ID_LT: return &RNA_Lattice; 00166 case ID_MA: return &RNA_Material; 00167 case ID_MB: return &RNA_MetaBall; 00168 case ID_NT: return &RNA_NodeTree; 00169 case ID_ME: return &RNA_Mesh; 00170 case ID_OB: return &RNA_Object; 00171 case ID_PA: return &RNA_ParticleSettings; 00172 case ID_SCE: return &RNA_Scene; 00173 case ID_SCR: return &RNA_Screen; 00174 case ID_SPK: return &RNA_Speaker; 00175 case ID_SO: return &RNA_Sound; 00176 case ID_TXT: return &RNA_Text; 00177 case ID_TE: return &RNA_Texture; 00178 case ID_VF: return &RNA_VectorFont; 00179 case ID_WO: return &RNA_World; 00180 case ID_WM: return &RNA_WindowManager; 00181 case ID_MC: return &RNA_MovieClip; 00182 default: return &RNA_ID; 00183 } 00184 } 00185 00186 StructRNA *rna_ID_refine(PointerRNA *ptr) 00187 { 00188 ID *id= (ID*)ptr->data; 00189 00190 return ID_code_to_RNA_type(GS(id->name)); 00191 } 00192 00193 IDProperty *rna_ID_idprops(PointerRNA *ptr, int create) 00194 { 00195 return IDP_GetProperties(ptr->data, create); 00196 } 00197 00198 void rna_ID_fake_user_set(PointerRNA *ptr, int value) 00199 { 00200 ID *id= (ID*)ptr->data; 00201 00202 if(value && !(id->flag & LIB_FAKEUSER)) { 00203 id->flag |= LIB_FAKEUSER; 00204 id_us_plus(id); 00205 } 00206 else if(!value && (id->flag & LIB_FAKEUSER)) { 00207 id->flag &= ~LIB_FAKEUSER; 00208 id_us_min(id); 00209 } 00210 } 00211 00212 IDProperty *rna_PropertyGroup_idprops(PointerRNA *ptr, int UNUSED(create)) 00213 { 00214 return ptr->data; 00215 } 00216 00217 void rna_PropertyGroup_unregister(Main *UNUSED(bmain), StructRNA *type) 00218 { 00219 RNA_struct_free(&BLENDER_RNA, type); 00220 } 00221 00222 StructRNA *rna_PropertyGroup_register(Main *UNUSED(bmain), ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc UNUSED(call), StructFreeFunc UNUSED(free)) 00223 { 00224 PointerRNA dummyptr; 00225 00226 /* create dummy pointer */ 00227 RNA_pointer_create(NULL, &RNA_PropertyGroup, NULL, &dummyptr); 00228 00229 /* validate the python class */ 00230 if(validate(&dummyptr, data, NULL) != 0) 00231 return NULL; 00232 00233 /* note: it looks like there is no length limit on the srna id since its 00234 * just a char pointer, but take care here, also be careful that python 00235 * owns the string pointer which it could potentually free while blender 00236 * is running. */ 00237 if(BLI_strnlen(identifier, MAX_IDPROP_NAME) == MAX_IDPROP_NAME) { 00238 BKE_reportf(reports, RPT_ERROR, "registering id property class: '%s' is too long, maximum length is " STRINGIFY(MAX_IDPROP_NAME), identifier); 00239 return NULL; 00240 } 00241 00242 return RNA_def_struct(&BLENDER_RNA, identifier, "PropertyGroup"); // XXX 00243 } 00244 00245 StructRNA* rna_PropertyGroup_refine(PointerRNA *ptr) 00246 { 00247 return ptr->type; 00248 } 00249 00250 ID *rna_ID_copy(ID *id) 00251 { 00252 ID *newid; 00253 00254 if(id_copy(id, &newid, 0)) { 00255 if(newid) id_us_min(newid); 00256 return newid; 00257 } 00258 00259 return NULL; 00260 } 00261 00262 static void rna_ID_update_tag(ID *id, ReportList *reports, int flag) 00263 { 00264 /* XXX, new function for this! */ 00265 /*if (ob->type == OB_FONT) { 00266 Curve *cu = ob->data; 00267 freedisplist(&cu->disp); 00268 BKE_text_to_curve(sce, ob, CU_LEFT); 00269 }*/ 00270 00271 if(flag == 0) { 00272 /* pass */ 00273 } 00274 else { 00275 /* ensure flag us correct for the type */ 00276 switch(GS(id->name)) { 00277 case ID_OB: 00278 if(flag & ~(OB_RECALC_ALL)) { 00279 BKE_report(reports, RPT_ERROR, "'refresh' incompatible with Object ID type"); 00280 return; 00281 } 00282 break; 00283 /* Could add particle updates later */ 00284 /* case ID_PA: 00285 if(flag & ~(OB_RECALC_ALL|PSYS_RECALC)) { 00286 BKE_report(reports, RPT_ERROR, "'refresh' incompatible with ParticleSettings ID type"); 00287 return; 00288 } 00289 break; */ 00290 default: 00291 BKE_report(reports, RPT_ERROR, "This ID type is not compatible with any 'refresh' options"); 00292 return; 00293 } 00294 } 00295 00296 DAG_id_tag_update(id, flag); 00297 } 00298 00299 void rna_ID_user_clear(ID *id) 00300 { 00301 id->us= 0; /* dont save */ 00302 id->flag &= ~LIB_FAKEUSER; 00303 } 00304 00305 static void rna_IDPArray_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00306 { 00307 IDProperty *prop= (IDProperty *)ptr->data; 00308 rna_iterator_array_begin(iter, IDP_IDPArray(prop), sizeof(IDProperty), prop->len, 0, NULL); 00309 } 00310 00311 static int rna_IDPArray_length(PointerRNA *ptr) 00312 { 00313 IDProperty *prop= (IDProperty *)ptr->data; 00314 return prop->len; 00315 } 00316 00317 int rna_IDMaterials_assign_int(PointerRNA *ptr, int key, const PointerRNA *assign_ptr) 00318 { 00319 ID *id= ptr->id.data; 00320 short *totcol= give_totcolp_id(id); 00321 Material *mat_id= assign_ptr->id.data; 00322 if(totcol && (key >= 0 && key < *totcol)) { 00323 assign_material_id(id, mat_id, key + 1); 00324 return 1; 00325 } 00326 else { 00327 return 0; 00328 } 00329 } 00330 00331 void rna_Library_filepath_set(PointerRNA *ptr, const char *value) 00332 { 00333 Library *lib= (Library*)ptr->data; 00334 BKE_library_filepath_set(lib, value); 00335 } 00336 00337 #else 00338 00339 static void rna_def_ID_properties(BlenderRNA *brna) 00340 { 00341 StructRNA *srna; 00342 PropertyRNA *prop; 00343 00344 /* this is struct is used for holding the virtual 00345 * PropertyRNA's for ID properties */ 00346 srna= RNA_def_struct(brna, "PropertyGroupItem", NULL); 00347 RNA_def_struct_sdna(srna, "IDProperty"); 00348 RNA_def_struct_ui_text(srna, "ID Property", "Property that stores arbitrary, user defined properties"); 00349 00350 /* IDP_STRING */ 00351 prop= RNA_def_property(srna, "string", PROP_STRING, PROP_NONE); 00352 RNA_def_property_flag(prop, PROP_EXPORT|PROP_IDPROPERTY); 00353 00354 /* IDP_INT */ 00355 prop= RNA_def_property(srna, "int", PROP_INT, PROP_NONE); 00356 RNA_def_property_flag(prop, PROP_EXPORT|PROP_IDPROPERTY); 00357 00358 prop= RNA_def_property(srna, "int_array", PROP_INT, PROP_NONE); 00359 RNA_def_property_flag(prop, PROP_EXPORT|PROP_IDPROPERTY); 00360 RNA_def_property_array(prop, 1); 00361 00362 /* IDP_FLOAT */ 00363 prop= RNA_def_property(srna, "float", PROP_FLOAT, PROP_NONE); 00364 RNA_def_property_flag(prop, PROP_EXPORT|PROP_IDPROPERTY); 00365 00366 prop= RNA_def_property(srna, "float_array", PROP_FLOAT, PROP_NONE); 00367 RNA_def_property_flag(prop, PROP_EXPORT|PROP_IDPROPERTY); 00368 RNA_def_property_array(prop, 1); 00369 00370 /* IDP_DOUBLE */ 00371 prop= RNA_def_property(srna, "double", PROP_FLOAT, PROP_NONE); 00372 RNA_def_property_flag(prop, PROP_EXPORT|PROP_IDPROPERTY); 00373 00374 prop= RNA_def_property(srna, "double_array", PROP_FLOAT, PROP_NONE); 00375 RNA_def_property_flag(prop, PROP_EXPORT|PROP_IDPROPERTY); 00376 RNA_def_property_array(prop, 1); 00377 00378 /* IDP_GROUP */ 00379 prop= RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE); 00380 RNA_def_property_flag(prop, PROP_EXPORT|PROP_IDPROPERTY); 00381 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 00382 RNA_def_property_struct_type(prop, "PropertyGroup"); 00383 00384 prop= RNA_def_property(srna, "collection", PROP_COLLECTION, PROP_NONE); 00385 RNA_def_property_flag(prop, PROP_EXPORT|PROP_IDPROPERTY); 00386 RNA_def_property_struct_type(prop, "PropertyGroup"); 00387 00388 prop= RNA_def_property(srna, "idp_array", PROP_COLLECTION, PROP_NONE); 00389 RNA_def_property_struct_type(prop, "PropertyGroup"); 00390 RNA_def_property_collection_funcs(prop, "rna_IDPArray_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_IDPArray_length", NULL, NULL, NULL); 00391 RNA_def_property_flag(prop, PROP_EXPORT|PROP_IDPROPERTY); 00392 00393 // never tested, maybe its useful to have this? 00394 #if 0 00395 prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); 00396 RNA_def_property_flag(prop, PROP_EXPORT|PROP_IDPROPERTY); 00397 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 00398 RNA_def_property_ui_text(prop, "Name", "Unique name used in the code and scripting"); 00399 RNA_def_struct_name_property(srna, prop); 00400 #endif 00401 00402 /* IDP_ID -- not implemented yet in id properties */ 00403 00404 /* ID property groups > level 0, since level 0 group is merged 00405 * with native RNA properties. the builtin_properties will take 00406 * care of the properties here */ 00407 srna= RNA_def_struct(brna, "PropertyGroup", NULL); 00408 RNA_def_struct_sdna(srna, "IDPropertyGroup"); 00409 RNA_def_struct_ui_text(srna, "ID Property Group", "Group of ID properties"); 00410 RNA_def_struct_idprops_func(srna, "rna_PropertyGroup_idprops"); 00411 RNA_def_struct_register_funcs(srna, "rna_PropertyGroup_register", "rna_PropertyGroup_unregister", NULL); 00412 RNA_def_struct_refine_func(srna, "rna_PropertyGroup_refine"); 00413 00414 /* important so python types can have their name used in list views 00415 * however this isnt prefect because it overrides how python would set the name 00416 * when we only really want this so RNA_def_struct_name_property() is set to something useful */ 00417 prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); 00418 RNA_def_property_flag(prop, PROP_EXPORT|PROP_IDPROPERTY); 00419 //RNA_def_property_clear_flag(prop, PROP_EDITABLE); 00420 RNA_def_property_ui_text(prop, "Name", "Unique name used in the code and scripting"); 00421 RNA_def_struct_name_property(srna, prop); 00422 } 00423 00424 00425 static void rna_def_ID_materials(BlenderRNA *brna) 00426 { 00427 StructRNA *srna; 00428 FunctionRNA *func; 00429 PropertyRNA *parm; 00430 00431 /* for mesh/mball/curve materials */ 00432 srna= RNA_def_struct(brna, "IDMaterials", NULL); 00433 RNA_def_struct_sdna(srna, "ID"); 00434 RNA_def_struct_ui_text(srna, "ID Materials", "Collection of materials"); 00435 00436 func= RNA_def_function(srna, "append", "material_append_id"); 00437 RNA_def_function_ui_description(func, "Add a new material to the data block"); 00438 parm= RNA_def_pointer(func, "material", "Material", "", "Material to add"); 00439 RNA_def_property_flag(parm, PROP_REQUIRED); 00440 00441 func= RNA_def_function(srna, "pop", "material_pop_id"); 00442 RNA_def_function_ui_description(func, "Remove a material from the data block"); 00443 parm= RNA_def_int(func, "index", 0, 0, MAXMAT, "", "Index of material to remove", 0, MAXMAT); 00444 RNA_def_property_flag(parm, PROP_REQUIRED); 00445 RNA_def_boolean(func, "update_data", 0, "", "Update data by re-adjusting the material slots assigned"); 00446 parm= RNA_def_pointer(func, "material", "Material", "", "Material to remove"); 00447 RNA_def_function_return(func, parm); 00448 } 00449 00450 static void rna_def_ID(BlenderRNA *brna) 00451 { 00452 StructRNA *srna; 00453 FunctionRNA *func; 00454 PropertyRNA *prop, *parm; 00455 00456 static EnumPropertyItem update_flag_items[] = { 00457 {OB_RECALC_OB, "OBJECT", 0, "Object", ""}, 00458 {OB_RECALC_DATA, "DATA", 0, "Data", ""}, 00459 {OB_RECALC_TIME, "TIME", 0, "Time", ""}, 00460 {0, NULL, 0, NULL, NULL}}; 00461 00462 srna= RNA_def_struct(brna, "ID", NULL); 00463 RNA_def_struct_ui_text(srna, "ID", "Base type for datablocks, defining a unique name, linking from other libraries and garbage collection"); 00464 RNA_def_struct_flag(srna, STRUCT_ID|STRUCT_ID_REFCOUNT); 00465 RNA_def_struct_refine_func(srna, "rna_ID_refine"); 00466 RNA_def_struct_idprops_func(srna, "rna_ID_idprops"); 00467 00468 prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); 00469 RNA_def_property_ui_text(prop, "Name", "Unique datablock ID name"); 00470 RNA_def_property_string_funcs(prop, "rna_ID_name_get", "rna_ID_name_length", "rna_ID_name_set"); 00471 RNA_def_property_string_maxlength(prop, MAX_ID_NAME-2); 00472 RNA_def_property_editable_func(prop, "rna_ID_name_editable"); 00473 RNA_def_property_update(prop, NC_ID|NA_RENAME, NULL); 00474 RNA_def_struct_name_property(srna, prop); 00475 00476 prop= RNA_def_property(srna, "users", PROP_INT, PROP_UNSIGNED); 00477 RNA_def_property_int_sdna(prop, NULL, "us"); 00478 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 00479 RNA_def_property_ui_text(prop, "Users", "Number of times this datablock is referenced"); 00480 00481 prop= RNA_def_property(srna, "use_fake_user", PROP_BOOLEAN, PROP_NONE); 00482 RNA_def_property_boolean_sdna(prop, NULL, "flag", LIB_FAKEUSER); 00483 RNA_def_property_ui_text(prop, "Fake User", "Save this datablock even if it has no users"); 00484 RNA_def_property_boolean_funcs(prop, NULL, "rna_ID_fake_user_set"); 00485 00486 prop= RNA_def_property(srna, "tag", PROP_BOOLEAN, PROP_NONE); 00487 RNA_def_property_boolean_sdna(prop, NULL, "flag", LIB_DOIT); 00488 RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); 00489 RNA_def_property_ui_text(prop, "Tag", "Tools can use this to tag data (initial state is undefined)"); 00490 00491 prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); 00492 RNA_def_property_boolean_sdna(prop, NULL, "flag", LIB_ID_RECALC); 00493 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 00494 RNA_def_property_ui_text(prop, "Is Updated", "Datablock is tagged for recalculation"); 00495 00496 prop= RNA_def_property(srna, "is_updated_data", PROP_BOOLEAN, PROP_NONE); 00497 RNA_def_property_boolean_sdna(prop, NULL, "flag", LIB_ID_RECALC_DATA); 00498 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 00499 RNA_def_property_ui_text(prop, "Is Updated Data", "Datablock data is tagged for recalculation"); 00500 00501 prop= RNA_def_property(srna, "library", PROP_POINTER, PROP_NONE); 00502 RNA_def_property_pointer_sdna(prop, NULL, "lib"); 00503 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 00504 RNA_def_property_ui_text(prop, "Library", "Library file the datablock is linked from"); 00505 00506 /* functions */ 00507 func= RNA_def_function(srna, "copy", "rna_ID_copy"); 00508 RNA_def_function_ui_description(func, "Create a copy of this datablock (not supported for all datablocks)"); 00509 parm= RNA_def_pointer(func, "id", "ID", "", "New copy of the ID"); 00510 RNA_def_function_return(func, parm); 00511 00512 func= RNA_def_function(srna, "user_clear", "rna_ID_user_clear"); 00513 RNA_def_function_ui_description(func, "Clear the user count of a datablock so its not saved, " 00514 "on reload the data will be removed"); 00515 00516 func= RNA_def_function(srna, "animation_data_create", "BKE_id_add_animdata"); 00517 RNA_def_function_ui_description(func, "Create animation data to this ID, note that not all ID types support this"); 00518 parm= RNA_def_pointer(func, "anim_data", "AnimData", "", "New animation data or NULL"); 00519 RNA_def_function_return(func, parm); 00520 00521 func= RNA_def_function(srna, "animation_data_clear", "BKE_free_animdata"); 00522 RNA_def_function_ui_description(func, "Clear animation on this this ID"); 00523 00524 func= RNA_def_function(srna, "update_tag", "rna_ID_update_tag"); 00525 RNA_def_function_flag(func, FUNC_USE_REPORTS); 00526 RNA_def_function_ui_description(func, "Tag the ID to update its display data"); 00527 RNA_def_enum_flag(func, "refresh", update_flag_items, 0, "", "Type of updates to perform"); 00528 } 00529 00530 static void rna_def_library(BlenderRNA *brna) 00531 { 00532 StructRNA *srna; 00533 PropertyRNA *prop; 00534 00535 srna= RNA_def_struct(brna, "Library", "ID"); 00536 RNA_def_struct_ui_text(srna, "Library", "External .blend file from which data is linked"); 00537 RNA_def_struct_ui_icon(srna, ICON_LIBRARY_DATA_DIRECT); 00538 00539 prop= RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH); 00540 RNA_def_property_string_sdna(prop, NULL, "name"); 00541 RNA_def_property_ui_text(prop, "File Path", "Path to the library .blend file"); 00542 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Library_filepath_set"); 00543 00544 prop= RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE); 00545 RNA_def_property_struct_type(prop, "Library"); 00546 RNA_def_property_ui_text(prop, "Parent", ""); 00547 } 00548 void RNA_def_ID(BlenderRNA *brna) 00549 { 00550 StructRNA *srna; 00551 00552 /* built-in unknown type */ 00553 srna= RNA_def_struct(brna, "UnknownType", NULL); 00554 RNA_def_struct_ui_text(srna, "Unknown Type", "Stub RNA type used for pointers to unknown or internal data"); 00555 00556 /* built-in any type */ 00557 srna= RNA_def_struct(brna, "AnyType", NULL); 00558 RNA_def_struct_ui_text(srna, "Any Type", "RNA type used for pointers to any possible data"); 00559 00560 rna_def_ID(brna); 00561 rna_def_ID_properties(brna); 00562 rna_def_ID_materials(brna); 00563 rna_def_library(brna); 00564 } 00565 00566 #endif 00567