Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / space_image / image_ops.c
index 956043afea34cd4b770650221ef98db4b68c6b6e..6c0ab33dd2c01274073f091c12a426811f1357ce 100644 (file)
@@ -48,6 +48,7 @@
 
 #include "BLT_translation.h"
 
+#include "DNA_camera_types.h"
 #include "DNA_object_types.h"
 #include "DNA_node_types.h"
 #include "DNA_packedFile_types.h"
@@ -56,7 +57,6 @@
 
 #include "BKE_colortools.h"
 #include "BKE_context.h"
-#include "BKE_depsgraph.h"
 #include "BKE_DerivedMesh.h"
 #include "BKE_icons.h"
 #include "BKE_image.h"
@@ -70,6 +70,8 @@
 #include "BKE_sound.h"
 #include "BKE_scene.h"
 
+#include "DEG_depsgraph.h"
+
 #include "GPU_draw.h"
 #include "GPU_buffers.h"
 
@@ -792,6 +794,7 @@ static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
        SpaceImage *sima;
        ARegion *ar;
        Scene *scene;
+       ViewLayer *view_layer;
        Object *obedit;
        Image *ima;
 
@@ -799,6 +802,7 @@ static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
        sima = CTX_wm_space_image(C);
        ar = CTX_wm_region(C);
        scene = CTX_data_scene(C);
+       view_layer = CTX_data_view_layer(C);
        obedit = CTX_data_edit_object(C);
 
        ima = ED_space_image(sima);
@@ -810,7 +814,7 @@ static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
                        return OPERATOR_CANCELLED;
                }
        }
-       else if (ED_space_image_check_show_maskedit(scene, sima)) {
+       else if (ED_space_image_check_show_maskedit(view_layer, sima)) {
                if (!ED_mask_selected_minmax(C, min, max)) {
                        return OPERATOR_CANCELLED;
                }
@@ -1307,21 +1311,23 @@ static int image_open_exec(bContext *C, wmOperator *op)
                ED_space_image_set(sima, scene, obedit, ima);
                iuser = &sima->iuser;
        }
-       else if (sa && sa->spacetype == SPACE_VIEW3D) {
-               View3D *v3d = sa->spacedata.first;
-
-               for (BGpic *bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) {
-                       if (bgpic->ima == ima) {
-                               iuser = &bgpic->iuser;
-                               break;
-                       }
-               }
-       }
        else {
                Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
                if (tex && tex->type == TEX_IMAGE) {
                        iuser = &tex->iuser;
                }
+
+               if (iuser == NULL) {
+                       Camera *cam = CTX_data_pointer_get_type(C, "camera", &RNA_Camera).data;
+                       if (cam) {
+                               for (CameraBGImage *bgpic = cam->bg_images.first; bgpic; bgpic = bgpic->next) {
+                                       if (bgpic->ima == ima) {
+                                               iuser = &bgpic->iuser;
+                                               break;
+                                       }
+                               }
+                       }
+               }
        }
 
        /* initialize because of new image */
@@ -2341,7 +2347,7 @@ static int image_reload_exec(bContext *C, wmOperator *UNUSED(op))
        
        // XXX other users?
        BKE_image_signal(ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_RELOAD);
-       DAG_id_tag_update(&ima->id, 0);
+       DEG_id_tag_update(&ima->id, 0);
 
        WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
        
@@ -3594,7 +3600,7 @@ void IMAGE_OT_change_frame(wmOperatorType *ot)
 
 /* Reload cached render results... */
 /* goes over all scenes, reads render layers */
-static int image_read_renderlayers_exec(bContext *C, wmOperator *UNUSED(op))
+static int image_read_viewlayers_exec(bContext *C, wmOperator *UNUSED(op))
 {
        Scene *scene = CTX_data_scene(C);
        SpaceImage *sima = CTX_wm_space_image(C);
@@ -3611,14 +3617,14 @@ static int image_read_renderlayers_exec(bContext *C, wmOperator *UNUSED(op))
        return OPERATOR_FINISHED;
 }
 
-void IMAGE_OT_read_renderlayers(wmOperatorType *ot)
+void IMAGE_OT_read_viewlayers(wmOperatorType *ot)
 {
-       ot->name = "Read Render Layers";
-       ot->idname = "IMAGE_OT_read_renderlayers";
-       ot->description = "Read all the current scene's render layers from cache, as needed";
+       ot->name = "Read View Layers";
+       ot->idname = "IMAGE_OT_read_viewlayers";
+       ot->description = "Read all the current scene's view layers from cache, as needed";
 
        ot->poll = space_image_main_region_poll;
-       ot->exec = image_read_renderlayers_exec;
+       ot->exec = image_read_viewlayers_exec;
 
        /* flags */
        ot->flag = 0;