Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2020-12-23 16:25:58 +0300
committerJulian Eisel <julian@blender.org>2020-12-23 16:34:24 +0300
commit27fcaa61733827dbb81b69fdeec0db2f656c6f03 (patch)
tree26e279f330c22e7362bf6b685a2af7cc1c809aea /source/blender/editors/util/ed_util.c
parent78d2ce19c4fbb5678995efae74a6128a3dcc4e73 (diff)
Cleanup: Move functions to new ED (editor) operators file & general cleanup
With the new `ed_util_ops.c` introduced in 2250b5cefee7, existing code can be cleaned up to use it. * Move new ID preview operators to `ed_util_ops.c` * Move ED operator registration to `ed_util_ops.c` * Use doxygen sections in `ed_util_ops.c` * Rename ID related ED operators to use `ED_OT_lib_id_` prefix. * Remove unused `#include`s
Diffstat (limited to 'source/blender/editors/util/ed_util.c')
-rw-r--r--source/blender/editors/util/ed_util.c117
1 files changed, 0 insertions, 117 deletions
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index 5d2584c566d..4b1335cf047 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -29,50 +29,34 @@
#include "DNA_armature_types.h"
#include "DNA_mesh_types.h"
-#include "DNA_object_types.h"
-#include "DNA_packedFile_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_screen_types.h"
-#include "DNA_space_types.h"
-#include "BLI_fileops.h"
#include "BLI_listbase.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
-#include "BLI_utildefines.h"
#include "BLT_translation.h"
-#include "BKE_context.h"
#include "BKE_global.h"
-#include "BKE_icons.h"
-#include "BKE_layer.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_multires.h"
#include "BKE_object.h"
#include "BKE_packedFile.h"
#include "BKE_paint.h"
-#include "BKE_report.h"
#include "BKE_screen.h"
#include "BKE_undo_system.h"
-#include "BKE_workspace.h"
#include "DEG_depsgraph.h"
#include "ED_armature.h"
#include "ED_image.h"
#include "ED_mesh.h"
-#include "ED_node.h"
#include "ED_object.h"
-#include "ED_outliner.h"
#include "ED_paint.h"
-#include "ED_render.h"
#include "ED_space_api.h"
#include "ED_util.h"
#include "GPU_immediate.h"
-#include "GPU_state.h"
#include "UI_interface.h"
#include "UI_resources.h"
@@ -484,104 +468,3 @@ void ED_spacedata_id_remap(struct ScrArea *area, struct SpaceLink *sl, ID *old_i
st->id_remap(area, sl, old_id, new_id);
}
}
-
-static bool lib_id_preview_editing_poll(bContext *C)
-{
- const PointerRNA idptr = CTX_data_pointer_get(C, "id");
- BLI_assert(!idptr.data || RNA_struct_is_ID(idptr.type));
-
- const ID *id = idptr.data;
- if (!id) {
- return false;
- }
- if (ID_IS_LINKED(id)) {
- CTX_wm_operator_poll_msg_set(C, TIP_("Can't edit external library data"));
- return false;
- }
- if (ID_IS_OVERRIDE_LIBRARY(id)) {
- CTX_wm_operator_poll_msg_set(C, TIP_("Can't edit previews of overridden library data"));
- return false;
- }
- if (!BKE_previewimg_id_get_p(id)) {
- CTX_wm_operator_poll_msg_set(C, TIP_("Data-block does not support previews"));
- return false;
- }
-
- return true;
-}
-
-static int lib_id_load_custom_preview_exec(bContext *C, wmOperator *op)
-{
- char path[FILE_MAX];
-
- RNA_string_get(op->ptr, "filepath", path);
-
- if (!BLI_is_file(path)) {
- BKE_reportf(op->reports, RPT_ERROR, "File not found '%s'", path);
- return OPERATOR_CANCELLED;
- }
-
- PointerRNA idptr = CTX_data_pointer_get(C, "id");
- ID *id = idptr.data;
-
- BKE_previewimg_id_custom_set(id, path);
-
- WM_event_add_notifier(C, NC_ASSET, NULL);
-
- return OPERATOR_FINISHED;
-}
-
-void ED_OT_lib_id_load_custom_preview(wmOperatorType *ot)
-{
- ot->name = "Load Custom Preview";
- ot->description = "Choose an image to help identify the data-block visually";
- ot->idname = "ED_OT_lib_id_load_custom_preview";
-
- /* api callbacks */
- ot->poll = lib_id_preview_editing_poll;
- ot->exec = lib_id_load_custom_preview_exec;
- ot->invoke = WM_operator_filesel;
-
- /* flags */
- ot->flag = OPTYPE_INTERNAL;
-
- WM_operator_properties_filesel(ot,
- FILE_TYPE_FOLDER | FILE_TYPE_IMAGE,
- FILE_SPECIAL,
- FILE_OPENFILE,
- WM_FILESEL_FILEPATH,
- FILE_DEFAULTDISPLAY,
- FILE_SORT_DEFAULT);
-}
-
-static int lib_id_generate_preview_exec(bContext *C, wmOperator *UNUSED(op))
-{
- PointerRNA idptr = CTX_data_pointer_get(C, "id");
- ID *id = idptr.data;
-
- ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
-
- PreviewImage *preview = BKE_previewimg_id_get(id);
- if (preview) {
- BKE_previewimg_clear(preview);
- }
- UI_icon_render_id(C, NULL, id, true, true);
-
- WM_event_add_notifier(C, NC_ASSET, NULL);
-
- return OPERATOR_FINISHED;
-}
-
-void ED_OT_lib_id_generate_preview(wmOperatorType *ot)
-{
- ot->name = "Generate Preview";
- ot->description = "Create an automatic preview for the selected data-block";
- ot->idname = "ED_OT_lib_id_generate_preview";
-
- /* api callbacks */
- ot->poll = lib_id_preview_editing_poll;
- ot->exec = lib_id_generate_preview_exec;
-
- /* flags */
- ot->flag = OPTYPE_INTERNAL;
-}