diff options
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/Makefile | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 5 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/Makefile | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm.c | 9 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_dragdrop.c | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_draw.c | 35 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 22 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 85 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 119 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_jobs.c | 13 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 105 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 4 | ||||
-rw-r--r-- | source/blender/windowmanager/wm_window.h | 2 |
13 files changed, 270 insertions, 135 deletions
diff --git a/source/blender/windowmanager/Makefile b/source/blender/windowmanager/Makefile index 90621f66057..1596921b5ee 100644 --- a/source/blender/windowmanager/Makefile +++ b/source/blender/windowmanager/Makefile @@ -15,7 +15,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # The Original Code is Copyright (C) Blender Foundation. # All rights reserved. diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 78ea0350667..9fe09c0836c 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -57,7 +57,7 @@ void WM_init (struct bContext *C, int argc, char **argv); void WM_exit (struct bContext *C); void WM_main (struct bContext *C); -void WM_init_game (struct bContext *C); +int WM_init_game (struct bContext *C); void WM_init_splash (struct bContext *C); @@ -78,7 +78,7 @@ void WM_window_open_temp (struct bContext *C, struct rcti *position, int type); int WM_read_homefile (struct bContext *C, struct wmOperator *op); int WM_write_homefile (struct bContext *C, struct wmOperator *op); void WM_read_file (struct bContext *C, char *name, struct ReportList *reports); -int WM_write_file (struct bContext *C, char *target, int fileflags, struct ReportList *reports); +int WM_write_file (struct bContext *C, char *target, int fileflags, struct ReportList *reports, int copy); void WM_read_autosavefile(struct bContext *C); void WM_autosave_init (struct wmWindowManager *wm); @@ -201,7 +201,6 @@ void WM_operator_free (struct wmOperator *op); void WM_operator_stack_clear(struct bContext *C); struct wmOperatorType *WM_operatortype_find(const char *idnamem, int quiet); -struct wmOperatorType *WM_operatortype_exists(const char *idname); struct wmOperatorType *WM_operatortype_first(void); void WM_operatortype_append (void (*opfunc)(struct wmOperatorType*)); void WM_operatortype_append_ptr (void (*opfunc)(struct wmOperatorType*, void *), void *userdata); diff --git a/source/blender/windowmanager/intern/Makefile b/source/blender/windowmanager/intern/Makefile index 18085194405..60be5fed4b2 100644 --- a/source/blender/windowmanager/intern/Makefile +++ b/source/blender/windowmanager/intern/Makefile @@ -15,7 +15,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. # All rights reserved. diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index fcf8951d796..8d36711032b 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -26,7 +26,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -#include "string.h" +#include <string.h> +#include <stddef.h> #include "DNA_windowmanager_types.h" @@ -149,9 +150,9 @@ MenuType *WM_menutype_find(const char *idname, int quiet) MenuType* mt; if (idname[0]) { - for(mt=menutypes.first; mt; mt=mt->next) - if(strcmp(idname, mt->idname)==0) - return mt; + mt= BLI_findstring(&menutypes, idname, offsetof(MenuType, idname)); + if(mt) + return mt; } if(!quiet) diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index 3d519a5609b..18b1e7239ed 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -26,7 +26,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -#include "string.h" +#include <string.h> #include "DNA_windowmanager_types.h" #include "DNA_screen_types.h" diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 38322b66bbb..aa26d4444b1 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -101,6 +101,14 @@ static void wm_area_mark_invalid_backbuf(ScrArea *sa) ((View3D*)sa->spacedata.first)->flag |= V3D_INVALID_BACKBUF; } +static int wm_area_test_invalid_backbuf(ScrArea *sa) +{ + if(sa->spacetype == SPACE_VIEW3D) + return (((View3D*)sa->spacedata.first)->flag & V3D_INVALID_BACKBUF); + else + return 1; +} + /********************** draw all **************************/ /* - reference method, draw all each time */ @@ -189,6 +197,12 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange) ARegion *ar; static rcti rect= {0, 0, 0, 0}; + /* after backbuffer selection draw, we need to redraw */ + for(sa= screen->areabase.first; sa; sa= sa->next) + for(ar= sa->regionbase.first; ar; ar= ar->next) + if(ar->swinid && !wm_area_test_invalid_backbuf(sa)) + ED_region_tag_redraw(ar); + /* flush overlapping regions */ if(screen->regionbase.first) { /* flush redraws of area regions up to overlapping regions */ @@ -677,13 +691,26 @@ static int wm_draw_update_test_window(wmWindow *win) static int wm_automatic_draw_method(wmWindow *win) { + /* Ideally all cards would work well with triple buffer, since if it works + well gives the least redraws and is considerably faster at partial redraw + for sculpting or drawing overlapping menus. For typically lower end cards + copy to texture is slow though and so we use overlap instead there. */ + if(win->drawmethod == USER_DRAW_AUTOMATIC) { /* ATI opensource driver is known to be very slow at this */ if(GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) return USER_DRAW_OVERLAP; + /* also Intel drivers are slow */ + else if(GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_UNIX, GPU_DRIVER_ANY)) + return USER_DRAW_OVERLAP; + else if(GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_WIN, GPU_DRIVER_ANY)) + return USER_DRAW_OVERLAP_FLIP; + else if(GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_MAC, GPU_DRIVER_ANY)) + return USER_DRAW_OVERLAP_FLIP; /* Windows software driver darkens color on each redraw */ else if(GPU_type_matches(GPU_DEVICE_SOFTWARE, GPU_OS_WIN, GPU_DRIVER_SOFTWARE)) return USER_DRAW_OVERLAP_FLIP; + /* drawing lower color depth again degrades colors each time */ else if(GPU_color_depth() < 24) return USER_DRAW_OVERLAP; else @@ -781,3 +808,11 @@ void wm_draw_region_clear(wmWindow *win, ARegion *ar) win->screen->do_draw= 1; } +void wm_draw_region_modified(wmWindow *win, ARegion *ar) +{ + int drawmethod= wm_automatic_draw_method(win); + + if(ELEM(drawmethod, USER_DRAW_OVERLAP, USER_DRAW_OVERLAP_FLIP)) + ED_region_tag_redraw(ar); +} + diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 3077b25cc73..e1fc934ee3e 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -296,7 +296,7 @@ void wm_event_do_notifiers(bContext *C) /* XXX make lock in future, or separated derivedmesh users in scene */ if(!G.rendering) /* depsgraph & animation: update tagged datablocks */ - scene_update_tagged(win->screen->scene); + scene_update_tagged(CTX_data_main(C), win->screen->scene); } CTX_wm_window_set(C, NULL); @@ -425,6 +425,14 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int pop } } +/* this function is mainly to check that the rules for freeing + * an operator are kept in sync. + */ +static int wm_operator_register_check(wmWindowManager *wm, wmOperatorType *ot) +{ + return (wm->op_undo_depth == 0) && (ot->flag & OPTYPE_REGISTER); +} + static void wm_operator_finished(bContext *C, wmOperator *op, int repeat) { wmWindowManager *wm= CTX_wm_manager(C); @@ -445,7 +453,7 @@ static void wm_operator_finished(bContext *C, wmOperator *op, int repeat) MEM_freeN(buf); } - if((wm->op_undo_depth == 0) && (op->type->flag & OPTYPE_REGISTER)) + if(wm_operator_register_check(wm, op->type)) wm_operator_register(C, op); else WM_operator_free(op); @@ -801,17 +809,17 @@ int WM_operator_name_call(bContext *C, const char *opstring, int context, Pointe } /* Similar to WM_operator_name_call called with WM_OP_EXEC_DEFAULT context. - - wmOperatorType is used instead of operator name since python alredy has the operator type + - wmOperatorType is used instead of operator name since python already has the operator type - poll() must be called by python before this runs. - reports can be passed to this function (so python can report them as exceptions) */ int WM_operator_call_py(bContext *C, wmOperatorType *ot, int context, PointerRNA *properties, ReportList *reports) { + wmWindowManager *wm= CTX_wm_manager(C); int retval= OPERATOR_CANCELLED; #if 0 wmOperator *op; - wmWindowManager *wm= CTX_wm_manager(C); op= wm_operator_create(wm, ot, properties, reports); if (op->type->exec) { @@ -830,9 +838,9 @@ int WM_operator_call_py(bContext *C, wmOperatorType *ot, int context, PointerRNA retval= wm_operator_call_internal(C, ot, context, properties, reports); /* keep the reports around if needed later */ - if (retval & OPERATOR_RUNNING_MODAL || ot->flag & OPTYPE_REGISTER) + if (retval & OPERATOR_RUNNING_MODAL || wm_operator_register_check(wm, ot)) { - reports->flag |= RPT_FREE; + reports->flag |= RPT_FREE; /* let blender manage freeing */ } return retval; @@ -1598,7 +1606,7 @@ void wm_event_do_handlers(bContext *C) } if(playing == 0) { - int ncfra = round(sound_sync_scene(scene) * FPS); + int ncfra = sound_sync_scene(scene) * FPS + 0.5; if(ncfra != scene->r.cfra) { scene->r.cfra = ncfra; ED_update_for_newframe(C, 1); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 8a05e6c4916..e2293f79e95 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -179,21 +179,23 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist) /* we've read file without wm..., keep current one entirely alive */ if(G.main->wm.first==NULL) { - bScreen *screen= CTX_wm_screen(C); - - /* match oldwm to new dbase, only old files */ - - for(wm= oldwmlist->first; wm; wm= wm->id.next) { - - for(win= wm->windows.first; win; win= win->next) { - /* all windows get active screen from file */ - if(screen->winid==0) - win->screen= screen; - else - win->screen= ED_screen_duplicate(win, screen); + /* when loading without UI, no matching needed */ + if(!(G.fileflags & G_FILE_NO_UI)) { + bScreen *screen= CTX_wm_screen(C); + + /* match oldwm to new dbase, only old files */ + for(wm= oldwmlist->first; wm; wm= wm->id.next) { - BLI_strncpy(win->screenname, win->screen->id.name+2, 21); - win->screen->winid= win->winid; + for(win= wm->windows.first; win; win= win->next) { + /* all windows get active screen from file */ + if(screen->winid==0) + win->screen= screen; + else + win->screen= ED_screen_duplicate(win, screen); + + BLI_strncpy(win->screenname, win->screen->id.name+2, 21); + win->screen->winid= win->winid; + } } } @@ -312,7 +314,7 @@ void WM_read_file(bContext *C, char *name, ReportList *reports) CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first); ED_editors_init(C); - DAG_on_load_update(); + DAG_on_load_update(CTX_data_main(C)); #ifndef DISABLE_PYTHON /* run any texts that were loaded in and flagged as modules */ @@ -382,7 +384,7 @@ int WM_read_homefile(bContext *C, wmOperator *op) /* XXX */ G.save_over = 0; // start with save preference untitled.blend - G.fileflags &= ~G_FILE_AUTOPLAY; /* disable autoplay in .B.blend... */ + G.fileflags &= ~G_FILE_AUTOPLAY; /* disable autoplay in startup.blend... */ // mainwindow_set_filename_to_title(""); // empty string re-initializes title to "Blender" // refresh_interface_font(); @@ -392,7 +394,7 @@ int WM_read_homefile(bContext *C, wmOperator *op) BKE_write_undo(C, "original"); /* save current state */ ED_editors_init(C); - DAG_on_load_update(); + DAG_on_load_update(CTX_data_main(C)); WM_event_add_notifier(C, NC_WM|ND_FILEREAD, NULL); CTX_wm_window_set(C, NULL); /* exits queues */ @@ -418,7 +420,7 @@ void read_history(void) G.recent_files.first = G.recent_files.last = NULL; - /* read list of recent opend files from .Blog to memory */ + /* read list of recent opend files from recent-files.txt to memory */ for (l= lines, num= 0; l && (num<U.recent_files); l= l->next) { line = l->link; if (line[0] && BLI_exists(line)) { @@ -434,9 +436,6 @@ void read_history(void) num++; } } - - if(G.sce[0] == 0) - BLI_make_file_string("/", G.sce, BLI_gethome(), "untitled.blend"); BLI_free_file_lines(lines); @@ -452,7 +451,7 @@ static void write_history(void) BLI_make_file_string("/", name, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_HISTORY_FILE); recent = G.recent_files.first; - /* refresh .Blog of recent opened files, when current file was changed */ + /* refresh recent-files.txt of recent opened files, when current file was changed */ if(!(recent) || (strcmp(recent->filepath, G.sce)!=0)) { fp= fopen(name, "w"); if (fp) { @@ -462,11 +461,11 @@ static void write_history(void) recent->filepath[0] = '\0'; strcpy(recent->filepath, G.sce); BLI_addhead(&(G.recent_files), recent); - /* write current file to .Blog */ + /* write current file to recent-files.txt */ fprintf(fp, "%s\n", recent->filepath); recent = recent->next; i=1; - /* write rest of recent opened files to .Blog */ + /* write rest of recent opened files to recent-files.txt */ while((i<U.recent_files) && (recent)){ /* this prevents to have duplicities in list */ if (strcmp(recent->filepath, G.sce)!=0) { @@ -569,7 +568,7 @@ int write_crash_blend(void) } } -int WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports) +int WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports, int copy) { Library *li; int len; @@ -616,17 +615,20 @@ int WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports) ED_object_exit_editmode(C, EM_DO_UNDO); ED_sculpt_force_update(C); - do_history(di, reports); - /* blend file thumbnail */ ibuf_thumb= blend_file_thumb(di, CTX_data_scene(C), &thumb); - if (BLO_write_file(CTX_data_main(C), di, fileflags, reports, thumb)) { - strcpy(G.sce, di); - G.relbase_valid = 1; - strcpy(G.main->name, di); /* is guaranteed current file */ + /* rename to .blend1, do this as last before write */ + do_history(di, reports); - G.save_over = 1; /* disable untitled.blend convention */ + if (BLO_write_file(CTX_data_main(C), di, fileflags, reports, thumb)) { + if(!copy) { + strcpy(G.sce, di); + G.relbase_valid = 1; + strcpy(G.main->name, di); /* is guaranteed current file */ + + G.save_over = 1; /* disable untitled.blend convention */ + } if(fileflags & G_FILE_COMPRESS) G.fileflags |= G_FILE_COMPRESS; else G.fileflags &= ~G_FILE_COMPRESS; @@ -685,21 +687,22 @@ void wm_autosave_location(char *filename) { char pidstr[32]; #ifdef WIN32 - char subdir[9]; - char savedir[FILE_MAXDIR]; + char *savedir; #endif sprintf(pidstr, "%d.blend", abs(getpid())); #ifdef WIN32 + /* XXX Need to investigate how to handle default location of '/tmp/' + * This is a relative directory on Windows, and it may be + * found. Example: + * Blender installed on D:\ drive, D:\ drive has D:\tmp\ + * Now, BLI_exists() will find '/tmp/' exists, but + * BLI_make_file_string will create string that has it most likely on C:\ + * through get_default_root(). + * If there is no C:\tmp autosave fails. */ if (!BLI_exists(U.tempdir)) { - BLI_strncpy(subdir, "autosave", sizeof(subdir)); - BLI_make_file_string("/", savedir, BLI_gethome(), subdir); - - /* create a new autosave dir - * function already checks for existence or not */ - BLI_recurdir_fileops(savedir); - + savedir = BLI_get_folder_create(BLENDER_USER_AUTOSAVE, NULL); BLI_make_file_string("/", filename, savedir, pidstr); return; } diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index adf0e9d2001..0fd42ffb8aa 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -49,6 +49,7 @@ #include "BKE_font.h" #include "BKE_global.h" #include "BKE_library.h" +#include "BKE_main.h" #include "BKE_mball.h" #include "BKE_report.h" #include "BKE_utildefines.h" @@ -95,6 +96,7 @@ #include "BKE_depsgraph.h" #include "BKE_sound.h" +#include "GHOST_C-api.h" static void wm_init_reports(bContext *C) { @@ -165,6 +167,10 @@ void WM_init(bContext *C, int argc, char **argv) G.ndofdevice = -1; /* XXX bad initializer, needs set otherwise buttons show! */ read_history(); + + if(G.sce[0] == 0) + BLI_make_file_string("/", G.sce, BLI_getDefaultDocumentFolder(), "untitled.blend"); + BLI_strncpy(G.lib, G.sce, FILE_MAX); } @@ -183,18 +189,115 @@ void WM_init_splash(bContext *C) } } -void WM_init_game(bContext *C) +static ScrArea *biggest_view3d(bContext *C) +{ + bScreen *sc= CTX_wm_screen(C); + ScrArea *sa, *big= NULL; + int size, maxsize= 0; + + for(sa= sc->areabase.first; sa; sa= sa->next) { + if(sa->spacetype==SPACE_VIEW3D) { + size= sa->winx * sa->winy; + if(size > maxsize) { + maxsize= size; + big= sa; + } + } + } + return big; +} + +int WM_init_game(bContext *C) { - //XXX copied from WM_init_splash we may not even need those "window" related code - //XXX not working yet, it fails at the game_start_operator pool (it needs an area) wmWindowManager *wm= CTX_wm_manager(C); - wmWindow *prevwin= CTX_wm_window(C); - - if(wm->windows.first) { - CTX_wm_window_set(C, wm->windows.first); + wmWindow* win; + + ScrArea *sa; + ARegion *ar; + + Scene *scene= CTX_data_scene(C); + + if (!scene) { + // XXX, this should not be needed. + Main *bmain = CTX_data_main(C); + scene= bmain->scene.first; + } + + win = wm->windows.first; + + //first to get a valid window + if(win) + CTX_wm_window_set(C, win); + + sa = biggest_view3d(C); + + if(sa) + { + for(ar=sa->regionbase.first; ar; ar=ar->next) { + if(ar->regiontype == RGN_TYPE_WINDOW) { + break; + } + } + } + + // if we have a valid 3D view + if (sa && ar) { + ARegion *arhide; + + CTX_wm_area_set(C, sa); + CTX_wm_region_set(C, ar); + + /* disable quad view */ + if(ar->alignment == RGN_ALIGN_QSPLIT) + WM_operator_name_call(C, "SCREEN_OT_region_quadview", WM_OP_EXEC_DEFAULT, NULL); + + /* toolbox, properties panel and header are hidden */ + for(arhide=sa->regionbase.first; arhide; arhide=arhide->next) { + if(arhide->regiontype != RGN_TYPE_WINDOW) { + if(!(arhide->flag & RGN_FLAG_HIDDEN)) { + ED_region_toggle_hidden(C, arhide); + } + } + } + + /* full screen the area */ + if(!sa->full) { + ED_screen_full_toggle(C, wm->windows.first, sa); + } + + /* Fullscreen */ + if(scene->gm.fullscreen) { + WM_operator_name_call(C, "WM_OT_window_fullscreen_toggle", WM_OP_EXEC_DEFAULT, NULL); + wm_get_screensize(&ar->winrct.xmax, &ar->winrct.ymax); + } + else + { + GHOST_RectangleHandle rect = GHOST_GetClientBounds(win->ghostwin); + ar->winrct.ymax = GHOST_GetHeightRectangle(rect); + ar->winrct.xmax = GHOST_GetWidthRectangle(rect); + GHOST_DisposeRectangle(rect); + } + WM_operator_name_call(C, "VIEW3D_OT_game_start", WM_OP_EXEC_DEFAULT, NULL); - CTX_wm_window_set(C, prevwin); + + return 1; + } + else + { + ReportTimerInfo *rti; + + BKE_report(&wm->reports, RPT_ERROR, "No valid 3D View found. Game auto start is not possible."); + + /* After adding the report to the global list, reset the report timer. */ + WM_event_remove_timer(wm, NULL, wm->reports.reporttimer); + + /* Records time since last report was added */ + wm->reports.reporttimer = WM_event_add_timer(wm, CTX_wm_window(C), TIMER, 0.02); + + rti = MEM_callocN(sizeof(ReportTimerInfo), "ReportTimerInfo"); + wm->reports.reporttimer->customdata = rti; } + return 0; } /* free strings of open recent files */ diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index 80f1c680931..3ebfac4928c 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -355,9 +355,16 @@ void WM_jobs_kill(wmWindowManager *wm, void *owner, void *startjob) { wmJob *steve; - for(steve= wm->jobs.first; steve; steve= steve->next) - if(steve->owner==owner || steve->startjob==startjob) - wm_jobs_kill_job(wm, steve); + steve= wm->jobs.first; + while(steve) { + if(steve->owner==owner || steve->startjob==startjob) { + wmJob* bill = steve; + steve= steve->next; + wm_jobs_kill_job(wm, bill); + } else { + steve= steve->next; + } + } } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index efd05114d9a..2311024827e 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -30,6 +30,8 @@ #include <string.h> #include <ctype.h> #include <stdio.h> +#include <stddef.h> + #include "DNA_ID.h" #include "DNA_object_types.h" @@ -61,7 +63,7 @@ #include "BKE_scene.h" #include "BKE_screen.h" /* BKE_ST_MAXNAME */ #include "BKE_utildefines.h" -#include "BKE_brush.h" // JW +#include "BKE_idcode.h" #include "BIF_gl.h" #include "BIF_glutil.h" /* for paint cursor */ @@ -70,7 +72,6 @@ #include "ED_screen.h" #include "ED_util.h" -#include "ED_view3d.h" // JW #include "RNA_access.h" #include "RNA_define.h" @@ -88,8 +89,6 @@ #include "wm_subwindow.h" #include "wm_window.h" - - static ListBase global_ops= {NULL, NULL}; /* ************ operator API, exported ********** */ @@ -101,11 +100,11 @@ wmOperatorType *WM_operatortype_find(const char *idname, int quiet) char idname_bl[OP_MAX_TYPENAME]; // XXX, needed to support python style names without the _OT_ syntax WM_operator_bl_idname(idname_bl, idname); - + if (idname_bl[0]) { - for(ot= global_ops.first; ot; ot= ot->next) { - if(strncmp(ot->idname, idname_bl, OP_MAX_TYPENAME)==0) - return ot; + ot= (wmOperatorType *)BLI_findstring_ptr(&global_ops, idname_bl, offsetof(wmOperatorType, idname)); + if(ot) { + return ot; } } @@ -115,22 +114,6 @@ wmOperatorType *WM_operatortype_find(const char *idname, int quiet) return NULL; } -wmOperatorType *WM_operatortype_exists(const char *idname) -{ - wmOperatorType *ot; - - char idname_bl[OP_MAX_TYPENAME]; // XXX, needed to support python style names without the _OT_ syntax - WM_operator_bl_idname(idname_bl, idname); - - if(idname_bl[0]) { - for(ot= global_ops.first; ot; ot= ot->next) { - if(strncmp(ot->idname, idname_bl, OP_MAX_TYPENAME)==0) - return ot; - } - } - return NULL; -} - wmOperatorType *WM_operatortype_first(void) { return global_ops.first; @@ -331,7 +314,7 @@ wmOperatorType *WM_operatortype_append_macro(char *idname, char *name, int flag) { wmOperatorType *ot; - if(WM_operatortype_exists(idname)) { + if(WM_operatortype_find(idname, TRUE)) { printf("Macro error: operator %s exists\n", idname); return NULL; } @@ -1212,6 +1195,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *arg_unuse split = uiLayoutSplit(layout, 0, 0); col = uiLayoutColumn(split, 0); uiItemL(col, "Links", 0); + uiItemStringO(col, "Donations", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/blenderorg/blender-foundation/donation-payment/"); uiItemStringO(col, "Release Log", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/release-logs/blender-250/"); uiItemStringO(col, "Manual", ICON_URL, "WM_OT_url_open", "url", "http://wiki.blender.org/index.php/Doc:Manual"); uiItemStringO(col, "Blender Website", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/"); @@ -1584,7 +1568,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) scene_deselect_all(scene); bh = BLO_blendhandle_from_file(libname); - idcode = BLO_idcode_from_name(group); + idcode = BKE_idcode_from_name(group); flag = wm_link_append_flag(op); @@ -1628,8 +1612,8 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) flag_all_listbases_ids(LIB_PRE_EXISTING, 0); /* recreate dependency graph to include new objects */ - DAG_scene_sort(scene); - DAG_ids_flush_update(0); + DAG_scene_sort(bmain, scene); + DAG_ids_flush_update(bmain, 0); BLO_blendhandle_close(bh); @@ -1783,6 +1767,7 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op) { char path[FILE_MAX]; int fileflags; + int copy=0; save_set_compress(op); @@ -1793,6 +1778,9 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op) untitled(path); } + if(RNA_property_is_set(op->ptr, "copy")) + copy = RNA_boolean_get(op->ptr, "copy"); + fileflags= G.fileflags; /* set compression flag */ @@ -1801,7 +1789,7 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op) if(RNA_boolean_get(op->ptr, "relative_remap")) fileflags |= G_FILE_RELATIVE_REMAP; else fileflags &= ~G_FILE_RELATIVE_REMAP; - if ( WM_write_file(C, path, fileflags, op->reports) != 0) + if ( WM_write_file(C, path, fileflags, op->reports, copy) != 0) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_WM|ND_FILESAVE, NULL); @@ -1822,6 +1810,7 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot) WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH); RNA_def_boolean(ot->srna, "compress", 0, "Compress", "Write compressed .blend file"); RNA_def_boolean(ot->srna, "relative_remap", 1, "Remap Relative", "Remap relative paths when saving in a different directory"); + RNA_def_boolean(ot->srna, "copy", 0, "Save Copy", "Save a copy of the actual working state but does not make saved file active."); } /* *************** save file directly ******** */ @@ -1873,7 +1862,6 @@ static void WM_OT_save_mainfile(wmOperatorType *ot) RNA_def_boolean(ot->srna, "relative_remap", 0, "Remap Relative", "Remap relative paths when saving in a different directory"); } - /* XXX: move these collada operators to a more appropriate place */ #ifdef WITH_COLLADA @@ -2592,33 +2580,22 @@ const int WM_RADIAL_CONTROL_DISPLAY_SIZE = 200; typedef struct wmRadialControl { int mode; float initial_value, value, max_value; + float col[4], tex_col[4]; int initial_mouse[2]; void *cursor; GLuint tex; } wmRadialControl; -extern Paint *paint_get_active(Scene *sce); -extern struct Brush *paint_brush(struct Paint *paint); - static void wm_radial_control_paint(bContext *C, int x, int y, void *customdata) { wmRadialControl *rc = (wmRadialControl*)customdata; ARegion *ar = CTX_wm_region(C); float r1=0.0f, r2=0.0f, r3=0.0f, angle=0.0f; - Paint *paint = paint_get_active(CTX_data_scene(C)); - Brush *brush = paint_brush(paint); - - ViewContext vc; - // int hit = 0; - - int flip; - int sign; - - float* col; - - const float str = rc->mode == WM_RADIALCONTROL_STRENGTH ? (rc->value + 0.5) : (brush->texture_overlay_alpha / 100.0f); + + if(rc->mode == WM_RADIALCONTROL_STRENGTH) + rc->tex_col[3]= (rc->value + 0.5); if(rc->mode == WM_RADIALCONTROL_SIZE) { r1= rc->value; @@ -2636,18 +2613,6 @@ static void wm_radial_control_paint(bContext *C, int x, int y, void *customdata) x = rc->initial_mouse[0] - ar->winrct.xmin; y = rc->initial_mouse[1] - ar->winrct.ymin; - view3d_set_viewcontext(C, &vc); - - // XXX: no way currently to know state of pen flip or invert key modifier without starting a stroke - flip = 1; - - sign = flip * ((brush->flag & BRUSH_DIR_IN)? -1 : 1); - - if (sign < 0 && ELEM4(brush->sculpt_tool, SCULPT_TOOL_DRAW, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, SCULPT_TOOL_PINCH)) - col = brush->sub_col; - else - col = brush->add_col; - glTranslatef((float)x, (float)y, 0.0f); glEnable(GL_BLEND); @@ -2664,7 +2629,7 @@ static void wm_radial_control_paint(bContext *C, int x, int y, void *customdata) glEnable(GL_TEXTURE_2D); glBegin(GL_QUADS); - glColor4f(U.sculpt_paint_overlay_col[0],U.sculpt_paint_overlay_col[1],U.sculpt_paint_overlay_col[2], str); + glColor4f(rc->tex_col[0], rc->tex_col[1], rc->tex_col[2], rc->tex_col[3]); glTexCoord2f(0,0); glVertex2f(-r3, -r3); glTexCoord2f(1,0); @@ -2678,7 +2643,7 @@ static void wm_radial_control_paint(bContext *C, int x, int y, void *customdata) } if(rc->mode == WM_RADIALCONTROL_ANGLE) { - glColor4f(col[0], col[1], col[2], 0.5f); + glColor4f(rc->col[0], rc->col[1], rc->col[2], rc->col[3]); glEnable(GL_LINE_SMOOTH); glRotatef(-angle, 0, 0, 1); fdrawline(0, 0, WM_RADIAL_CONTROL_DISPLAY_SIZE, 0); @@ -2687,7 +2652,7 @@ static void wm_radial_control_paint(bContext *C, int x, int y, void *customdata) glDisable(GL_LINE_SMOOTH); } - glColor4f(col[0], col[1], col[2], 0.5f); + glColor4f(rc->col[0], rc->col[1], rc->col[2], rc->col[3]); glutil_draw_lined_arc(0.0, M_PI*2.0, r1, 40); glutil_draw_lined_arc(0.0, M_PI*2.0, r2, 40); glDisable(GL_BLEND); @@ -2702,7 +2667,7 @@ int WM_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) float dist; double new_value = RNA_float_get(op->ptr, "new_value"); int ret = OPERATOR_RUNNING_MODAL; - float initial_value = RNA_float_get(op->ptr, "initial_value"); + // float initial_value = RNA_float_get(op->ptr, "initial_value"); mode = RNA_int_get(op->ptr, "mode"); RNA_int_get_array(op->ptr, "initial_mouse", initial_mouse); @@ -2813,6 +2778,9 @@ int WM_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) MEM_freeN(im); } + RNA_float_get_array(op->ptr, "color", rc->col); + RNA_float_get_array(op->ptr, "texture_color", rc->tex_col); + RNA_int_set_array(op->ptr, "initial_mouse", mouse); RNA_float_set(op->ptr, "new_value", initial_value); @@ -2857,6 +2825,8 @@ void WM_OT_radial_control_partial(wmOperatorType *ot) {WM_RADIALCONTROL_STRENGTH, "STRENGTH", 0, "Strength", ""}, {WM_RADIALCONTROL_ANGLE, "ANGLE", 0, "Angle", ""}, {0, NULL, 0, NULL, NULL}}; + static float color[4] = {1.0f, 1.0f, 1.0f, 0.5f}; + static float tex_color[4] = {1.0f, 1.0f, 1.0f, 1.0f}; /* Should be set in custom invoke() */ RNA_def_float(ot->srna, "initial_value", 0, 0, FLT_MAX, "Initial Value", "", 0, FLT_MAX); @@ -2868,7 +2838,10 @@ void WM_OT_radial_control_partial(wmOperatorType *ot) RNA_def_enum(ot->srna, "mode", radial_mode_items, 0, "Mode", ""); /* Internal */ - RNA_def_int_vector(ot->srna, "initial_mouse", 2, NULL, INT_MIN, INT_MAX, "initial_mouse", "", INT_MIN, INT_MAX); + RNA_def_int_vector(ot->srna, "initial_mouse", 2, NULL, INT_MIN, INT_MAX, "Initial Mouse", "", INT_MIN, INT_MAX); + + RNA_def_float_color(ot->srna, "color", 4, color, 0.0f, FLT_MAX, "Color", "Radial control color", 0.0f, 1.0f); + RNA_def_float_color(ot->srna, "texture_color", 4, tex_color, 0.0f, FLT_MAX, "Texture Color", "Radial control texture color", 0.0f, 1.0f); } /* ************************** timer for testing ***************** */ @@ -2949,15 +2922,17 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) redraw_timer_window_swap(C); } else if (type==4) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); if(a & 1) scene->r.cfra--; else scene->r.cfra++; - scene_update_for_newframe(scene, scene->lay); + scene_update_for_newframe(bmain, scene, scene->lay); } else if (type==5) { /* play anim, return on same frame as started with */ + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); int tot= (scene->r.efra - scene->r.sfra) + 1; @@ -2967,7 +2942,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) if(scene->r.cfra > scene->r.efra) scene->r.cfra= scene->r.sfra; - scene_update_for_newframe(scene, scene->lay); + scene_update_for_newframe(bmain, scene, scene->lay); redraw_timer_window_swap(C); } } @@ -3263,6 +3238,8 @@ void wm_window_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "WM_OT_save_mainfile", WKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "WM_OT_save_as_mainfile", SKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); WM_keymap_add_item(keymap, "WM_OT_save_as_mainfile", F2KEY, KM_PRESS, 0, 0); + kmi= WM_keymap_add_item(keymap, "WM_OT_save_as_mainfile", SKEY, KM_PRESS, KM_ALT|KM_CTRL, 0); + RNA_boolean_set(kmi->ptr, "copy", 1); WM_keymap_verify_item(keymap, "WM_OT_window_fullscreen_toggle", F11KEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "WM_OT_exit_blender", QKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 6d01620dae8..45234464ef0 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -73,7 +73,7 @@ static int prefsizx= 0, prefsizy= 0, prefstax= 0, prefstay= 0; /* XXX this one should correctly check for apple top header... done for Cocoa : returns window contents (and not frame) max size*/ -static void wm_get_screensize(int *width_r, int *height_r) +void wm_get_screensize(int *width_r, int *height_r) { unsigned int uiwidth; unsigned int uiheight; @@ -258,7 +258,7 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win) } else { - /* this is set to 1 if you don't have .B.blend open */ + /* this is set to 1 if you don't have startup.blend open */ if(G.save_over) { char *str= MEM_mallocN(strlen(G.sce) + 16, "title"); diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h index fa244036645..d57fd0e75d8 100644 --- a/source/blender/windowmanager/wm_window.h +++ b/source/blender/windowmanager/wm_window.h @@ -36,6 +36,8 @@ struct wmOperator; void wm_ghost_init (bContext *C); void wm_ghost_exit(void); +void wm_get_screensize(int *width_r, int *height_r); + wmWindow *wm_window_new (bContext *C); void wm_window_free (bContext *C, wmWindowManager *wm, wmWindow *win); void wm_window_close (bContext *C, wmWindowManager *wm, wmWindow *win); |