diff options
author | Ton Roosendaal <ton@blender.org> | 2010-12-17 22:05:34 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2010-12-17 22:05:34 +0300 |
commit | a0ce28d7312adc31194e2ba34974dc5de754fced (patch) | |
tree | fc801b5d536e8d37207d04c068b7e1e456f470df /source/blender/editors/screen | |
parent | fd90685a48f6fae30e6731bc4a805930e776f117 (diff) |
Drag & drop feature:
You now can drop a .blend inside blender window to open it.
Implementation notes:
- Added call to extract icon type for files. Code re-used from
space_file
- External files that get dropped set icon types too.
Drop box polls can check for this.
- Also enabled setting op-context for drop operators, this was
needed to prevent filewindow to open.
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index bcfddd0792c..0c49779cd84 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -64,6 +64,7 @@ #include "RNA_define.h" #include "UI_interface.h" +#include "UI_resources.h" #include "wm_window.h" @@ -3014,6 +3015,7 @@ void SCENE_OT_delete(wmOperatorType *ot) /* **************** Assigning operatortypes to global list, adding handlers **************** */ + /* called in spacetypes.c */ void ED_operatortypes_screen(void) { @@ -3087,9 +3089,27 @@ static void keymap_modal_set(wmKeyConfig *keyconf) } +static int open_file_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) +{ + if(drag->type==WM_DRAG_PATH) { + if(drag->icon==ICON_FILE_BLEND) + return 1; + } + return 0; +} + +static void open_file_drop_copy(wmDrag *drag, wmDropBox *drop) +{ + /* copy drag path to properties */ + RNA_string_set(drop->ptr, "filepath", drag->path); + drop->opcontext= WM_OP_EXEC_DEFAULT; +} + + /* called in spacetypes.c */ void ED_keymap_screen(wmKeyConfig *keyconf) { + ListBase *lb; wmKeyMap *keymap; //wmKeyMapItem *kmi; @@ -3203,6 +3223,10 @@ void ED_keymap_screen(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", DOWNARROWKEY, KM_PRESS, KM_ALT, 0); #endif + /* dropbox for entire window */ + lb= WM_dropboxmap_find("Window", 0, 0); + WM_dropbox_add(lb, "WM_OT_open_mainfile", open_file_drop_poll, open_file_drop_copy); + keymap_modal_set(keyconf); } |