diff options
author | William Reynish <william@reynish.com> | 2010-05-09 22:07:17 +0400 |
---|---|---|
committer | William Reynish <william@reynish.com> | 2010-05-09 22:07:17 +0400 |
commit | 95bb364bda806a3d28ae45e2fddfc87842e9234c (patch) | |
tree | 03fc0981c65ad9423748f29784a04ae4982049ff /source/blender/editors/space_view3d/space_view3d.c | |
parent | 6d8cb93f71b5fb3b0d1638378e0cd56696337cbe (diff) |
***Drag and drop fun!***
Added ability to drag images and movies directly onto objects to assign them as textures.
You can drag them from the file browser, directly from the OS or even from other apps. Here's a video to demonstrate:
http://www.youtube.com/watch?v=fGe2U8F_JvE
Ton wanted to show me how to add it, but he ended up doing almost all of the coding himself ;)
Ton/Matt: Dropping a text file in the Text Editor fails for some reason. It aught to work - probably a keymap conflict of some sorts?
Diffstat (limited to 'source/blender/editors/space_view3d/space_view3d.c')
-rw-r--r-- | source/blender/editors/space_view3d/space_view3d.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index a37ecda99ac..326409f310f 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -57,6 +57,8 @@ #include "RNA_access.h" +#include "UI_resources.h" + #include "view3d_intern.h" // own include /* ******************** manage regions ********************* */ @@ -416,6 +418,10 @@ static int view3d_ima_drop_poll(bContext *C, wmDrag *drag, wmEvent *event) if( GS(id->name)==ID_IM ) return 1; } + else if(drag->type==WM_DRAG_PATH){ + if(ELEM(drag->icon, 0, ICON_FILE_IMAGE)) /* rule might not work? */ + return 1; + } return 0; } @@ -435,10 +441,20 @@ static void view3d_ob_drop_copy(wmDrag *drag, wmDropBox *drop) static void view3d_id_drop_copy(wmDrag *drag, wmDropBox *drop) { ID *id= (ID *)drag->poin; - + RNA_string_set(drop->ptr, "name", id->name+2); } +static void view3d_id_path_drop_copy(wmDrag *drag, wmDropBox *drop) +{ + ID *id= (ID *)drag->poin; + + if(id) + RNA_string_set(drop->ptr, "name", id->name+2); + if(drag->path) + RNA_string_set(drop->ptr, "path", drag->path); +} + /* region dropbox definition */ static void view3d_dropboxes(void) @@ -447,7 +463,7 @@ static void view3d_dropboxes(void) WM_dropbox_add(lb, "OBJECT_OT_add_named_cursor", 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, "MESH_OT_drop_named_image", view3d_ima_drop_poll, view3d_id_drop_copy); + WM_dropbox_add(lb, "MESH_OT_drop_named_image", view3d_ima_drop_poll, view3d_id_path_drop_copy); } |