diff options
Diffstat (limited to 'source/blender/editors/space_console')
-rw-r--r-- | source/blender/editors/space_console/Makefile | 1 | ||||
-rw-r--r-- | source/blender/editors/space_console/SConscript | 1 | ||||
-rw-r--r-- | source/blender/editors/space_console/space_console.c | 63 |
3 files changed, 65 insertions, 0 deletions
diff --git a/source/blender/editors/space_console/Makefile b/source/blender/editors/space_console/Makefile index a7c9283985b..3f760b1ad67 100644 --- a/source/blender/editors/space_console/Makefile +++ b/source/blender/editors/space_console/Makefile @@ -43,6 +43,7 @@ CPPFLAGS += -I../../windowmanager CPPFLAGS += -I../../blenfont CPPFLAGS += -I../../blenkernel CPPFLAGS += -I../../blenlib +CPPFLAGS += -I../../blenloader CPPFLAGS += -I../../makesdna CPPFLAGS += -I../../makesrna CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include diff --git a/source/blender/editors/space_console/SConscript b/source/blender/editors/space_console/SConscript index ecc10a1d0c3..d50902446ba 100644 --- a/source/blender/editors/space_console/SConscript +++ b/source/blender/editors/space_console/SConscript @@ -14,6 +14,7 @@ incs = [ '../../blenlib', '../../windowmanager', '../../blenfont', + '../../blenloader', ] if not env['WITH_BF_PYTHON']: diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 1b8191696f4..8a2f4e85f96 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -29,9 +29,14 @@ #include <string.h> #include <stdio.h> +#ifdef WIN32 +#include "BLI_winstuff.h" +#endif #include "MEM_guardedalloc.h" +#include "BLO_readfile.h" + #include "BLI_blenlib.h" #include "BLI_math.h" @@ -142,14 +147,71 @@ static SpaceLink *console_duplicate(SpaceLink *sl) static void console_main_area_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; + ListBase *lb; UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); /* own keymap */ keymap= WM_keymap_find(wm->defaultconf, "Console", SPACE_CONSOLE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + + /* add drop boxes */ + lb= WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW); + + WM_event_add_dropbox_handler(&ar->handlers, lb); +} + + +/* ************* dropboxes ************* */ + +static int id_drop_poll(bContext *C, wmDrag *drag, wmEvent *event) +{ + SpaceConsole *sc= CTX_wm_space_console(C); + if(sc->type==CONSOLE_TYPE_PYTHON) + if(drag->type==WM_DRAG_ID) + return 1; + return 0; +} + +static void id_drop_copy(wmDrag *drag, wmDropBox *drop) +{ + char text[64]; + ID *id= drag->poin; + + snprintf(text, sizeof(text), "bpy.data.%s['%s']", BLO_idcode_to_name_plural(GS(id->name)), id->name+2); + + /* copy drag path to properties */ + RNA_string_set(drop->ptr, "text", text); } +static int path_drop_poll(bContext *C, wmDrag *drag, wmEvent *event) +{ + SpaceConsole *sc= CTX_wm_space_console(C); + if(sc->type==CONSOLE_TYPE_PYTHON) + if(drag->type==WM_DRAG_PATH) + return 1; + return 0; +} + +static void path_drop_copy(wmDrag *drag, wmDropBox *drop) +{ + char pathname[FILE_MAXDIR+FILE_MAXFILE+2]; + snprintf(pathname, sizeof(pathname), "\"%s\"", drag->path); + RNA_string_set(drop->ptr, "text", pathname); +} + + +/* this region dropbox definition */ +static void console_dropboxes(void) +{ + ListBase *lb= WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW); + + WM_dropbox_add(lb, "CONSOLE_OT_insert", id_drop_poll, id_drop_copy); + WM_dropbox_add(lb, "CONSOLE_OT_insert", path_drop_poll, path_drop_copy); +} + +/* ************* end drop *********** */ + static void console_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ @@ -344,6 +406,7 @@ void ED_spacetype_console(void) st->duplicate= console_duplicate; st->operatortypes= console_operatortypes; st->keymap= console_keymap; + st->dropboxes= console_dropboxes; st->listener= console_main_area_listener; /* regions: main window */ |