diff options
author | Xiao Xiangquan <xiaoxiangquan@gmail.com> | 2011-07-14 21:29:53 +0400 |
---|---|---|
committer | Xiao Xiangquan <xiaoxiangquan@gmail.com> | 2011-07-14 21:29:53 +0400 |
commit | fa46278e347ca173e9e6d6b734a59c268f4fc9d0 (patch) | |
tree | a14148822e60cb1f8f36dba0481b830cb9675db1 /source/blender/windowmanager | |
parent | 470a5017fb80f21bac08373e4b5816c92d42990a (diff) | |
parent | 4da4943b5ce9514e9fb3d9458f3e52d6b0d310ca (diff) |
merge from trunk 38379
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 35 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 26 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 10 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 21 |
5 files changed, 48 insertions, 47 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 2613cb8f14f..ce3830b059c 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2365,18 +2365,11 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U if(win->active) { GHOST_TEventCursorData *cd= customdata; wmEvent *lastevent= win->queue.last; - -#if defined(__APPLE__) && defined(GHOST_COCOA) - //Cocoa already uses coordinates with y=0 at bottom, and returns inwindow coordinates on mouse moved event - evt->x= cd->x; - evt->y= cd->y; -#else int cx, cy; GHOST_ScreenToClient(win->ghostwin, cd->x, cd->y, &cx, &cy); evt->x= cx; evt->y= (win->sizey-1) - cy; -#endif event.x= evt->x; event.y= evt->y; @@ -2423,21 +2416,17 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U event.type= MOUSEPAN; break; } -#if defined(__APPLE__) && defined(GHOST_COCOA) - //Cocoa already uses coordinates with y=0 at bottom, and returns inwindow coordinates on mouse moved event - event.x= evt->x = pd->x; - event.y = evt->y = pd->y; -#else + { - int cx, cy; - GHOST_ScreenToClient(win->ghostwin, pd->x, pd->y, &cx, &cy); - event.x= evt->x= cx; - event.y= evt->y= (win->sizey-1) - cy; + int cx, cy; + GHOST_ScreenToClient(win->ghostwin, pd->x, pd->y, &cx, &cy); + event.x= evt->x= cx; + event.y= evt->y= (win->sizey-1) - cy; } -#endif + // Use prevx/prevy so we can calculate the delta later event.prevx= event.x - pd->deltaX; - event.prevy= event.y - pd->deltaY; + event.prevy= event.y - (-pd->deltaY); update_tablet_data(win, &event); wm_event_add(win, &event); @@ -2460,6 +2449,16 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U else event.type= MIDDLEMOUSE; + if(win->active==0) { + int cx, cy; + + /* entering window, update mouse pos. (ghost sends win-activate *after* the mouseclick in window!) */ + wm_get_cursor_position(win, &cx, &cy); + + event.x= evt->x= cx; + event.y= evt->y= cy; + } + /* add to other window if event is there (not to both!) */ owin= wm_event_cursor_other_windows(wm, win, &event); if(owin) { diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 6bec3b60df1..df00c2b83cb 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -57,6 +57,7 @@ #include "BLI_blenlib.h" #include "BLI_linklist.h" #include "BLI_utildefines.h" +#include "BLI_callbacks.h" #include "BLF_api.h" @@ -344,6 +345,8 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports) WM_cursor_wait(1); + BLI_exec_cb(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_PRE); + /* first try to append data from exotic file formats... */ /* it throws error box when file doesnt exist and returns -1 */ /* note; it should set some error message somewhere... (ton) */ @@ -394,6 +397,7 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports) #ifdef WITH_PYTHON /* run any texts that were loaded in and flagged as modules */ BPY_driver_reset(); + BPY_app_handlers_reset(); BPY_modules_load_user(C); #endif CTX_wm_window_set(C, NULL); /* exits queues */ @@ -413,7 +417,8 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports) // XXX undo_editmode_clear(); BKE_reset_undo(); BKE_write_undo(C, "original"); /* save current state */ - + + BLI_exec_cb(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_POST); } else if(retval == BKE_READ_EXOTIC_OK_OTHER) BKE_write_undo(C, "Import file"); @@ -520,6 +525,7 @@ int WM_read_homefile(bContext *C, ReportList *reports, short from_memory) BPY_string_exec(C, "__import__('addon_utils').reset_all()"); BPY_driver_reset(); + BPY_app_handlers_reset(); BPY_modules_load_user(C); } #endif @@ -631,8 +637,9 @@ static ImBuf *blend_file_thumb(Scene *scene, int **thumb_pt) char err_out[256]= "unknown"; *thumb_pt= NULL; - - if(G.background || scene->camera==NULL) + + /* scene can be NULL if running a script at startup and calling the save operator */ + if(G.background || scene==NULL || scene->camera==NULL) return NULL; /* gets scaled to BLEN_THUMB_SIZE */ @@ -718,6 +725,14 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re } } + /* blend file thumbnail */ + /* save before exit_editmode, otherwise derivedmeshes for shared data corrupt #27765) */ + if(U.flag & USER_SAVE_PREVIEWS) { + ibuf_thumb= blend_file_thumb(CTX_data_scene(C), &thumb); + } + + BLI_exec_cb(G.main, NULL, BLI_CB_EVT_SAVE_PRE); + /* operator now handles overwrite checks */ if (G.fileflags & G_AUTOPACK) { @@ -730,9 +745,6 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re /* don't forget not to return without! */ WM_cursor_wait(1); - /* blend file thumbnail */ - ibuf_thumb= blend_file_thumb(CTX_data_scene(C), &thumb); - fileflags |= G_FILE_HISTORY; /* write file history */ if (BLO_write_file(CTX_data_main(C), filepath, fileflags, reports, thumb)) { @@ -754,6 +766,8 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re write_history(); } + BLI_exec_cb(G.main, NULL, BLI_CB_EVT_SAVE_POST); + /* run this function after because the file cant be written before the blend is */ if (ibuf_thumb) { ibuf_thumb= IMB_thumb_create(filepath, THB_NORMAL, THB_SOURCE_BLEND, ibuf_thumb); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 01ce605ed65..dfa3a0f80f1 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -162,6 +162,7 @@ void WM_init(bContext *C, int argc, const char **argv) BPY_python_start(argc, argv); BPY_driver_reset(); + BPY_app_handlers_reset(); BPY_modules_load_user(C); #else (void)argc; /* unused */ @@ -423,7 +424,7 @@ void WM_exit(bContext *C) BPY_python_end(); #endif - GPU_buffer_pool_free(NULL); + GPU_global_buffer_pool_free(); GPU_free_unused_buffers(); GPU_extensions_exit(); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 8313f2f85bc..41838052b47 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2004,6 +2004,8 @@ static void WM_OT_save_mainfile(wmOperatorType *ot) static int wm_collada_export_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { + int selected = 0; + if(!RNA_property_is_set(op->ptr, "filepath")) { char filepath[FILE_MAX]; BLI_strncpy(filepath, G.main->name, sizeof(filepath)); @@ -2020,6 +2022,7 @@ static int wm_collada_export_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED static int wm_collada_export_exec(bContext *C, wmOperator *op) { char filename[FILE_MAX]; + int selected; if(!RNA_property_is_set(op->ptr, "filepath")) { BKE_report(op->reports, RPT_ERROR, "No filename given"); @@ -2027,7 +2030,8 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) } RNA_string_get(op->ptr, "filepath", filename); - if(collada_export(CTX_data_scene(C), filename)) { + selected = RNA_boolean_get(op->ptr, "selected"); + if(collada_export(CTX_data_scene(C), filename, selected)) { return OPERATOR_FINISHED; } else { @@ -2045,6 +2049,8 @@ static void WM_OT_collada_export(wmOperatorType *ot) ot->poll= WM_operator_winactive; WM_operator_properties_filesel(ot, FOLDERFILE|COLLADAFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH); + RNA_def_boolean(ot->srna, "selected", 0, _("Export only selected"), + _("Export only selected elements")); } /* function used for WM_OT_save_mainfile too */ @@ -3368,7 +3374,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) time= (float)((PIL_check_seconds_timer()-stime)*1000); - RNA_enum_description( redraw_timer_type_items, type, &infostr); + RNA_enum_description(redraw_timer_type_items, type, &infostr); WM_cursor_wait(0); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index e2e08c8f546..5836c432181 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -675,13 +675,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) GHOST_ScreenToClient(win->ghostwin, wx, wy, &cx, &cy); win->eventstate->x= cx; - -#if defined(__APPLE__) && defined(GHOST_COCOA) - //Cocoa already uses coordinates with y=0 at bottom - win->eventstate->y= cy; -#else win->eventstate->y= (win->sizey-1) - cy; -#endif win->addmousemove= 1; /* enables highlighted buttons */ @@ -798,20 +792,13 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) wmEvent event; GHOST_TEventDragnDropData *ddd= GHOST_GetEventData(evt); int cx, cy, wx, wy; - /* entering window, update mouse pos */ GHOST_GetCursorPosition(g_system, &wx, &wy); GHOST_ScreenToClient(win->ghostwin, wx, wy, &cx, &cy); win->eventstate->x= cx; - -#if defined(__APPLE__) && defined(GHOST_COCOA) - //Cocoa already uses coordinates with y=0 at bottom - win->eventstate->y= cy; -#else win->eventstate->y= (win->sizey-1) - cy; -#endif event= *(win->eventstate); /* copy last state, like mouse coords */ @@ -1151,12 +1138,7 @@ void wm_get_cursor_position(wmWindow *win, int *x, int *y) { GHOST_GetCursorPosition(g_system, x, y); GHOST_ScreenToClient(win->ghostwin, *x, *y, x, y); -#if defined(__APPLE__) && defined(GHOST_COCOA) - //Cocoa has silly exception that should be fixed at the ghost level - //(ghost is an allegory for an invisible system specific code) -#else *y = (win->sizey-1) - *y; -#endif } /* ******************* exported api ***************** */ @@ -1189,9 +1171,8 @@ void WM_cursor_warp(wmWindow *win, int x, int y) if (win && win->ghostwin) { int oldx=x, oldy=y; -#if !defined(__APPLE__) || !defined(GHOST_COCOA) y= win->sizey -y - 1; -#endif + GHOST_ClientToScreen(win->ghostwin, x, y, &x, &y); GHOST_SetCursorPosition(g_system, x, y); |