diff options
Diffstat (limited to 'source/blender/editors/space_image/image_ops.c')
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 64 |
1 files changed, 42 insertions, 22 deletions
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index df556f94f28..61667b02140 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -92,6 +92,8 @@ #include "PIL_time.h" +#include "RE_engine.h" + #include "image_intern.h" /******************** view navigation utilities *********************/ @@ -583,7 +585,7 @@ void IMAGE_OT_view_zoom(wmOperatorType *ot) ot->poll = space_image_main_area_poll; /* flags */ - ot->flag = OPTYPE_BLOCKING | OPTYPE_LOCK_BYPASS; + ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER | OPTYPE_LOCK_BYPASS; /* properties */ prop = RNA_def_float(ot->srna, "factor", 0.0f, -FLT_MAX, FLT_MAX, "Factor", @@ -947,7 +949,7 @@ static void image_open_init(bContext *C, wmOperator *op) op->customdata = iod = MEM_callocN(sizeof(ImageOpenData), __func__); iod->iuser = CTX_data_pointer_get_type(C, "image_user", &RNA_ImageUser).data; - uiIDContextProperty(C, &iod->pprop.ptr, &iod->pprop.prop); + UI_context_active_but_prop_get_templateID(C, &iod->pprop.ptr, &iod->pprop.prop); } static void image_open_cancel(bContext *UNUSED(C), wmOperator *op) @@ -1024,7 +1026,7 @@ static int image_sequence_get_len(ListBase *frames, int *ofs) { ImageFrame *frame; - BLI_sortlist(frames, image_cmp_frame); + BLI_listbase_sort(frames, image_cmp_frame); frame = frames->first; if (frame) { @@ -1052,6 +1054,7 @@ static int image_open_exec(bContext *C, wmOperator *op) char path[FILE_MAX]; int frame_seq_len = 0; int frame_ofs = 1; + bool exists = false; const bool is_relative_path = RNA_boolean_get(op->ptr, "relative_path"); @@ -1070,7 +1073,7 @@ static int image_open_exec(bContext *C, wmOperator *op) errno = 0; - ima = BKE_image_load_exists(path); + ima = BKE_image_load_exists_ex(path, &exists); if (!ima) { if (op->customdata) MEM_freeN(op->customdata); @@ -1084,8 +1087,9 @@ static int image_open_exec(bContext *C, wmOperator *op) /* only image path after save, never ibuf */ if (is_relative_path) { - const char *relbase = ID_BLEND_PATH(bmain, &ima->id); - BLI_path_rel(ima->name, relbase); + if (!exists) { + BLI_path_rel(ima->name, bmain->name); + } } /* hook into UI */ @@ -1127,7 +1131,7 @@ static int image_open_exec(bContext *C, wmOperator *op) } /* XXX unpackImage frees image buffers */ - ED_preview_kill_jobs(C); + ED_preview_kill_jobs(CTX_wm_manager(C), bmain); BKE_image_signal(ima, iuser, IMA_SIGNAL_RELOAD); WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima); @@ -1158,7 +1162,7 @@ static int image_open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED( PropertyRNA *prop; /* hook into UI */ - uiIDContextProperty(C, &ptr, &prop); + UI_context_active_but_prop_get_templateID(C, &ptr, &prop); if (prop) { PointerRNA oldptr; @@ -1203,7 +1207,7 @@ void IMAGE_OT_open(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE | MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, + WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_IMAGE | FILE_TYPE_MOVIE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_DIRECTORY | WM_FILESEL_FILES | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); } @@ -1279,7 +1283,7 @@ static int image_replace_exec(bContext *C, wmOperator *op) sima->image->source = IMA_SRC_FILE; /* XXX unpackImage frees image buffers */ - ED_preview_kill_jobs(C); + ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); BKE_icon_changed(BKE_icon_getid(&sima->image->id)); BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_RELOAD); @@ -1322,7 +1326,7 @@ void IMAGE_OT_replace(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE | MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, + WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_IMAGE | FILE_TYPE_MOVIE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); } @@ -1732,7 +1736,7 @@ void IMAGE_OT_save_as(wmOperatorType *ot) RNA_def_boolean(ot->srna, "save_as_render", 0, "Save As Render", "Apply render part of display transform when saving byte image"); RNA_def_boolean(ot->srna, "copy", 0, "Copy", "Create a new image file without modifying the current image in blender"); - WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE | MOVIEFILE, FILE_SPECIAL, FILE_SAVE, + WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_IMAGE | FILE_TYPE_MOVIE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); } @@ -1880,7 +1884,7 @@ static int image_reload_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* XXX unpackImage frees image buffers */ - ED_preview_kill_jobs(C); + ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); // XXX other users? BKE_image_signal(ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_RELOAD); @@ -1958,7 +1962,7 @@ static int image_new_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* hook into UI */ - uiIDContextProperty(C, &ptr, &prop); + UI_context_active_but_prop_get_templateID(C, &ptr, &prop); if (prop) { /* when creating new ID blocks, use is already 1, but RNA @@ -2024,7 +2028,7 @@ static int image_new_exec(bContext *C, wmOperator *op) } /* XXX, Ton is not a fan of OK buttons but using this function to avoid undo/redo bug while in mesh-editmode, - campbell */ -/* XXX Note: the WM_operator_props_dialog_popup() doesn't work for uiIDContextProperty(), image is not being that way */ +/* XXX Note: the WM_operator_props_dialog_popup() doesn't work for UI_context_active_but_prop_get_templateID(), image is not being that way */ static int image_new_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { /* Better for user feedback. */ @@ -2248,15 +2252,15 @@ static int image_pack_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED( ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); if (!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) { - pup = uiPupMenuBegin(C, IFACE_("OK"), ICON_QUESTION); - layout = uiPupMenuLayout(pup); + pup = UI_popup_menu_begin(C, IFACE_("OK"), ICON_QUESTION); + layout = UI_popup_menu_layout(pup); uiItemBooleanO(layout, IFACE_("Can't pack edited image from disk, pack as internal PNG?"), ICON_NONE, op->idname, "as_png", 1); - uiPupMenuEnd(C, pup); + UI_popup_menu_end(C, pup); BKE_image_release_ibuf(ima, ibuf, NULL); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } BKE_image_release_ibuf(ima, ibuf, NULL); @@ -2309,7 +2313,7 @@ static int image_unpack_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_WARNING, "AutoPack is enabled, so image will be packed again on file save"); /* XXX unpackImage frees image buffers */ - ED_preview_kill_jobs(C); + ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); unpackImage(op->reports, ima, method); @@ -2580,8 +2584,9 @@ static int image_sample_invoke(bContext *C, wmOperator *op, const wmEvent *event ImageSampleInfo *info; if (ar->regiontype == RGN_TYPE_WINDOW) { - if (event->mval[1] <= 16) + if (event->mval[1] <= 16 && ED_space_image_show_cache(sima)) { return OPERATOR_PASS_THROUGH; + } } if (!ED_space_image_has_buffer(sima)) @@ -3015,8 +3020,10 @@ static int change_frame_invoke(bContext *C, wmOperator *op, const wmEvent *event ARegion *ar = CTX_wm_region(C); if (ar->regiontype == RGN_TYPE_WINDOW) { - if (event->mval[1] > 16) + SpaceImage *sima = CTX_wm_space_image(C); + if (event->mval[1] > 16 || !ED_space_image_show_cache(sima)) { return OPERATOR_PASS_THROUGH; + } } RNA_int_set(op->ptr, "frame", frame_from_event(C, event)); @@ -3108,8 +3115,21 @@ static int render_border_exec(bContext *C, wmOperator *op) { ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); + Render *re = RE_GetRender(scene->id.name); + RenderData *rd; rctf border; + if (re == NULL) { + /* Shouldn't happen, but better be safe close to the release. */ + return OPERATOR_CANCELLED; + } + + rd = RE_engine_get_render_data(re); + if ((rd->mode & (R_BORDER | R_CROP)) == (R_BORDER | R_CROP)) { + BKE_report(op->reports, RPT_INFO, "Can not set border from a cropped render"); + return OPERATOR_CANCELLED; + } + /* get rectangle from operator */ WM_operator_properties_border_to_rctf(op, &border); UI_view2d_region_to_view_rctf(&ar->v2d, &border, &border); |