diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_main_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_main_api.c | 302 |
1 files changed, 163 insertions, 139 deletions
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index b38f4fa67b6..4b7ce640a56 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -202,7 +202,7 @@ static Object *rna_Main_objects_new(Main *bmain, ReportList *reports, const char default: { const char *idname; - if (RNA_enum_id_from_value(id_type_items, GS(data->name), &idname) == 0) + if (RNA_enum_id_from_value(rna_enum_id_type_items, GS(data->name), &idname) == 0) idname = "UNKNOWN"; BKE_reportf(reports, RPT_ERROR, "ID type '%s' is not valid for an object", idname); @@ -218,7 +218,7 @@ static Object *rna_Main_objects_new(Main *bmain, ReportList *reports, const char ob->data = data; test_object_materials(bmain, ob->data); - + return ob; } @@ -226,7 +226,7 @@ static void rna_Main_objects_remove(Main *bmain, ReportList *reports, PointerRNA { Object *object = object_ptr->data; if (ID_REAL_USERS(object) <= 0) { - BKE_object_unlink(object); /* needed or ID pointers to this are not cleared */ + BKE_object_unlink(bmain, object); /* needed or ID pointers to this are not cleared */ BKE_libblock_free(bmain, object); RNA_POINTER_INVALIDATE(object_ptr); } @@ -264,7 +264,7 @@ static struct bNodeTree *rna_Main_nodetree_new(Main *bmain, const char *name, in bNodeTreeType *typeinfo = rna_node_tree_type_from_enum(type); if (typeinfo) { bNodeTree *ntree = ntreeAddTree(bmain, name, typeinfo->idname); - + id_us_min(&ntree->id); return ntree; } @@ -352,18 +352,24 @@ static Image *rna_Main_images_new(Main *bmain, const char *name, int width, int id_us_min(&image->id); return image; } -static Image *rna_Main_images_load(Main *bmain, ReportList *reports, const char *filepath) +static Image *rna_Main_images_load(Main *bmain, ReportList *reports, const char *filepath, int check_existing) { Image *ima; errno = 0; - ima = BKE_image_load(bmain, filepath); + if (check_existing) { + ima = BKE_image_load_exists(filepath); + } + else { + ima = BKE_image_load(bmain, filepath); + } if (!ima) { BKE_reportf(reports, RPT_ERROR, "Cannot read '%s': %s", filepath, errno ? strerror(errno) : TIP_("unsupported image format")); } + id_us_min((ID *)ima); return ima; } static void rna_Main_images_remove(Main *bmain, ReportList *reports, PointerRNA *image_ptr) @@ -436,17 +442,23 @@ static void rna_Main_metaballs_remove(Main *bmain, ReportList *reports, PointerR } } -static VFont *rna_Main_fonts_load(Main *bmain, ReportList *reports, const char *filepath) +static VFont *rna_Main_fonts_load(Main *bmain, ReportList *reports, const char *filepath, int check_existing) { VFont *font; - errno = 0; - font = BKE_vfont_load(bmain, filepath); + + if (check_existing) { + font = BKE_vfont_load_exists(bmain, filepath); + } + else { + font = BKE_vfont_load(bmain, filepath); + } if (!font) BKE_reportf(reports, RPT_ERROR, "Cannot read '%s': %s", filepath, errno ? strerror(errno) : TIP_("unsupported font format")); + id_us_min((ID *)font); return font; } @@ -494,6 +506,7 @@ static void rna_Main_brushes_remove(Main *bmain, ReportList *reports, PointerRNA { Brush *brush = brush_ptr->data; if (ID_REAL_USERS(brush) <= 0) { + BKE_brush_unlink(bmain, brush); BKE_libblock_free(bmain, brush); RNA_POINTER_INVALIDATE(brush_ptr); } @@ -529,7 +542,7 @@ static Group *rna_Main_groups_new(Main *bmain, const char *name) static void rna_Main_groups_remove(Main *bmain, PointerRNA *group_ptr) { Group *group = group_ptr->data; - BKE_group_unlink(group); + BKE_group_unlink(bmain, group); BKE_libblock_free(bmain, group); RNA_POINTER_INVALIDATE(group_ptr); } @@ -553,9 +566,17 @@ static void rna_Main_speakers_remove(Main *bmain, ReportList *reports, PointerRN } } -static bSound *rna_Main_sounds_load(Main *bmain, const char *name) +static bSound *rna_Main_sounds_load(Main *bmain, const char *name, int check_existing) { - bSound *sound = BKE_sound_new_file(bmain, name); + bSound *sound; + + if (check_existing) { + sound = BKE_sound_new_file_exists(bmain, name); + } + else { + sound = BKE_sound_new_file(bmain, name); + } + id_us_min(&sound->id); return sound; } @@ -620,8 +641,7 @@ static void rna_Main_armatures_remove(Main *bmain, ReportList *reports, PointerR static bAction *rna_Main_actions_new(Main *bmain, const char *name) { bAction *act = add_empty_action(bmain, name); - id_us_min(&act->id); - act->id.flag &= ~LIB_FAKEUSER; + id_fake_user_clear(&act->id); return act; } static void rna_Main_actions_remove(Main *bmain, ReportList *reports, PointerRNA *act_ptr) @@ -675,17 +695,24 @@ static void rna_Main_palettes_remove(Main *bmain, ReportList *reports, PointerRN } } -static MovieClip *rna_Main_movieclip_load(Main *bmain, ReportList *reports, const char *filepath) +static MovieClip *rna_Main_movieclip_load(Main *bmain, ReportList *reports, const char *filepath, int check_existing) { MovieClip *clip; errno = 0; - clip = BKE_movieclip_file_add(bmain, filepath); + + if (check_existing) { + clip = BKE_movieclip_file_add_exists(bmain, filepath); + } + else { + clip = BKE_movieclip_file_add(bmain, filepath); + } if (!clip) BKE_reportf(reports, RPT_ERROR, "Cannot read '%s': %s", filepath, errno ? strerror(errno) : TIP_("unable to load movie clip")); + id_us_min((ID *)clip); return clip; } @@ -745,68 +772,48 @@ static void rna_Main_linestyles_remove(Main *bmain, ReportList *reports, Freesty /* XXX python now has invalid pointer? */ } -/* tag functions, all the same */ -static void rna_Main_cameras_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->camera, value); } -static void rna_Main_scenes_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->scene, value); } -static void rna_Main_objects_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->object, value); } -static void rna_Main_materials_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->mat, value); } -static void rna_Main_node_groups_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->nodetree, value); } -static void rna_Main_meshes_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->mesh, value); } -static void rna_Main_lamps_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->lamp, value); } -static void rna_Main_libraries_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->library, value); } -static void rna_Main_screens_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->screen, value); } -static void rna_Main_window_managers_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->wm, value); } -static void rna_Main_images_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->image, value); } -static void rna_Main_lattices_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->latt, value); } -static void rna_Main_curves_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->curve, value); } -static void rna_Main_metaballs_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->mball, value); } -static void rna_Main_fonts_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->vfont, value); } -static void rna_Main_textures_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->tex, value); } -static void rna_Main_brushes_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->brush, value); } -static void rna_Main_worlds_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->world, value); } -static void rna_Main_groups_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->group, value); } -// static void rna_Main_shape_keys_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->key, value); } -// static void rna_Main_scripts_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->script, value); } -static void rna_Main_texts_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->text, value); } -static void rna_Main_speakers_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->speaker, value); } -static void rna_Main_sounds_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->sound, value); } -static void rna_Main_armatures_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->armature, value); } -static void rna_Main_actions_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->action, value); } -static void rna_Main_particles_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->particle, value); } -static void rna_Main_palettes_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->palettes, value); } -static void rna_Main_gpencil_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->gpencil, value); } -static void rna_Main_movieclips_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->movieclip, value); } -static void rna_Main_masks_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->mask, value); } -static void rna_Main_linestyle_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->linestyle, value); } - -static int rna_Main_cameras_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_CA) != 0; } -static int rna_Main_scenes_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_SCE) != 0; } -static int rna_Main_objects_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_OB) != 0; } -static int rna_Main_materials_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_MA) != 0; } -static int rna_Main_node_groups_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_NT) != 0; } -static int rna_Main_meshes_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_ME) != 0; } -static int rna_Main_lamps_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_LA) != 0; } -static int rna_Main_libraries_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_LI) != 0; } -static int rna_Main_screens_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_SCR) != 0; } -static int rna_Main_window_managers_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_WM) != 0; } -static int rna_Main_images_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_IM) != 0; } -static int rna_Main_lattices_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_LT) != 0; } -static int rna_Main_curves_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_CU) != 0; } -static int rna_Main_metaballs_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_MB) != 0; } -static int rna_Main_fonts_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_VF) != 0; } -static int rna_Main_textures_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_TE) != 0; } -static int rna_Main_brushes_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_BR) != 0; } -static int rna_Main_worlds_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_WO) != 0; } -static int rna_Main_groups_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_GR) != 0; } -static int rna_Main_texts_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_TXT) != 0; } -static int rna_Main_speakers_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_SPK) != 0; } -static int rna_Main_sounds_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_SO) != 0; } -static int rna_Main_armatures_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_AR) != 0; } -static int rna_Main_actions_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_AC) != 0; } -static int rna_Main_particles_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_PA) != 0; } -static int rna_Main_palettes_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_PAL) != 0; } -static int rna_Main_gpencil_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_GD) != 0; } -static int rna_Main_linestyle_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_LS) != 0; } +/* tag and is_updated functions, all the same */ +#define RNA_MAIN_ID_TAG_FUNCS_DEF(_func_name, _listbase_name, _id_type) \ + static void rna_Main_##_func_name##_tag(Main *bmain, int value) { \ + BKE_main_id_tag_listbase(&bmain->_listbase_name, LIB_TAG_DOIT, value); \ + } \ + static int rna_Main_##_func_name##_is_updated_get(PointerRNA *ptr) { \ + return DAG_id_type_tagged(ptr->data, _id_type) != 0; \ + } + +RNA_MAIN_ID_TAG_FUNCS_DEF(cameras, camera, ID_CA) +RNA_MAIN_ID_TAG_FUNCS_DEF(scenes, scene, ID_SCE) +RNA_MAIN_ID_TAG_FUNCS_DEF(objects, object, ID_OB) +RNA_MAIN_ID_TAG_FUNCS_DEF(materials, mat, ID_MA) +RNA_MAIN_ID_TAG_FUNCS_DEF(node_groups, nodetree, ID_NT) +RNA_MAIN_ID_TAG_FUNCS_DEF(meshes, mesh, ID_ME) +RNA_MAIN_ID_TAG_FUNCS_DEF(lamps, lamp, ID_LA) +RNA_MAIN_ID_TAG_FUNCS_DEF(libraries, library, ID_LI) +RNA_MAIN_ID_TAG_FUNCS_DEF(screens, screen, ID_SCR) +RNA_MAIN_ID_TAG_FUNCS_DEF(window_managers, wm, ID_WM) +RNA_MAIN_ID_TAG_FUNCS_DEF(images, image, ID_IM) +RNA_MAIN_ID_TAG_FUNCS_DEF(lattices, latt, ID_LT) +RNA_MAIN_ID_TAG_FUNCS_DEF(curves, curve, ID_CU) +RNA_MAIN_ID_TAG_FUNCS_DEF(metaballs, mball, ID_MB) +RNA_MAIN_ID_TAG_FUNCS_DEF(fonts, vfont, ID_VF) +RNA_MAIN_ID_TAG_FUNCS_DEF(textures, tex, ID_TE) +RNA_MAIN_ID_TAG_FUNCS_DEF(brushes, brush, ID_BR) +RNA_MAIN_ID_TAG_FUNCS_DEF(worlds, world, ID_WO) +RNA_MAIN_ID_TAG_FUNCS_DEF(groups, group, ID_GR) +//RNA_MAIN_ID_TAG_FUNCS_DEF(shape_keys, key, ID_KE) +RNA_MAIN_ID_TAG_FUNCS_DEF(texts, text, ID_TXT) +RNA_MAIN_ID_TAG_FUNCS_DEF(speakers, speaker, ID_SPK) +RNA_MAIN_ID_TAG_FUNCS_DEF(sounds, sound, ID_SO) +RNA_MAIN_ID_TAG_FUNCS_DEF(armatures, armature, ID_AR) +RNA_MAIN_ID_TAG_FUNCS_DEF(actions, action, ID_AC) +RNA_MAIN_ID_TAG_FUNCS_DEF(particles, particle, ID_PA) +RNA_MAIN_ID_TAG_FUNCS_DEF(palettes, palettes, ID_PAL) +RNA_MAIN_ID_TAG_FUNCS_DEF(gpencil, gpencil, ID_GD) +RNA_MAIN_ID_TAG_FUNCS_DEF(movieclips, movieclip, ID_MC) +RNA_MAIN_ID_TAG_FUNCS_DEF(masks, mask, ID_MSK) +RNA_MAIN_ID_TAG_FUNCS_DEF(linestyle, linestyle, ID_LS) + +#undef RNA_MAIN_ID_TAG_FUNCS_DEF #else @@ -841,10 +848,10 @@ void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_Main_cameras_new"); RNA_def_function_ui_description(func, "Add a new camera to the main database"); - parm = RNA_def_string(func, "name", "Camera", 0, "", "New name for the datablock"); + parm = RNA_def_string(func, "name", "Camera", 0, "", "New name for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "camera", "Camera", "", "New camera datablock"); + parm = RNA_def_pointer(func, "camera", "Camera", "", "New camera data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_cameras_remove"); @@ -877,10 +884,10 @@ void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_Main_scenes_new"); RNA_def_function_ui_description(func, "Add a new scene to the main database"); - parm = RNA_def_string(func, "name", "Scene", 0, "", "New name for the datablock"); + parm = RNA_def_string(func, "name", "Scene", 0, "", "New name for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "scene", "Scene", "", "New scene datablock"); + parm = RNA_def_pointer(func, "scene", "Scene", "", "New scene data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_scenes_remove"); @@ -914,13 +921,13 @@ void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_Main_objects_new"); RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Add a new object to the main database"); - parm = RNA_def_string(func, "name", "Object", 0, "", "New name for the datablock"); + parm = RNA_def_string(func, "name", "Object", 0, "", "New name for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); parm = RNA_def_pointer(func, "object_data", "ID", "", "Object data or None for an empty object"); RNA_def_property_flag(parm, PROP_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "object", "Object", "", "New object datablock"); + parm = RNA_def_pointer(func, "object", "Object", "", "New object data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_objects_remove"); @@ -953,10 +960,10 @@ void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_Main_materials_new"); RNA_def_function_ui_description(func, "Add a new material to the main database"); - parm = RNA_def_string(func, "name", "Material", 0, "", "New name for the datablock"); + parm = RNA_def_string(func, "name", "Material", 0, "", "New name for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "material", "Material", "", "New material datablock"); + parm = RNA_def_pointer(func, "material", "Material", "", "New material data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_materials_remove"); @@ -993,13 +1000,13 @@ void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_Main_nodetree_new"); RNA_def_function_ui_description(func, "Add a new node tree to the main database"); - parm = RNA_def_string(func, "name", "NodeGroup", 0, "", "New name for the datablock"); + parm = RNA_def_string(func, "name", "NodeGroup", 0, "", "New name for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); parm = RNA_def_enum(func, "type", dummy_items, 0, "Type", "The type of node_group to add"); RNA_def_property_enum_funcs(parm, NULL, NULL, "rna_Main_nodetree_type_itemf"); RNA_def_property_flag(parm, PROP_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "tree", "NodeTree", "", "New node tree datablock"); + parm = RNA_def_pointer(func, "tree", "NodeTree", "", "New node tree data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_nodetree_remove"); @@ -1037,10 +1044,10 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_Main_meshes_new"); RNA_def_function_ui_description(func, "Add a new mesh to the main database"); - parm = RNA_def_string(func, "name", "Mesh", 0, "", "New name for the datablock"); + parm = RNA_def_string(func, "name", "Mesh", 0, "", "New name for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "mesh", "Mesh", "", "New mesh datablock"); + parm = RNA_def_pointer(func, "mesh", "Mesh", "", "New mesh data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "new_from_object", "rna_Main_meshes_new_from_object"); @@ -1089,12 +1096,12 @@ void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_Main_lamps_new"); RNA_def_function_ui_description(func, "Add a new lamp to the main database"); - parm = RNA_def_string(func, "name", "Lamp", 0, "", "New name for the datablock"); + parm = RNA_def_string(func, "name", "Lamp", 0, "", "New name for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); - parm = RNA_def_enum(func, "type", lamp_type_items, 0, "Type", "The type of texture to add"); + parm = RNA_def_enum(func, "type", rna_enum_lamp_type_items, 0, "Type", "The type of texture to add"); RNA_def_property_flag(parm, PROP_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "lamp", "Lamp", "", "New lamp datablock"); + parm = RNA_def_pointer(func, "lamp", "Lamp", "", "New lamp data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_lamps_remove"); @@ -1189,7 +1196,7 @@ void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_Main_images_new"); RNA_def_function_ui_description(func, "Add a new image to the main database"); - parm = RNA_def_string(func, "name", "Image", 0, "", "New name for the datablock"); + parm = RNA_def_string(func, "name", "Image", 0, "", "New name for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); parm = RNA_def_int(func, "width", 1024, 1, INT_MAX, "", "Width of the image", 1, INT_MAX); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -1199,7 +1206,7 @@ void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_boolean(func, "float_buffer", 0, "Float Buffer", "Create an image with floating point color"); RNA_def_boolean(func, "stereo3d", 0, "Stereo 3D", "Create left and right views"); /* return type */ - parm = RNA_def_pointer(func, "image", "Image", "", "New image datablock"); + parm = RNA_def_pointer(func, "image", "Image", "", "New image data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "load", "rna_Main_images_load"); @@ -1207,8 +1214,9 @@ void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Load a new image into the main database"); parm = RNA_def_string_file_path(func, "filepath", "File Path", 0, "", "path of the file to load"); RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_boolean(func, "check_existing", false, "", "Using existing data-block if this file is already loaded"); /* return type */ - parm = RNA_def_pointer(func, "image", "Image", "", "New image datablock"); + parm = RNA_def_pointer(func, "image", "Image", "", "New image data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_images_remove"); @@ -1241,10 +1249,10 @@ void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_Main_lattices_new"); RNA_def_function_ui_description(func, "Add a new lattice to the main database"); - parm = RNA_def_string(func, "name", "Lattice", 0, "", "New name for the datablock"); + parm = RNA_def_string(func, "name", "Lattice", 0, "", "New name for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "lattice", "Lattice", "", "New lattices datablock"); + parm = RNA_def_pointer(func, "lattice", "Lattice", "", "New lattices data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_lattices_remove"); @@ -1276,12 +1284,12 @@ void RNA_def_main_curves(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_Main_curves_new"); RNA_def_function_ui_description(func, "Add a new curve to the main database"); - parm = RNA_def_string(func, "name", "Curve", 0, "", "New name for the datablock"); + parm = RNA_def_string(func, "name", "Curve", 0, "", "New name for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); - parm = RNA_def_enum(func, "type", object_type_curve_items, 0, "Type", "The type of curve to add"); + parm = RNA_def_enum(func, "type", rna_enum_object_type_curve_items, 0, "Type", "The type of curve to add"); RNA_def_property_flag(parm, PROP_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "curve", "Curve", "", "New curve datablock"); + parm = RNA_def_pointer(func, "curve", "Curve", "", "New curve data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_curves_remove"); @@ -1313,10 +1321,10 @@ void RNA_def_main_metaballs(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_Main_metaballs_new"); RNA_def_function_ui_description(func, "Add a new metaball to the main database"); - parm = RNA_def_string(func, "name", "MetaBall", 0, "", "New name for the datablock"); + parm = RNA_def_string(func, "name", "MetaBall", 0, "", "New name for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "metaball", "MetaBall", "", "New metaball datablock"); + parm = RNA_def_pointer(func, "metaball", "MetaBall", "", "New metaball data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_metaballs_remove"); @@ -1351,8 +1359,9 @@ void RNA_def_main_fonts(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Load a new font into the main database"); parm = RNA_def_string_file_path(func, "filepath", "File Path", 0, "", "path of the font to load"); RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_boolean(func, "check_existing", false, "", "Using existing data-block if this file is already loaded"); /* return type */ - parm = RNA_def_pointer(func, "vfont", "VectorFont", "", "New font datablock"); + parm = RNA_def_pointer(func, "vfont", "VectorFont", "", "New font data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_fonts_remove"); @@ -1384,12 +1393,12 @@ void RNA_def_main_textures(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_Main_textures_new"); RNA_def_function_ui_description(func, "Add a new texture to the main database"); - parm = RNA_def_string(func, "name", "Texture", 0, "", "New name for the datablock"); + parm = RNA_def_string(func, "name", "Texture", 0, "", "New name for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); - parm = RNA_def_enum(func, "type", texture_type_items, 0, "Type", "The type of texture to add"); + parm = RNA_def_enum(func, "type", rna_enum_texture_type_items, 0, "Type", "The type of texture to add"); RNA_def_property_flag(parm, PROP_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "texture", "Texture", "", "New texture datablock"); + parm = RNA_def_pointer(func, "texture", "Texture", "", "New texture data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_textures_remove"); @@ -1421,11 +1430,11 @@ void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_Main_brushes_new"); RNA_def_function_ui_description(func, "Add a new brush to the main database"); - parm = RNA_def_string(func, "name", "Brush", 0, "", "New name for the datablock"); + parm = RNA_def_string(func, "name", "Brush", 0, "", "New name for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); - parm = RNA_def_enum(func, "mode", object_mode_items, OB_MODE_TEXTURE_PAINT, "", "Paint Mode for the new brush"); + parm = RNA_def_enum(func, "mode", rna_enum_object_mode_items, OB_MODE_TEXTURE_PAINT, "", "Paint Mode for the new brush"); /* return type */ - parm = RNA_def_pointer(func, "brush", "Brush", "", "New brush datablock"); + parm = RNA_def_pointer(func, "brush", "Brush", "", "New brush data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_brushes_remove"); @@ -1458,10 +1467,10 @@ void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_Main_worlds_new"); RNA_def_function_ui_description(func, "Add a new world to the main database"); - parm = RNA_def_string(func, "name", "World", 0, "", "New name for the datablock"); + parm = RNA_def_string(func, "name", "World", 0, "", "New name for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "world", "World", "", "New world datablock"); + parm = RNA_def_pointer(func, "world", "World", "", "New world data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_worlds_remove"); @@ -1494,10 +1503,10 @@ void RNA_def_main_groups(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_Main_groups_new"); RNA_def_function_ui_description(func, "Add a new group to the main database"); - parm = RNA_def_string(func, "name", "Group", 0, "", "New name for the datablock"); + parm = RNA_def_string(func, "name", "Group", 0, "", "New name for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "group", "Group", "", "New group datablock"); + parm = RNA_def_pointer(func, "group", "Group", "", "New group data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_groups_remove"); @@ -1529,10 +1538,10 @@ void RNA_def_main_speakers(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_Main_speakers_new"); RNA_def_function_ui_description(func, "Add a new speaker to the main database"); - parm = RNA_def_string(func, "name", "Speaker", 0, "", "New name for the datablock"); + parm = RNA_def_string(func, "name", "Speaker", 0, "", "New name for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "speaker", "Speaker", "", "New speaker datablock"); + parm = RNA_def_pointer(func, "speaker", "Speaker", "", "New speaker data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_speakers_remove"); @@ -1565,10 +1574,10 @@ void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_Main_texts_new"); RNA_def_function_ui_description(func, "Add a new text to the main database"); - parm = RNA_def_string(func, "name", "Text", 0, "", "New name for the datablock"); + parm = RNA_def_string(func, "name", "Text", 0, "", "New name for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "text", "Text", "", "New text datablock"); + parm = RNA_def_pointer(func, "text", "Text", "", "New text data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_texts_remove"); @@ -1581,11 +1590,11 @@ void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "load", "rna_Main_texts_load"); RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Add a new text to the main database from a file"); - parm = RNA_def_string_file_path(func, "filepath", "Path", FILE_MAX, "", "path for the datablock"); + parm = RNA_def_string_file_path(func, "filepath", "Path", FILE_MAX, "", "path for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); parm = RNA_def_boolean(func, "internal", 0, "Make internal", "Make text file internal after loading"); /* return type */ - parm = RNA_def_pointer(func, "text", "Text", "", "New text datablock"); + parm = RNA_def_pointer(func, "text", "Text", "", "New text data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "tag", "rna_Main_texts_tag"); @@ -1612,10 +1621,11 @@ void RNA_def_main_sounds(BlenderRNA *brna, PropertyRNA *cprop) /* load func */ func = RNA_def_function(srna, "load", "rna_Main_sounds_load"); RNA_def_function_ui_description(func, "Add a new sound to the main database from a file"); - parm = RNA_def_string_file_path(func, "filepath", "Path", FILE_MAX, "", "path for the datablock"); + parm = RNA_def_string_file_path(func, "filepath", "Path", FILE_MAX, "", "path for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_boolean(func, "check_existing", false, "", "Using existing data-block if this file is already loaded"); /* return type */ - parm = RNA_def_pointer(func, "sound", "Sound", "", "New text datablock"); + parm = RNA_def_pointer(func, "sound", "Sound", "", "New text data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_sounds_remove"); @@ -1648,10 +1658,10 @@ void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_Main_armatures_new"); RNA_def_function_ui_description(func, "Add a new armature to the main database"); - parm = RNA_def_string(func, "name", "Armature", 0, "", "New name for the datablock"); + parm = RNA_def_string(func, "name", "Armature", 0, "", "New name for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "armature", "Armature", "", "New armature datablock"); + parm = RNA_def_pointer(func, "armature", "Armature", "", "New armature data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_armatures_remove"); @@ -1683,10 +1693,10 @@ void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_Main_actions_new"); RNA_def_function_ui_description(func, "Add a new action to the main database"); - parm = RNA_def_string(func, "name", "Action", 0, "", "New name for the datablock"); + parm = RNA_def_string(func, "name", "Action", 0, "", "New name for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "action", "Action", "", "New action datablock"); + parm = RNA_def_pointer(func, "action", "Action", "", "New action data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_actions_remove"); @@ -1718,10 +1728,10 @@ void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_Main_particles_new"); RNA_def_function_ui_description(func, "Add a new particle settings instance to the main database"); - parm = RNA_def_string(func, "name", "ParticleSettings", 0, "", "New name for the datablock"); + parm = RNA_def_string(func, "name", "ParticleSettings", 0, "", "New name for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "particle", "ParticleSettings", "", "New particle settings datablock"); + parm = RNA_def_pointer(func, "particle", "ParticleSettings", "", "New particle settings data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_particles_remove"); @@ -1753,10 +1763,10 @@ void RNA_def_main_palettes(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_Main_palettes_new"); RNA_def_function_ui_description(func, "Add a new palette to the main database"); - parm = RNA_def_string(func, "name", "Palette", 0, "", "New name for the datablock"); + parm = RNA_def_string(func, "name", "Palette", 0, "", "New name for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "palette", "Palette", "", "New palette datablock"); + parm = RNA_def_pointer(func, "palette", "Palette", "", "New palette data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_palettes_remove"); @@ -1792,10 +1802,10 @@ void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "gpencil_data_addnew"); RNA_def_function_flag(func, FUNC_NO_SELF); - parm = RNA_def_string(func, "name", "GreasePencil", 0, "", "New name for the datablock"); + parm = RNA_def_string(func, "name", "GreasePencil", 0, "", "New name for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "grease_pencil", "GreasePencil", "", "New grease pencil datablock"); + parm = RNA_def_pointer(func, "grease_pencil", "GreasePencil", "", "New grease pencil data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_grease_pencil_remove"); @@ -1815,6 +1825,7 @@ void RNA_def_main_movieclips(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataMovieClips"); srna = RNA_def_struct(brna, "BlendDataMovieClips", NULL); @@ -1834,12 +1845,20 @@ void RNA_def_main_movieclips(BlenderRNA *brna, PropertyRNA *cprop) /* load func */ func = RNA_def_function(srna, "load", "rna_Main_movieclip_load"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_function_ui_description(func, "Add a new movie clip to the main database from a file"); - parm = RNA_def_string_file_path(func, "filepath", "Path", FILE_MAX, "", "path for the datablock"); + RNA_def_function_ui_description( + func, "Add a new movie clip to the main database from a file " + "(while ``check_existing`` is disabled for consistency with other load functions, " + "behavior with multiple movie-clips using the same file may incorrectly generate proxies)"); + parm = RNA_def_string_file_path(func, "filepath", "Path", FILE_MAX, "", "path for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_boolean(func, "check_existing", false, "", "Using existing data-block if this file is already loaded"); /* return type */ - parm = RNA_def_pointer(func, "clip", "MovieClip", "", "New movie clip datablock"); + parm = RNA_def_pointer(func, "clip", "MovieClip", "", "New movie clip data-block"); RNA_def_function_return(func, parm); + + prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_movieclips_is_updated_get", NULL); } void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop) @@ -1847,6 +1866,7 @@ void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataMasks"); srna = RNA_def_struct(brna, "BlendDataMasks", NULL); @@ -1860,9 +1880,9 @@ void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop) /* new func */ func = RNA_def_function(srna, "new", "rna_Main_mask_new"); RNA_def_function_ui_description(func, "Add a new mask with a given name to the main database"); - RNA_def_string_file_path(func, "name", NULL, MAX_ID_NAME - 2, "Mask", "Name of new mask datablock"); + RNA_def_string_file_path(func, "name", NULL, MAX_ID_NAME - 2, "Mask", "Name of new mask data-block"); /* return type */ - parm = RNA_def_pointer(func, "mask", "Mask", "", "New mask datablock"); + parm = RNA_def_pointer(func, "mask", "Mask", "", "New mask data-block"); RNA_def_function_return(func, parm); /* remove func */ @@ -1871,6 +1891,10 @@ void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop) parm = RNA_def_pointer(func, "mask", "Mask", "", "Mask to remove"); RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); + + prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_masks_is_updated_get", NULL); } void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop) @@ -1891,10 +1915,10 @@ void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_Main_linestyles_new"); RNA_def_function_ui_description(func, "Add a new line style instance to the main database"); - parm = RNA_def_string(func, "name", "FreestyleLineStyle", 0, "", "New name for the datablock"); + parm = RNA_def_string(func, "name", "FreestyleLineStyle", 0, "", "New name for the data-block"); RNA_def_property_flag(parm, PROP_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "linestyle", "FreestyleLineStyle", "", "New line style datablock"); + parm = RNA_def_pointer(func, "linestyle", "FreestyleLineStyle", "", "New line style data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_linestyles_remove"); |