Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_operators.c
| Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | |||||
| #include "BLO_readfile.h" | #include "BLO_readfile.h" | ||||
| #include "BKE_appdir.h" | #include "BKE_appdir.h" | ||||
| #include "BKE_autoexec.h" | #include "BKE_autoexec.h" | ||||
| #include "BKE_blender.h" | #include "BKE_blender.h" | ||||
| #include "BKE_brush.h" | #include "BKE_brush.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_depsgraph.h" | #include "BKE_depsgraph.h" | ||||
| #include "BKE_icons.h" | |||||
| #include "BKE_idprop.h" | #include "BKE_idprop.h" | ||||
| #include "BKE_image.h" | #include "BKE_image.h" | ||||
| #include "BKE_library.h" | #include "BKE_library.h" | ||||
| #include "BKE_library_query.h" | #include "BKE_library_query.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_material.h" | #include "BKE_material.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| ▲ Show 20 Lines • Show All 1,172 Lines • ▼ Show 20 Lines | void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type, short action, short flag, short display) | ||||
| prop = RNA_def_boolean(ot->srna, "filter_text", (filter & FILE_TYPE_TEXT) != 0, "Filter text files", ""); | prop = RNA_def_boolean(ot->srna, "filter_text", (filter & FILE_TYPE_TEXT) != 0, "Filter text files", ""); | ||||
| RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); | RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); | ||||
| prop = RNA_def_boolean(ot->srna, "filter_btx", (filter & FILE_TYPE_BTX) != 0, "Filter btx files", ""); | prop = RNA_def_boolean(ot->srna, "filter_btx", (filter & FILE_TYPE_BTX) != 0, "Filter btx files", ""); | ||||
| RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); | RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); | ||||
| prop = RNA_def_boolean(ot->srna, "filter_collada", (filter & FILE_TYPE_COLLADA) != 0, "Filter COLLADA files", ""); | prop = RNA_def_boolean(ot->srna, "filter_collada", (filter & FILE_TYPE_COLLADA) != 0, "Filter COLLADA files", ""); | ||||
| RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); | RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); | ||||
| prop = RNA_def_boolean(ot->srna, "filter_folder", (filter & FILE_TYPE_FOLDER) != 0, "Filter folders", ""); | prop = RNA_def_boolean(ot->srna, "filter_folder", (filter & FILE_TYPE_FOLDER) != 0, "Filter folders", ""); | ||||
| RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); | RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); | ||||
| prop = RNA_def_boolean(ot->srna, "filter_blenlib", (filter & FILE_TYPE_BLENDERLIB) != 0, "Filter Blender IDs", ""); | |||||
| RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); | |||||
| prop = RNA_def_int(ot->srna, "filemode", type, FILE_LOADLIB, FILE_SPECIAL, | prop = RNA_def_int(ot->srna, "filemode", type, FILE_LOADLIB, FILE_SPECIAL, | ||||
| "File Browser Mode", "The setting for the file browser mode to load a .blend file, a library or a special file", | "File Browser Mode", "The setting for the file browser mode to load a .blend file, a library or a special file", | ||||
| FILE_LOADLIB, FILE_SPECIAL); | FILE_LOADLIB, FILE_SPECIAL); | ||||
| RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); | RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); | ||||
| if (flag & WM_FILESEL_RELPATH) | if (flag & WM_FILESEL_RELPATH) | ||||
| RNA_def_boolean(ot->srna, "relative_path", true, "Relative Path", "Select the file relative to the blend file"); | RNA_def_boolean(ot->srna, "relative_path", true, "Relative Path", "Select the file relative to the blend file"); | ||||
| ▲ Show 20 Lines • Show All 1,316 Lines • ▼ Show 20 Lines | static short wm_link_append_flag(wmOperator *op) | ||||
| if (RNA_boolean_get(op->ptr, "active_layer")) flag |= FILE_ACTIVELAY; | if (RNA_boolean_get(op->ptr, "active_layer")) flag |= FILE_ACTIVELAY; | ||||
| if (RNA_struct_find_property(op->ptr, "relative_path") && RNA_boolean_get(op->ptr, "relative_path")) flag |= FILE_RELPATH; | if (RNA_struct_find_property(op->ptr, "relative_path") && RNA_boolean_get(op->ptr, "relative_path")) flag |= FILE_RELPATH; | ||||
| if (RNA_boolean_get(op->ptr, "link")) flag |= FILE_LINK; | if (RNA_boolean_get(op->ptr, "link")) flag |= FILE_LINK; | ||||
| if (RNA_boolean_get(op->ptr, "instance_groups")) flag |= FILE_GROUP_INSTANCE; | if (RNA_boolean_get(op->ptr, "instance_groups")) flag |= FILE_GROUP_INSTANCE; | ||||
| return flag; | return flag; | ||||
| } | } | ||||
| static int wm_link_append_exec(bContext *C, wmOperator *op) | /* Helper. | ||||
| * if `name` is non-NULL, we assume a single-item link/append. | |||||
| * else if `*todo_libraries` is NULL we assume first-run. | |||||
| */ | |||||
| static void wm_link_append_do_libgroup( | |||||
| bContext *C, wmOperator *op, const char *root, const char *libname, char *group, char *name, | |||||
| const short flag, GSet **todo_libraries) | |||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | Main *mainl; | ||||
| Main *mainl = NULL; | |||||
| BlendHandle *bh; | BlendHandle *bh; | ||||
| Library *lib; | Library *lib; | ||||
| char path[FILE_MAX_LIBEXTRA], relname[FILE_MAX]; | |||||
| int idcode; | |||||
| const bool is_first_run = (*todo_libraries == NULL); | |||||
| BLI_assert(group); | |||||
| idcode = BKE_idcode_from_name(group); | |||||
| bh = BLO_blendhandle_from_file(libname, op->reports); | |||||
| if (bh == NULL) { | |||||
| /* unlikely since we just browsed it, but possible | |||||
| * error reports will have been made by BLO_blendhandle_from_file() */ | |||||
| return; | |||||
| } | |||||
| /* here appending/linking starts */ | |||||
| mainl = BLO_library_append_begin(bmain, &bh, libname); | |||||
| lib = mainl->curlib; | |||||
| BLI_assert(lib); | |||||
| if (mainl->versionfile < 250) { | |||||
| BKE_reportf(op->reports, RPT_WARNING, | |||||
| "Linking or appending from a very old .blend file format (%d.%d), no animation conversion will " | |||||
| "be done! You may want to re-save your lib file with current Blender", | |||||
| mainl->versionfile, mainl->subversionfile); | |||||
| } | |||||
| if (name) { | |||||
| BLO_library_append_named_part_ex(C, mainl, &bh, name, idcode, flag); | |||||
| } | |||||
| else { | |||||
| if (is_first_run) { | |||||
| *todo_libraries = BLI_gset_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, __func__); | |||||
| } | |||||
| RNA_BEGIN (op->ptr, itemptr, "files") | |||||
| { | |||||
| char curr_libname[FILE_MAX]; | |||||
| int curr_idcode; | |||||
| RNA_string_get(&itemptr, "name", relname); | |||||
| BLI_join_dirfile(path, sizeof(path), root, relname); | |||||
| if (BLO_library_path_explode(path, curr_libname, &group, &name)) { | |||||
| if (!group || !name) { | |||||
| continue; | |||||
| } | |||||
| curr_idcode = BKE_idcode_from_name(group); | |||||
| if ((idcode == curr_idcode) && (BLI_path_cmp(curr_libname, libname) == 0)) { | |||||
| BLO_library_append_named_part_ex(C, mainl, &bh, name, idcode, flag); | |||||
| } | |||||
| else if (is_first_run) { | |||||
| BLI_join_dirfile(path, sizeof(path), curr_libname, group); | |||||
| if (!BLI_gset_haskey(*todo_libraries, path)) { | |||||
| BLI_gset_insert(*todo_libraries, BLI_strdup(path)); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| RNA_END; | |||||
| } | |||||
| BLO_library_append_end(C, mainl, &bh, idcode, flag); | |||||
| BLO_blendhandle_close(bh); | |||||
| /* mark all library linked objects to be updated */ | |||||
| BKE_main_lib_objects_recalc_all(bmain); | |||||
| IMB_colormanagement_check_file_config(bmain); | |||||
| /* append, rather than linking */ | |||||
| if ((flag & FILE_LINK) == 0) { | |||||
| BLI_assert(BLI_findindex(&bmain->library, lib) != -1); | |||||
| BKE_library_make_local(bmain, lib, true); | |||||
| } | |||||
| } | |||||
| static int wm_link_append_exec(bContext *C, wmOperator *op) | |||||
| { | |||||
| Main *bmain = CTX_data_main(C); | |||||
| Scene *scene = CTX_data_scene(C); | |||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| char name[FILE_MAX], dir[FILE_MAX], libname[FILE_MAX], group[BLO_GROUP_MAX]; | char path[FILE_MAX_LIBEXTRA], root[FILE_MAXDIR], libname[FILE_MAX], relname[FILE_MAX], *group, *name; | ||||
| int idcode, totfiles = 0; | int totfiles = 0; | ||||
| short flag; | short flag; | ||||
| RNA_string_get(op->ptr, "filename", name); | GSet *todo_libraries = NULL; | ||||
| RNA_string_get(op->ptr, "directory", dir); | |||||
| RNA_string_get(op->ptr, "filename", relname); | |||||
| RNA_string_get(op->ptr, "directory", root); | |||||
| BLI_join_dirfile(path, sizeof(path), root, relname); | |||||
| /* test if we have a valid data */ | /* test if we have a valid data */ | ||||
| if (BLO_is_a_library(dir, libname, group) == 0) { | if (!BLO_library_path_explode(path, libname, &group, &name)) { | ||||
| BKE_report(op->reports, RPT_ERROR, "Not a library"); | BKE_report(op->reports, RPT_ERROR, "Not a library"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| else if (group[0] == 0) { | else if (!group) { | ||||
| BKE_report(op->reports, RPT_ERROR, "Nothing indicated"); | BKE_report(op->reports, RPT_ERROR, "Nothing indicated"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| else if (BLI_path_cmp(bmain->name, libname) == 0) { | else if (BLI_path_cmp(bmain->name, libname) == 0) { | ||||
| BKE_report(op->reports, RPT_ERROR, "Cannot use current file as library"); | BKE_report(op->reports, RPT_ERROR, "Cannot use current file as library"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| /* check if something is indicated for append/link */ | /* check if something is indicated for append/link */ | ||||
| prop = RNA_struct_find_property(op->ptr, "files"); | prop = RNA_struct_find_property(op->ptr, "files"); | ||||
| if (prop) { | if (prop) { | ||||
| totfiles = RNA_property_collection_length(op->ptr, prop); | totfiles = RNA_property_collection_length(op->ptr, prop); | ||||
| if (totfiles == 0) { | if (totfiles == 0) { | ||||
| if (name[0] == '\0') { | if (!name) { | ||||
| BKE_report(op->reports, RPT_ERROR, "Nothing indicated"); | BKE_report(op->reports, RPT_ERROR, "Nothing indicated"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else if (name[0] == '\0') { | else if (!name) { | ||||
| BKE_report(op->reports, RPT_ERROR, "Nothing indicated"); | BKE_report(op->reports, RPT_ERROR, "Nothing indicated"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| bh = BLO_blendhandle_from_file(libname, op->reports); | |||||
| if (bh == NULL) { | |||||
| /* unlikely since we just browsed it, but possible | |||||
| * error reports will have been made by BLO_blendhandle_from_file() */ | |||||
| return OPERATOR_CANCELLED; | |||||
| } | |||||
| /* from here down, no error returns */ | |||||
| idcode = BKE_idcode_from_name(group); | |||||
| /* now we have or selected, or an indicated file */ | |||||
| if (RNA_boolean_get(op->ptr, "autoselect")) | |||||
| BKE_scene_base_deselect_all(scene); | |||||
| flag = wm_link_append_flag(op); | flag = wm_link_append_flag(op); | ||||
| /* sanity checks for flag */ | /* sanity checks for flag */ | ||||
| if (scene->id.lib && (flag & FILE_GROUP_INSTANCE)) { | if (scene->id.lib && (flag & FILE_GROUP_INSTANCE)) { | ||||
| /* TODO, user never gets this message */ | /* TODO, user never gets this message */ | ||||
| BKE_reportf(op->reports, RPT_WARNING, "Scene '%s' is linked, group instance disabled", scene->id.name + 2); | BKE_reportf(op->reports, RPT_WARNING, "Scene '%s' is linked, group instance disabled", scene->id.name + 2); | ||||
| flag &= ~FILE_GROUP_INSTANCE; | flag &= ~FILE_GROUP_INSTANCE; | ||||
| } | } | ||||
| /* from here down, no error returns */ | |||||
| /* now we have or selected, or an indicated file */ | |||||
| if (RNA_boolean_get(op->ptr, "autoselect")) | |||||
| BKE_scene_base_deselect_all(scene); | |||||
| /* tag everything, all untagged data can be made local | /* tag everything, all untagged data can be made local | ||||
| * its also generally useful to know what is new | * its also generally useful to know what is new | ||||
| * | * | ||||
| * take extra care BKE_main_id_flag_all(LIB_LINK_TAG, false) is called after! */ | * take extra care BKE_main_id_flag_all(LIB_LINK_TAG, false) is called after! */ | ||||
| BKE_main_id_flag_all(bmain, LIB_PRE_EXISTING, 1); | BKE_main_id_flag_all(bmain, LIB_PRE_EXISTING, 1); | ||||
| /* here appending/linking starts */ | if (totfiles != 0) { | ||||
| mainl = BLO_library_append_begin(bmain, &bh, libname); | name = NULL; | ||||
| lib = mainl->curlib; | |||||
| BLI_assert(lib); | |||||
| if (mainl->versionfile < 250) { | |||||
| BKE_reportf(op->reports, RPT_WARNING, | |||||
| "Linking or appending from a very old .blend file format (%d.%d), no animation conversion will " | |||||
| "be done! You may want to re-save your lib file with current Blender", | |||||
| mainl->versionfile, mainl->subversionfile); | |||||
| } | } | ||||
| if (totfiles == 0) { | wm_link_append_do_libgroup(C, op, root, libname, group, name, flag, &todo_libraries); | ||||
| BLO_library_append_named_part_ex(C, mainl, &bh, name, idcode, flag); | |||||
| } | |||||
| else { | |||||
| RNA_BEGIN (op->ptr, itemptr, "files") | |||||
| { | |||||
| RNA_string_get(&itemptr, "name", name); | |||||
| BLO_library_append_named_part_ex(C, mainl, &bh, name, idcode, flag); | |||||
| } | |||||
| RNA_END; | |||||
| } | |||||
| BLO_library_append_end(C, mainl, &bh, idcode, flag); | |||||
| /* mark all library linked objects to be updated */ | if (todo_libraries) { | ||||
| BKE_main_lib_objects_recalc_all(bmain); | GSetIterator libs_it; | ||||
| IMB_colormanagement_check_file_config(bmain); | |||||
| /* append, rather than linking */ | GSET_ITER(libs_it, todo_libraries) { | ||||
| if ((flag & FILE_LINK) == 0) { | char *libpath = (char *)BLI_gsetIterator_getKey(&libs_it); | ||||
| BLI_assert(BLI_findindex(&bmain->library, lib) != -1); | |||||
| BKE_library_make_local(bmain, lib, true); | BLO_library_path_explode(libpath, libname, &group, NULL); | ||||
| wm_link_append_do_libgroup(C, op, root, libname, group, NULL, flag, &todo_libraries); | |||||
| } | |||||
| BLI_gset_free(todo_libraries, MEM_freeN); | |||||
| } | } | ||||
| /* important we unset, otherwise these object wont | /* important we unset, otherwise these object wont | ||||
| * link into other scenes from this blend file */ | * link into other scenes from this blend file */ | ||||
| BKE_main_id_flag_all(bmain, LIB_PRE_EXISTING, false); | BKE_main_id_flag_all(bmain, LIB_PRE_EXISTING, false); | ||||
| /* recreate dependency graph to include new objects */ | /* recreate dependency graph to include new objects */ | ||||
| DAG_scene_relations_rebuild(bmain, scene); | DAG_scene_relations_rebuild(bmain, scene); | ||||
| /* free gpu materials, some materials depend on existing objects, such as lamps so freeing correctly refreshes */ | /* free gpu materials, some materials depend on existing objects, such as lamps so freeing correctly refreshes */ | ||||
| GPU_materials_free(); | GPU_materials_free(); | ||||
| BLO_blendhandle_close(bh); | |||||
| /* XXX TODO: align G.lib with other directory storage (like last opened image etc...) */ | /* XXX TODO: align G.lib with other directory storage (like last opened image etc...) */ | ||||
| BLI_strncpy(G.lib, dir, FILE_MAX); | BLI_strncpy(G.lib, root, FILE_MAX); | ||||
| WM_event_add_notifier(C, NC_WINDOW, NULL); | WM_event_add_notifier(C, NC_WINDOW, NULL); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static void wm_link_append_properties_common(wmOperatorType *ot, bool is_link) | static void wm_link_append_properties_common(wmOperatorType *ot, bool is_link) | ||||
| { | { | ||||
| Show All 23 Lines | static void WM_OT_link(wmOperatorType *ot) | ||||
| ot->invoke = wm_link_append_invoke; | ot->invoke = wm_link_append_invoke; | ||||
| ot->exec = wm_link_append_exec; | ot->exec = wm_link_append_exec; | ||||
| ot->poll = wm_link_append_poll; | ot->poll = wm_link_append_poll; | ||||
| ot->flag |= OPTYPE_UNDO; | ot->flag |= OPTYPE_UNDO; | ||||
| WM_operator_properties_filesel( | WM_operator_properties_filesel( | ||||
| ot, FILE_TYPE_FOLDER | FILE_TYPE_BLENDER, FILE_LOADLIB, FILE_OPENFILE, | ot, FILE_TYPE_FOLDER | FILE_TYPE_BLENDER | FILE_TYPE_BLENDERLIB, FILE_LOADLIB, FILE_OPENFILE, | ||||
| WM_FILESEL_FILEPATH | WM_FILESEL_DIRECTORY | WM_FILESEL_FILENAME | WM_FILESEL_RELPATH | WM_FILESEL_FILES, | WM_FILESEL_FILEPATH | WM_FILESEL_DIRECTORY | WM_FILESEL_FILENAME | WM_FILESEL_RELPATH | WM_FILESEL_FILES, | ||||
| FILE_DEFAULTDISPLAY); | FILE_DEFAULTDISPLAY); | ||||
| wm_link_append_properties_common(ot, true); | wm_link_append_properties_common(ot, true); | ||||
| } | } | ||||
| static void WM_OT_append(wmOperatorType *ot) | static void WM_OT_append(wmOperatorType *ot) | ||||
| { | { | ||||
| ot->name = "Append from Library"; | ot->name = "Append from Library"; | ||||
| ot->idname = "WM_OT_append"; | ot->idname = "WM_OT_append"; | ||||
| ot->description = "Append from a Library .blend file"; | ot->description = "Append from a Library .blend file"; | ||||
| ot->invoke = wm_link_append_invoke; | ot->invoke = wm_link_append_invoke; | ||||
| ot->exec = wm_link_append_exec; | ot->exec = wm_link_append_exec; | ||||
| ot->poll = wm_link_append_poll; | ot->poll = wm_link_append_poll; | ||||
| ot->flag |= OPTYPE_UNDO; | ot->flag |= OPTYPE_UNDO; | ||||
| WM_operator_properties_filesel( | WM_operator_properties_filesel( | ||||
| ot, FILE_TYPE_FOLDER | FILE_TYPE_BLENDER, FILE_LOADLIB, FILE_OPENFILE, | ot, FILE_TYPE_FOLDER | FILE_TYPE_BLENDER | FILE_TYPE_BLENDERLIB, FILE_LOADLIB, FILE_OPENFILE, | ||||
| WM_FILESEL_FILEPATH | WM_FILESEL_DIRECTORY | WM_FILESEL_FILENAME | WM_FILESEL_FILES, | WM_FILESEL_FILEPATH | WM_FILESEL_DIRECTORY | WM_FILESEL_FILENAME | WM_FILESEL_FILES, | ||||
| FILE_DEFAULTDISPLAY); | FILE_DEFAULTDISPLAY); | ||||
| wm_link_append_properties_common(ot, false); | wm_link_append_properties_common(ot, false); | ||||
| } | } | ||||
| /* *************** recover last session **************** */ | /* *************** recover last session **************** */ | ||||
| ▲ Show 20 Lines • Show All 2,085 Lines • ▼ Show 20 Lines | static void WM_OT_previews_ensure(wmOperatorType *ot) | ||||
| ot->name = "Refresh DataBlock Previews"; | ot->name = "Refresh DataBlock Previews"; | ||||
| ot->idname = "WM_OT_previews_ensure"; | ot->idname = "WM_OT_previews_ensure"; | ||||
| ot->description = "Ensure datablock previews are available and up-to-date " | ot->description = "Ensure datablock previews are available and up-to-date " | ||||
| "(to be saved in .blend file, only for some types like materials, textures, etc.)"; | "(to be saved in .blend file, only for some types like materials, textures, etc.)"; | ||||
| ot->exec = previews_ensure_exec; | ot->exec = previews_ensure_exec; | ||||
| } | } | ||||
| /* *************************** Datablocks previews clear ************* */ | |||||
| /* Only types supporting previews currently. */ | |||||
| static EnumPropertyItem preview_id_type_items[] = { | |||||
| {FILTER_ID_SCE, "SCENE", 0, "Scenes", ""}, | |||||
| {FILTER_ID_GR, "GROUP", 0, "Groups", ""}, | |||||
| {FILTER_ID_OB, "OBJECT", 0, "Objects", ""}, | |||||
| {FILTER_ID_MA, "MATERIAL", 0, "Materials", ""}, | |||||
| {FILTER_ID_LA, "LAMP", 0, "Lamps", ""}, | |||||
| {FILTER_ID_WO, "WORLD", 0, "Worlds", ""}, | |||||
| {FILTER_ID_TE, "TEXTURE", 0, "Textures", ""}, | |||||
| {FILTER_ID_IM, "IMAGE", 0, "Images", ""}, | |||||
| #if 0 /* XXX TODO */ | |||||
| {FILTER_ID_BR, "BRUSH", 0, "Brushes", ""}, | |||||
| #endif | |||||
| {0, NULL, 0, NULL, NULL} | |||||
| }; | |||||
| static int previews_clear_exec(bContext *C, wmOperator *op) | |||||
| { | |||||
| Main *bmain = CTX_data_main(C); | |||||
| ListBase *lb[] = {&bmain->object, &bmain->group, | |||||
| &bmain->mat, &bmain->world, &bmain->lamp, &bmain->tex, &bmain->image, NULL}; | |||||
| int i; | |||||
| const int id_filters = RNA_enum_get(op->ptr, "id_type"); | |||||
| for (i = 0; lb[i]; i++) { | |||||
| ID *id = lb[i]->first; | |||||
| if (!id) continue; | |||||
| // printf("%s: %d, %d, %d -> %d\n", id->name, GS(id->name), BKE_idcode_to_idfilter(GS(id->name)), | |||||
| // id_filters, BKE_idcode_to_idfilter(GS(id->name)) & id_filters); | |||||
| if (!id || !(BKE_idcode_to_idfilter(GS(id->name)) & id_filters)) { | |||||
| continue; | |||||
| } | |||||
| for (; id; id = id->next) { | |||||
| PreviewImage *prv_img = BKE_previewimg_id_ensure(id); | |||||
| BKE_previewimg_clear(prv_img); | |||||
| } | |||||
| } | |||||
| return OPERATOR_FINISHED; | |||||
| } | |||||
| static void WM_OT_previews_clear(wmOperatorType *ot) | |||||
| { | |||||
| ot->name = "Clear DataBlock Previews"; | |||||
| ot->idname = "WM_OT_previews_clear"; | |||||
| ot->description = "Clear datablock previews (only for some types like objects, materials, textures, etc.)"; | |||||
| ot->exec = previews_clear_exec; | |||||
| ot->invoke = WM_menu_invoke; | |||||
| ot->prop = RNA_def_enum_flag(ot->srna, "id_type", preview_id_type_items, | |||||
| FILTER_ID_SCE | FILTER_ID_OB | FILTER_ID_GR | | |||||
| FILTER_ID_MA | FILTER_ID_LA | FILTER_ID_WO | FILTER_ID_TE | FILTER_ID_IM, | |||||
| "DataBlock Type", "Which datablock previews to clear"); | |||||
| } | |||||
| /* *************************** Doc from UI ************* */ | |||||
| static int doc_view_manual_ui_context_exec(bContext *C, wmOperator *UNUSED(op)) | static int doc_view_manual_ui_context_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| PointerRNA ptr_props; | PointerRNA ptr_props; | ||||
| char buf[512]; | char buf[512]; | ||||
| short retval = OPERATOR_CANCELLED; | short retval = OPERATOR_CANCELLED; | ||||
| if (UI_but_online_manual_id_from_active(C, buf, sizeof(buf))) { | if (UI_but_online_manual_id_from_active(C, buf, sizeof(buf))) { | ||||
| WM_operator_properties_create(&ptr_props, "WM_OT_doc_view_manual"); | WM_operator_properties_create(&ptr_props, "WM_OT_doc_view_manual"); | ||||
| ▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | void wm_operatortype_init(void) | ||||
| WM_operatortype_append(WM_OT_call_menu); | WM_operatortype_append(WM_OT_call_menu); | ||||
| WM_operatortype_append(WM_OT_call_menu_pie); | WM_operatortype_append(WM_OT_call_menu_pie); | ||||
| WM_operatortype_append(WM_OT_radial_control); | WM_operatortype_append(WM_OT_radial_control); | ||||
| WM_operatortype_append(WM_OT_stereo3d_set); | WM_operatortype_append(WM_OT_stereo3d_set); | ||||
| #if defined(WIN32) | #if defined(WIN32) | ||||
| WM_operatortype_append(WM_OT_console_toggle); | WM_operatortype_append(WM_OT_console_toggle); | ||||
| #endif | #endif | ||||
| WM_operatortype_append(WM_OT_previews_ensure); | WM_operatortype_append(WM_OT_previews_ensure); | ||||
| WM_operatortype_append(WM_OT_previews_clear); | |||||
| WM_operatortype_append(WM_OT_doc_view_manual_ui_context); | WM_operatortype_append(WM_OT_doc_view_manual_ui_context); | ||||
| } | } | ||||
| /* circleselect-like modal operators */ | /* circleselect-like modal operators */ | ||||
| static void gesture_circle_modal_keymap(wmKeyConfig *keyconf) | static void gesture_circle_modal_keymap(wmKeyConfig *keyconf) | ||||
| { | { | ||||
| static EnumPropertyItem modal_items[] = { | static EnumPropertyItem modal_items[] = { | ||||
| {GESTURE_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, | {GESTURE_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, | ||||
| ▲ Show 20 Lines • Show All 379 Lines • Show Last 20 Lines | |||||