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:
authorMatt Ebb <matt@mke3.net>2010-05-12 08:25:33 +0400
committerMatt Ebb <matt@mke3.net>2010-05-12 08:25:33 +0400
commit7aa907c996cd9a22a1b1d14159ef7ef9822f0a54 (patch)
tree4b8fdec044aa2ee9968e4e4b39b7cc14f1b395e5 /source/blender/editors/space_node/space_node.c
parentd153850520cc191b7cfad6c84cd56bebadeda376 (diff)
Another one for drag and drop:
Allow dropping image files from outside blender, or image datablocks from inside blender to the compositing node editor, to add an image node. Also small tweak: Only set 'path' properties on drops, if the drag->path isn't empty.
Diffstat (limited to 'source/blender/editors/space_node/space_node.c')
-rw-r--r--source/blender/editors/space_node/space_node.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index 3bafcc25f6e..d22d1b4aa2d 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -53,6 +53,7 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "UI_resources.h"
#include "UI_view2d.h"
#include "RNA_access.h"
@@ -263,6 +264,7 @@ static void node_buttons_area_draw(const bContext *C, ARegion *ar)
static void node_main_area_init(wmWindowManager *wm, ARegion *ar)
{
wmKeyMap *keymap;
+ ListBase *lb;
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
@@ -272,6 +274,11 @@ static void node_main_area_init(wmWindowManager *wm, ARegion *ar)
keymap= WM_keymap_find(wm->defaultconf, "Node Editor", SPACE_NODE, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+
+ /* add drop boxes */
+ lb = WM_dropboxmap_find("Node Editor", SPACE_NODE, RGN_TYPE_WINDOW);
+
+ WM_event_add_dropbox_handler(&ar->handlers, lb);
}
static void node_main_area_draw(const bContext *C, ARegion *ar)
@@ -281,6 +288,47 @@ static void node_main_area_draw(const bContext *C, ARegion *ar)
drawnodespace(C, ar, v2d);
}
+
+/* ************* dropboxes ************* */
+
+static int node_drop_poll(bContext *C, wmDrag *drag, wmEvent *event)
+{
+ if(drag->type==WM_DRAG_ID) {
+ ID *id= (ID *)drag->poin;
+ 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;
+}
+
+static void node_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[0]) {
+ RNA_string_set(drop->ptr, "path", drag->path);
+ }
+}
+
+/* this region dropbox definition */
+static void node_dropboxes(void)
+{
+ ListBase *lb= WM_dropboxmap_find("Node Editor", SPACE_NODE, RGN_TYPE_WINDOW);
+
+ WM_dropbox_add(lb, "NODE_OT_add_file", node_drop_poll, node_id_path_drop_copy);
+
+}
+
+/* ************* end drop *********** */
+
+
/* add handlers, stuff you only do once or on area/region changes */
static void node_header_area_init(wmWindowManager *wm, ARegion *ar)
{
@@ -366,6 +414,7 @@ void ED_spacetype_node(void)
st->listener= node_area_listener;
st->refresh= node_area_refresh;
st->context= node_context;
+ st->dropboxes = node_dropboxes;
/* regions: main window */
art= MEM_callocN(sizeof(ARegionType), "spacetype node region");