Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-05-02 20:42:42 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-05-02 20:42:42 +0400
commitd821cdd948497a3d484b657e72c282f02a270af6 (patch)
treea02a4556fd02ff7f75a4ede0962d3c8b47318754 /source/blender/editors/space_clip/space_clip.c
parent66581e903c346e60797669693de99fd710806af6 (diff)
Clip editor: added drag-n-drop support so files can be opened in clip editor
by drag-n-dropping them from an external application.
Diffstat (limited to 'source/blender/editors/space_clip/space_clip.c')
-rw-r--r--source/blender/editors/space_clip/space_clip.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index 271ad84fec6..80755828f7e 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -304,9 +304,12 @@ static void clip_free(SpaceLink *sl)
}
/* spacetype; init callback */
-static void clip_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
+static void clip_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa)
{
+ ListBase *lb = WM_dropboxmap_find("Clip", SPACE_CLIP, 0);
+ /* add drop boxes */
+ WM_event_add_dropbox_handler(&sa->handlers, lb);
}
static SpaceLink *clip_duplicate(SpaceLink *sl)
@@ -731,6 +734,30 @@ static int clip_context(const bContext *C, const char *member, bContextDataResul
return FALSE;
}
+/* dropboxes */
+static int clip_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event))
+{
+ if (drag->type == WM_DRAG_PATH)
+ if (ELEM3(drag->icon, 0, ICON_FILE_IMAGE, ICON_FILE_BLANK)) /* rule might not work? */
+ return TRUE;
+
+ return FALSE;
+}
+
+static void clip_drop_copy(wmDrag *drag, wmDropBox *drop)
+{
+ /* copy drag path to properties */
+ RNA_string_set(drop->ptr, "filepath", drag->path);
+}
+
+/* area+region dropbox definition */
+static void clip_dropboxes(void)
+{
+ ListBase *lb = WM_dropboxmap_find("Clip", SPACE_CLIP, 0);
+
+ WM_dropbox_add(lb, "CLIP_OT_open", clip_drop_poll, clip_drop_copy);
+}
+
static void clip_refresh(const bContext *C, ScrArea *sa)
{
wmWindowManager *wm = CTX_wm_manager(C);
@@ -1296,6 +1323,7 @@ void ED_spacetype_clip(void)
st->keymap = clip_keymap;
st->listener = clip_listener;
st->context = clip_context;
+ st->dropboxes = clip_dropboxes;
st->refresh = clip_refresh;
/* regions: main window */