diff options
author | Jacques Lucke <mail@jlucke.com> | 2018-10-16 12:17:32 +0300 |
---|---|---|
committer | Jacques Lucke <mail@jlucke.com> | 2018-10-16 12:18:16 +0300 |
commit | 09cd651bb7e59044cbcd0664e8b1064cb37734ed (patch) | |
tree | 7a4b97c1bf7ab0463681ccbe0fe981608e9f8b52 /source/blender | |
parent | f807371c3e2d344375f10c3d3e330128598f5314 (diff) |
View 3D: fix image dropping in 3d view
Reviewers: brecht
Differential Revision: https://developer.blender.org/D3798
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 1 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/space_view3d.c | 32 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 5 |
3 files changed, 23 insertions, 15 deletions
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 88e914288d5..0b87a5e57f0 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -470,6 +470,7 @@ struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple( struct Base *ED_view3d_give_base_under_cursor(struct bContext *C, const int mval[2]); struct Object *ED_view3d_give_object_under_cursor(struct bContext *C, const int mval[2]); +bool ED_view3d_there_is_an_object_under_cursor(struct bContext *C, const int mval[2]); void ED_view3d_quadview_update(struct ScrArea *sa, struct ARegion *ar, bool do_clip); void ED_view3d_update_viewmat( struct Depsgraph *depsgraph, struct Scene *scene, struct View3D *v3d, struct ARegion *ar, diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index f1394933c26..9c6a876714a 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -597,32 +597,34 @@ static bool view3d_ima_bg_is_camera_view(bContext *C) static bool view3d_ima_bg_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event, const char **tooltip) { - if (view3d_ima_bg_is_camera_view(C)) { - return true; + if (!view3d_ima_drop_poll(C, drag, event, tooltip)) { + return false; } - if (!ED_view3d_give_base_under_cursor(C, event->mval)) { - return view3d_ima_drop_poll(C, drag, event, tooltip); + if (ED_view3d_there_is_an_object_under_cursor(C, event->mval)) { + return false; } - return 0; + + return view3d_ima_bg_is_camera_view(C); } static bool view3d_ima_empty_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event, const char **tooltip) { - if (!view3d_ima_bg_is_camera_view(C)) { - return true; + if (!view3d_ima_drop_poll(C, drag, event, tooltip)) { + return false; } - Base *base = ED_view3d_give_base_under_cursor(C, event->mval); + Object *ob = ED_view3d_give_object_under_cursor(C, event->mval); - /* either holding and ctrl and no object, or dropping to empty */ - if ((base == NULL) || - ((base != NULL) && base->object->type == OB_EMPTY)) - { - return view3d_ima_drop_poll(C, drag, event, tooltip); + if (ob == NULL) { + return true; } - return 0; + if (ob->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE) { + return true; + } + + return false; } static void view3d_ob_drop_copy(wmDrag *drag, wmDropBox *drop) @@ -688,8 +690,8 @@ static void view3d_dropboxes(void) WM_dropbox_add(lb, "OBJECT_OT_add_named", view3d_ob_drop_poll, view3d_ob_drop_copy); WM_dropbox_add(lb, "OBJECT_OT_drop_named_material", view3d_mat_drop_poll, view3d_id_drop_copy); - WM_dropbox_add(lb, "OBJECT_OT_drop_named_image", view3d_ima_empty_drop_poll, view3d_id_path_drop_copy); WM_dropbox_add(lb, "VIEW3D_OT_background_image_add", view3d_ima_bg_drop_poll, view3d_id_path_drop_copy); + WM_dropbox_add(lb, "OBJECT_OT_drop_named_image", view3d_ima_empty_drop_poll, view3d_id_path_drop_copy); WM_dropbox_add(lb, "OBJECT_OT_collection_instance_add", view3d_collection_drop_poll, view3d_collection_drop_copy); } diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 47266c2584e..b177f25375e 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1535,6 +1535,11 @@ Object *ED_view3d_give_object_under_cursor(bContext *C, const int mval[2]) return NULL; } +bool ED_view3d_there_is_an_object_under_cursor(bContext *C, const int mval[2]) +{ + return ED_view3d_give_object_under_cursor(C, mval) != NULL; +} + static void deselect_all_tracks(MovieTracking *tracking) { MovieTrackingObject *object; |