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_text/space_text.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_text/space_text.c')
-rw-r--r-- | source/blender/editors/space_text/space_text.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index 2e78a502461..8b46617d55e 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -368,6 +368,36 @@ static void text_cursor(wmWindow *win, ScrArea *sa, ARegion *ar) WM_cursor_set(win, BC_TEXTEDITCURSOR); } + + +/* ************* dropboxes ************* */ + +static int text_drop_poll(bContext *C, wmDrag *drag, wmEvent *event) +{ + if(drag->type==WM_DRAG_PATH) + if(ELEM(drag->icon, 0, ICON_FILE_BLANK)) /* rule might not work? */ + return 1; + return 0; +} + +static void text_drop_copy(wmDrag *drag, wmDropBox *drop) +{ + /* copy drag path to properties */ + RNA_string_set(drop->ptr, "path", drag->path); +} + +/* this region dropbox definition */ +static void text_dropboxes(void) +{ + ListBase *lb= WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW); + + WM_dropbox_add(lb, "TEXT_OT_open", text_drop_poll, text_drop_copy); + +} + +/* ************* end drop *********** */ + + /****************** header region ******************/ /* add handlers, stuff you only do once or on area/region changes */ @@ -413,6 +443,7 @@ void ED_spacetype_text(void) st->keymap= text_keymap; st->listener= text_listener; st->context= text_context; + st->dropboxes = text_dropboxes; /* regions: main window */ art= MEM_callocN(sizeof(ARegionType), "spacetype text region"); |