From 5a90ea77bc1333efe4e1e54984a080550ed3f707 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 24 Mar 2012 06:24:53 +0000 Subject: style cleanup: follow style guide for formatting of if/for/while loops, and else if's --- source/blender/windowmanager/intern/wm.c | 66 +-- source/blender/windowmanager/intern/wm_apple.c | 3 +- source/blender/windowmanager/intern/wm_cursors.c | 43 +- source/blender/windowmanager/intern/wm_dragdrop.c | 66 +-- source/blender/windowmanager/intern/wm_draw.c | 234 ++++---- .../blender/windowmanager/intern/wm_event_system.c | 636 +++++++++++---------- source/blender/windowmanager/intern/wm_files.c | 113 ++-- source/blender/windowmanager/intern/wm_gesture.c | 73 +-- source/blender/windowmanager/intern/wm_init_exit.c | 36 +- source/blender/windowmanager/intern/wm_jobs.c | 112 ++-- source/blender/windowmanager/intern/wm_keymap.c | 270 ++++----- source/blender/windowmanager/intern/wm_operators.c | 442 +++++++------- source/blender/windowmanager/intern/wm_subwindow.c | 32 +- source/blender/windowmanager/intern/wm_window.c | 191 ++++--- 14 files changed, 1172 insertions(+), 1145 deletions(-) (limited to 'source/blender/windowmanager') diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index ea0a7388059..9fd9defc0ce 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -75,31 +75,31 @@ void WM_operator_free(wmOperator *op) { #ifdef WITH_PYTHON - if(op->py_instance) { + if (op->py_instance) { /* do this first in case there are any __del__ functions or * similar that use properties */ BPY_DECREF(op->py_instance); } #endif - if(op->ptr) { + if (op->ptr) { op->properties= op->ptr->data; MEM_freeN(op->ptr); } - if(op->properties) { + if (op->properties) { IDP_FreeProperty(op->properties); MEM_freeN(op->properties); } - if(op->reports && (op->reports->flag & RPT_FREE)) { + if (op->reports && (op->reports->flag & RPT_FREE)) { BKE_reports_clear(op->reports); MEM_freeN(op->reports); } - if(op->macro.first) { + if (op->macro.first) { wmOperator *opm, *opmnext; - for(opm= op->macro.first; opm; opm= opmnext) { + for (opm= op->macro.first; opm; opm= opmnext) { opmnext = opm->next; WM_operator_free(opm); } @@ -124,7 +124,7 @@ void wm_operator_register(bContext *C, wmOperator *op) BLI_addtail(&wm->operators, op); tot= BLI_countlist(&wm->operators); - while(tot>MAX_OP_REGISTERED) { + while (tot>MAX_OP_REGISTERED) { wmOperator *opt= wm->operators.first; BLI_remlink(&wm->operators, opt); WM_operator_free(opt); @@ -141,7 +141,7 @@ void WM_operator_stack_clear(wmWindowManager *wm) { wmOperator *op; - while((op= wm->operators.first)) { + while ((op= wm->operators.first)) { BLI_remlink(&wm->operators, op); WM_operator_free(op); } @@ -159,11 +159,11 @@ MenuType *WM_menutype_find(const char *idname, int quiet) if (idname[0]) { mt= BLI_ghash_lookup(menutypes_hash, idname); - if(mt) + if (mt) return mt; } - if(!quiet) + if (!quiet) printf("search for unknown menutype %s\n", idname); return NULL; @@ -190,9 +190,9 @@ void WM_menutype_free(void) { GHashIterator *iter= BLI_ghashIterator_new(menutypes_hash); - for( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { + for ( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { MenuType *mt= BLI_ghashIterator_getValue(iter); - if(mt->ext.free) { + if (mt->ext.free) { mt->ext.free(mt->ext.data); } } @@ -209,19 +209,19 @@ void WM_keymap_init(bContext *C) wmWindowManager *wm= CTX_wm_manager(C); /* create standard key configs */ - if(!wm->defaultconf) + if (!wm->defaultconf) wm->defaultconf= WM_keyconfig_new(wm, "Blender"); - if(!wm->addonconf) + if (!wm->addonconf) wm->addonconf= WM_keyconfig_new(wm, "Blender Addon"); - if(!wm->userconf) + if (!wm->userconf) wm->userconf= WM_keyconfig_new(wm, "Blender User"); /* initialize only after python init is done, for keymaps that * use python operators */ - if(CTX_py_init_get(C) && (wm->initialized & WM_INIT_KEYMAP) == 0) { + if (CTX_py_init_get(C) && (wm->initialized & WM_INIT_KEYMAP) == 0) { /* create default key config, only initialize once, * it's persistent across sessions */ - if(!(wm->defaultconf->flag & KEYCONF_INIT_DEFAULT)) { + if (!(wm->defaultconf->flag & KEYCONF_INIT_DEFAULT)) { wm_window_keymap(wm->defaultconf); ED_spacetypes_keymap(wm->defaultconf); @@ -240,16 +240,16 @@ void WM_check(bContext *C) wmWindowManager *wm= CTX_wm_manager(C); /* wm context */ - if(wm==NULL) { + if (wm==NULL) { wm= CTX_data_main(C)->wm.first; CTX_wm_manager_set(C, wm); } - if(wm==NULL) return; - if(wm->windows.first==NULL) return; + if (wm==NULL) return; + if (wm->windows.first==NULL) return; if (!G.background) { /* case: fileread */ - if((wm->initialized & WM_INIT_WINDOW) == 0) { + if ((wm->initialized & WM_INIT_WINDOW) == 0) { WM_keymap_init(C); WM_autosave_init(wm); } @@ -260,7 +260,7 @@ void WM_check(bContext *C) /* case: fileread */ /* note: this runs in bg mode to set the screen context cb */ - if((wm->initialized & WM_INIT_WINDOW) == 0) { + if ((wm->initialized & WM_INIT_WINDOW) == 0) { ED_screens_initialize(wm); wm->initialized |= WM_INIT_WINDOW; } @@ -272,14 +272,14 @@ void wm_clear_default_size(bContext *C) wmWindow *win; /* wm context */ - if(wm==NULL) { + if (wm==NULL) { wm= CTX_data_main(C)->wm.first; CTX_wm_manager_set(C, wm); } - if(wm==NULL) return; - if(wm->windows.first==NULL) return; + if (wm==NULL) return; + if (wm->windows.first==NULL) return; - for(win= wm->windows.first; win; win= win->next) { + for (win= wm->windows.first; win; win= win->next) { win->sizex = 0; win->sizey = 0; win->posx = 0; @@ -314,22 +314,22 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm) wmOperator *op; wmKeyConfig *keyconf; - if(wm->autosavetimer) + if (wm->autosavetimer) wm_autosave_timer_ended(wm); - while((win= wm->windows.first)) { + while ((win= wm->windows.first)) { BLI_remlink(&wm->windows, win); win->screen= NULL; /* prevent draw clear to use screen */ wm_draw_window_clear(win); wm_window_free(C, wm, win); } - while((op= wm->operators.first)) { + while ((op= wm->operators.first)) { BLI_remlink(&wm->operators, op); WM_operator_free(op); } - while((keyconf=wm->keyconfigs.first)) { + while ((keyconf=wm->keyconfigs.first)) { BLI_remlink(&wm->keyconfigs, keyconf); WM_keyconfig_free(keyconf); } @@ -341,14 +341,14 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm) wm_reports_free(wm); - if(C && CTX_wm_manager(C)==wm) CTX_wm_manager_set(C, NULL); + if (C && CTX_wm_manager(C)==wm) CTX_wm_manager_set(C, NULL); } void wm_close_and_free_all(bContext *C, ListBase *wmlist) { wmWindowManager *wm; - while((wm=wmlist->first)) { + while ((wm=wmlist->first)) { wm_close_and_free(C, wm); BLI_remlink(wmlist, wm); MEM_freeN(wm); @@ -357,7 +357,7 @@ void wm_close_and_free_all(bContext *C, ListBase *wmlist) void WM_main(bContext *C) { - while(1) { + while (1) { /* get events from ghost, handle window events, add to window queues */ wm_window_process_events(C); diff --git a/source/blender/windowmanager/intern/wm_apple.c b/source/blender/windowmanager/intern/wm_apple.c index 1b2a4e490a4..a79d20ff8b6 100644 --- a/source/blender/windowmanager/intern/wm_apple.c +++ b/source/blender/windowmanager/intern/wm_apple.c @@ -127,7 +127,8 @@ void wm_set_apple_prefsize(int scr_x, int scr_y) WM_setprefsize(left +10,scr_y - bottom +10,right-left -20,bottom - 64); G.windowstate= 0; - } else { + } + else { /* 40 + 684 + (headers) 22 + 22 = 768, the powerbook screen height */ WM_setprefsize(120, 40, 850, 684); diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index e35a1a269ae..2f0a118b54a 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -88,7 +88,8 @@ static void window_set_custom_cursor_ex(wmWindow *win, BCursor *cursor, int useB cursor->big_sizex,cursor->big_sizey, cursor->big_hotx,cursor->big_hoty, cursor->fg_color, cursor->bg_color); - } else { + } + else { GHOST_SetCustomCursorShapeEx(win->ghostwin, (GHOST_TUns8 *)cursor->small_bm, (GHOST_TUns8 *)cursor->small_mask, cursor->small_sizex,cursor->small_sizey, @@ -114,19 +115,19 @@ void WM_cursor_set(wmWindow *win, int curs) #ifdef _WIN32 /* the default win32 cross cursor is barely visible, * only 1 pixel thick, use another one instead */ - if(curs==CURSOR_EDIT) + if (curs==CURSOR_EDIT) curs= BC_CROSSCURSOR; #endif GHOST_SetCursorVisibility(win->ghostwin, 1); - if(curs == CURSOR_STD && win->modalcursor) + if (curs == CURSOR_STD && win->modalcursor) curs= win->modalcursor; win->cursor= curs; /* detect if we use system cursor or Blender cursor */ - if(curs>=BC_GHOST_CURSORS) { + if (curs>=BC_GHOST_CURSORS) { GHOST_SetCursorShape(win->ghostwin, convert_cursor(curs)); } else { @@ -146,7 +147,7 @@ void WM_cursor_set(wmWindow *win, int curs) void WM_cursor_modal(wmWindow *win, int val) { - if(win->lastcursor == 0) + if (win->lastcursor == 0) win->lastcursor = win->cursor; win->modalcursor = val; WM_cursor_set(win, val); @@ -155,7 +156,7 @@ void WM_cursor_modal(wmWindow *win, int val) void WM_cursor_restore(wmWindow *win) { win->modalcursor = 0; - if(win->lastcursor) + if (win->lastcursor) WM_cursor_set(win, win->lastcursor); win->lastcursor = 0; } @@ -163,14 +164,15 @@ void WM_cursor_restore(wmWindow *win) /* to allow usage all over, we do entire WM */ void WM_cursor_wait(int val) { - if(!G.background) { + if (!G.background) { wmWindowManager *wm= G.main->wm.first; wmWindow *win= wm?wm->windows.first:NULL; - for(; win; win= win->next) { - if(val) { + for (; win; win= win->next) { + if (val) { WM_cursor_modal(win, BC_WAITCURSOR); - } else { + } + else { WM_cursor_restore(win); } } @@ -184,8 +186,8 @@ void WM_cursor_grab(wmWindow *win, int wrap, int hide, int *bounds) * */ GHOST_TGrabCursorMode mode = GHOST_kGrabNormal; - if(hide) mode = GHOST_kGrabHide; - else if(wrap) mode = GHOST_kGrabWrap; + if (hide) mode = GHOST_kGrabHide; + else if (wrap) mode = GHOST_kGrabWrap; if ((G.f & G_DEBUG) == 0) { if (win && win->ghostwin) { const GHOST_TabletData *tabletdata= GHOST_GetTabletData(win->ghostwin); @@ -203,7 +205,7 @@ void WM_cursor_grab(wmWindow *win, int wrap, int hide, int *bounds) void WM_cursor_ungrab(wmWindow *win) { if ((G.f & G_DEBUG) == 0) { - if(win && win->ghostwin) { + if (win && win->ghostwin) { GHOST_SetCursorGrab(win->ghostwin, GHOST_kGrabDisable, NULL); win->grabcursor = GHOST_kGrabDisable; } @@ -213,18 +215,21 @@ void WM_cursor_ungrab(wmWindow *win) /* give it a modal keymap one day? */ int wm_cursor_arrow_move(wmWindow *win, wmEvent *event) { - if(win && event->val==KM_PRESS) { + if (win && event->val==KM_PRESS) { - if(event->type==UPARROWKEY) { + if (event->type==UPARROWKEY) { WM_cursor_warp(win, event->x, event->y+1); return 1; - } else if(event->type==DOWNARROWKEY) { + } + else if (event->type==DOWNARROWKEY) { WM_cursor_warp(win, event->x, event->y-1); return 1; - } else if(event->type==LEFTARROWKEY) { + } + else if (event->type==LEFTARROWKEY) { WM_cursor_warp(win, event->x-1, event->y); return 1; - } else if(event->type==RIGHTARROWKEY) { + } + else if (event->type==RIGHTARROWKEY) { WM_cursor_warp(win, event->x+1, event->y); return 1; } @@ -253,7 +258,7 @@ void WM_timecursor(wmWindow *win, int nr) unsigned char bitmap[16][2]= {{0}}; int i, idx; - if(win->lastcursor == 0) + if (win->lastcursor == 0) win->lastcursor= win->cursor; memset(&mask, 0xFF, sizeof(mask)); diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index 7f9633f939a..d60a97ad9bc 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -83,9 +83,9 @@ ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid) { wmDropBoxMap *dm; - for(dm= dropboxes.first; dm; dm= dm->next) - if(dm->spaceid==spaceid && dm->regionid==regionid) - if(0==strncmp(idname, dm->idname, KMAP_MAX_NAME)) + for (dm= dropboxes.first; dm; dm= dm->next) + if (dm->spaceid==spaceid && dm->regionid==regionid) + if (0==strncmp(idname, dm->idname, KMAP_MAX_NAME)) return &dm->dropboxes; dm= MEM_callocN(sizeof(struct wmDropBoxMap), "dropmap list"); @@ -109,7 +109,7 @@ wmDropBox *WM_dropbox_add(ListBase *lb, const char *idname, int (*poll)(bContext drop->ot= WM_operatortype_find(idname, 0); drop->opcontext= WM_OP_INVOKE_DEFAULT; - if(drop->ot==NULL) { + if (drop->ot==NULL) { MEM_freeN(drop); printf("Error: dropbox with unknown operator: %s\n", idname); return NULL; @@ -125,11 +125,11 @@ void wm_dropbox_free(void) { wmDropBoxMap *dm; - for(dm= dropboxes.first; dm; dm= dm->next) { + for (dm= dropboxes.first; dm; dm= dm->next) { wmDropBox *drop; - for(drop= dm->dropboxes.first; drop; drop= drop->next) { - if(drop->ptr) { + for (drop= dm->dropboxes.first; drop; drop= drop->next) { + if (drop->ptr) { WM_operator_properties_free(drop->ptr); MEM_freeN(drop->ptr); } @@ -154,7 +154,7 @@ wmDrag *WM_event_start_drag(struct bContext *C, int icon, int type, void *poin, BLI_addtail(&wm->drags, drag); drag->icon= icon; drag->type= type; - if(type==WM_DRAG_PATH) + if (type==WM_DRAG_PATH) BLI_strncpy(drag->path, poin, FILE_MAX); else drag->poin= poin; @@ -175,11 +175,11 @@ void WM_event_drag_image(wmDrag *drag, ImBuf *imb, float scale, int sx, int sy) static const char *dropbox_active(bContext *C, ListBase *handlers, wmDrag *drag, wmEvent *event) { wmEventHandler *handler= handlers->first; - for(; handler; handler= handler->next) { - if(handler->dropboxes) { + for (; handler; handler= handler->next) { + if (handler->dropboxes) { wmDropBox *drop= handler->dropboxes->first; - for(; drop; drop= drop->next) { - if(drop->poll(C, drag, event)) + for (; drop; drop= drop->next) { + if (drop->poll(C, drag, event)) return drop->ot->name; } } @@ -196,13 +196,13 @@ static const char *wm_dropbox_active(bContext *C, wmDrag *drag, wmEvent *event) const char *name; name= dropbox_active(C, &win->handlers, drag, event); - if(name) return name; + if (name) return name; name= dropbox_active(C, &sa->handlers, drag, event); - if(name) return name; + if (name) return name; name= dropbox_active(C, &ar->handlers, drag, event); - if(name) return name; + if (name) return name; return NULL; } @@ -213,19 +213,19 @@ static void wm_drop_operator_options(bContext *C, wmDrag *drag, wmEvent *event) wmWindow *win= CTX_wm_window(C); /* for multiwin drags, we only do this if mouse inside */ - if(event->x<0 || event->y<0 || event->x>win->sizex || event->y>win->sizey) + if (event->x<0 || event->y<0 || event->x>win->sizex || event->y>win->sizey) return; drag->opname[0]= 0; /* check buttons (XXX todo rna and value) */ - if( UI_but_active_drop_name(C) ) { + if ( UI_but_active_drop_name(C) ) { strcpy(drag->opname, "Paste name"); } else { const char *opname= wm_dropbox_active(C, drag, event); - if(opname) { + if (opname) { BLI_strncpy(drag->opname, opname, FILE_MAX); // WM_cursor_modal(win, CURSOR_COPY); } @@ -241,7 +241,7 @@ void wm_drags_check_ops(bContext *C, wmEvent *event) wmWindowManager *wm= CTX_wm_manager(C); wmDrag *drag; - for(drag= wm->drags.first; drag; drag= drag->next) { + for (drag= wm->drags.first; drag; drag= drag->next) { wm_drop_operator_options(C, drag, event); } } @@ -279,13 +279,13 @@ static const char *wm_drag_name(wmDrag *drag) static void drag_rect_minmax(rcti *rect, int x1, int y1, int x2, int y2) { - if(rect->xmin > x1) + if (rect->xmin > x1) rect->xmin = x1; - if(rect->xmax < x2) + if (rect->xmax < x2) rect->xmax = x2; - if(rect->ymin > y1) + if (rect->ymin > y1) rect->ymin = y1; - if(rect->ymax < y2) + if (rect->ymax < y2) rect->ymax = y2; } @@ -299,21 +299,21 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) cursorx= win->eventstate->x; cursory= win->eventstate->y; - if(rect) { + if (rect) { rect->xmin = rect->xmax = cursorx; rect->ymin = rect->ymax = cursory; } /* XXX todo, multiline drag draws... but maybe not, more types mixed wont work well */ glEnable(GL_BLEND); - for(drag= wm->drags.first; drag; drag= drag->next) { + for (drag= wm->drags.first; drag; drag= drag->next) { /* image or icon */ - if(drag->imb) { + if (drag->imb) { x= cursorx - drag->sx/2; y= cursory - drag->sy/2; - if(rect) + if (rect) drag_rect_minmax(rect, x, y, x+drag->sx, y+drag->sy); else { glColor4f(1.0, 1.0, 1.0, 0.65); /* this blends texture */ @@ -325,14 +325,14 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) y= cursory - 2; /* icons assumed to be 16 pixels */ - if(rect) + if (rect) drag_rect_minmax(rect, x, y, x+16, y+16); else UI_icon_draw_aspect(x, y, drag->icon, 1.0, 0.8); } /* item name */ - if(drag->imb) { + if (drag->imb) { x= cursorx - drag->sx/2; y= cursory - drag->sy/2 - 16; } @@ -341,7 +341,7 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) y= cursory + 1; } - if(rect) { + if (rect) { int w= UI_GetStringWidth(wm_drag_name(drag)); drag_rect_minmax(rect, x, y, x+w, y+16); } @@ -351,8 +351,8 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) } /* operator name with roundbox */ - if(drag->opname[0]) { - if(drag->imb) { + if (drag->opname[0]) { + if (drag->imb) { x= cursorx - drag->sx/2; y= cursory + drag->sy/2 + 4; } @@ -361,7 +361,7 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) y= cursory + 16; } - if(rect) { + if (rect) { int w= UI_GetStringWidth(wm_drag_name(drag)); drag_rect_minmax(rect, x, y, x+w, y+16); } diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 94df54dcdfc..3bf8a3ddf43 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -78,14 +78,14 @@ static void wm_paintcursor_draw(bContext *C, ARegion *ar) { wmWindowManager *wm= CTX_wm_manager(C); - if(wm->paintcursors.first) { + if (wm->paintcursors.first) { wmWindow *win= CTX_wm_window(C); bScreen *screen= win->screen; wmPaintCursor *pc; - if(screen->subwinactive == ar->swinid) { - for(pc= wm->paintcursors.first; pc; pc= pc->next) { - if(pc->poll == NULL || pc->poll(C)) { + if (screen->subwinactive == ar->swinid) { + for (pc= wm->paintcursors.first; pc; pc= pc->next) { + if (pc->poll == NULL || pc->poll(C)) { ARegion *ar_other= CTX_wm_region(C); if (ELEM(win->grabcursor, GHOST_kGrabWrap, GHOST_kGrabHide)) { int x = 0, y = 0; @@ -111,13 +111,13 @@ static void wm_paintcursor_draw(bContext *C, ARegion *ar) static void wm_area_mark_invalid_backbuf(ScrArea *sa) { - if(sa->spacetype == SPACE_VIEW3D) + if (sa->spacetype == SPACE_VIEW3D) ((View3D*)sa->spacedata.first)->flag |= V3D_INVALID_BACKBUF; } static int wm_area_test_invalid_backbuf(ScrArea *sa) { - if(sa->spacetype == SPACE_VIEW3D) + if (sa->spacetype == SPACE_VIEW3D) return (((View3D*)sa->spacedata.first)->flag & V3D_INVALID_BACKBUF); else return 1; @@ -125,11 +125,11 @@ static int wm_area_test_invalid_backbuf(ScrArea *sa) static void wm_region_test_render_do_draw(ScrArea *sa, ARegion *ar) { - if(sa->spacetype == SPACE_VIEW3D) { + if (sa->spacetype == SPACE_VIEW3D) { RegionView3D *rv3d = ar->regiondata; RenderEngine *engine = (rv3d)? rv3d->render_engine: NULL; - if(engine && (engine->flag & RE_ENGINE_DO_DRAW)) { + if (engine && (engine->flag & RE_ENGINE_DO_DRAW)) { ar->do_draw = 1; engine->flag &= ~RE_ENGINE_DO_DRAW; } @@ -146,11 +146,11 @@ static void wm_method_draw_full(bContext *C, wmWindow *win) ARegion *ar; /* draw area regions */ - for(sa= screen->areabase.first; sa; sa= sa->next) { + for (sa= screen->areabase.first; sa; sa= sa->next) { CTX_wm_area_set(C, sa); - for(ar=sa->regionbase.first; ar; ar= ar->next) { - if(ar->swinid) { + for (ar=sa->regionbase.first; ar; ar= ar->next) { + if (ar->swinid) { CTX_wm_region_set(C, ar); ED_region_do_draw(C, ar); wm_paintcursor_draw(C, ar); @@ -167,15 +167,15 @@ static void wm_method_draw_full(bContext *C, wmWindow *win) ED_area_overdraw(C); /* draw overlapping regions */ - for(ar=screen->regionbase.first; ar; ar= ar->next) { - if(ar->swinid) { + for (ar=screen->regionbase.first; ar; ar= ar->next) { + if (ar->swinid) { CTX_wm_menu_set(C, ar); ED_region_do_draw(C, ar); CTX_wm_menu_set(C, NULL); } } - if(screen->do_draw_gesture) + if (screen->do_draw_gesture) wm_gesture_draw(win); } @@ -191,9 +191,9 @@ static void wm_flush_regions_down(bScreen *screen, rcti *dirty) ScrArea *sa; ARegion *ar; - for(sa= screen->areabase.first; sa; sa= sa->next) { - for(ar= sa->regionbase.first; ar; ar= ar->next) { - if(BLI_isect_rcti(dirty, &ar->winrct, NULL)) { + for (sa= screen->areabase.first; sa; sa= sa->next) { + for (ar= sa->regionbase.first; ar; ar= ar->next) { + if (BLI_isect_rcti(dirty, &ar->winrct, NULL)) { ar->do_draw= RGN_DRAW; memset(&ar->drawrct, 0, sizeof(ar->drawrct)); ar->swap= WIN_NONE_OK; @@ -207,8 +207,8 @@ static void wm_flush_regions_up(bScreen *screen, rcti *dirty) { ARegion *ar; - for(ar= screen->regionbase.first; ar; ar= ar->next) { - if(BLI_isect_rcti(dirty, &ar->winrct, NULL)) { + for (ar= screen->regionbase.first; ar; ar= ar->next) { + if (BLI_isect_rcti(dirty, &ar->winrct, NULL)) { ar->do_draw= RGN_DRAW; memset(&ar->drawrct, 0, sizeof(ar->drawrct)); ar->swap= WIN_NONE_OK; @@ -225,58 +225,58 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange) 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)) + 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) { + if (screen->regionbase.first) { /* flush redraws of area regions up to overlapping regions */ - for(sa= screen->areabase.first; sa; sa= sa->next) - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->swinid && ar->do_draw) + for (sa= screen->areabase.first; sa; sa= sa->next) + for (ar= sa->regionbase.first; ar; ar= ar->next) + if (ar->swinid && ar->do_draw) wm_flush_regions_up(screen, &ar->winrct); /* flush between overlapping regions */ - for(ar= screen->regionbase.last; ar; ar= ar->prev) - if(ar->swinid && ar->do_draw) + for (ar= screen->regionbase.last; ar; ar= ar->prev) + if (ar->swinid && ar->do_draw) wm_flush_regions_up(screen, &ar->winrct); /* flush redraws of overlapping regions down to area regions */ - for(ar= screen->regionbase.last; ar; ar= ar->prev) - if(ar->swinid && ar->do_draw) + for (ar= screen->regionbase.last; ar; ar= ar->prev) + if (ar->swinid && ar->do_draw) wm_flush_regions_down(screen, &ar->winrct); } /* flush drag item */ - if(rect.xmin!=rect.xmax) { + if (rect.xmin!=rect.xmax) { wm_flush_regions_down(screen, &rect); rect.xmin = rect.xmax = 0; } - if(wm->drags.first) { + if (wm->drags.first) { /* doesnt draw, fills rect with boundbox */ wm_drags_draw(C, win, &rect); } /* draw marked area regions */ - for(sa= screen->areabase.first; sa; sa= sa->next) { + for (sa= screen->areabase.first; sa; sa= sa->next) { CTX_wm_area_set(C, sa); - for(ar=sa->regionbase.first; ar; ar= ar->next) { - if(ar->swinid) { - if(ar->do_draw) { + for (ar=sa->regionbase.first; ar; ar= ar->next) { + if (ar->swinid) { + if (ar->do_draw) { CTX_wm_region_set(C, ar); ED_region_do_draw(C, ar); wm_paintcursor_draw(C, ar); ED_area_overdraw_flush(sa, ar); CTX_wm_region_set(C, NULL); - if(exchange) + if (exchange) ar->swap= WIN_FRONT_OK; } - else if(exchange) { - if(ar->swap == WIN_FRONT_OK) { + else if (exchange) { + if (ar->swap == WIN_FRONT_OK) { CTX_wm_region_set(C, ar); ED_region_do_draw(C, ar); wm_paintcursor_draw(C, ar); @@ -285,9 +285,9 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange) ar->swap= WIN_BOTH_OK; } - else if(ar->swap == WIN_BACK_OK) + else if (ar->swap == WIN_BACK_OK) ar->swap= WIN_FRONT_OK; - else if(ar->swap == WIN_BOTH_OK) + else if (ar->swap == WIN_BOTH_OK) ar->swap= WIN_BOTH_OK; } } @@ -298,39 +298,39 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange) } /* after area regions so we can do area 'overlay' drawing */ - if(screen->do_draw) { + if (screen->do_draw) { ED_screen_draw(win); - if(exchange) + if (exchange) screen->swap= WIN_FRONT_OK; } - else if(exchange) { - if(screen->swap==WIN_FRONT_OK) { + else if (exchange) { + if (screen->swap==WIN_FRONT_OK) { ED_screen_draw(win); screen->swap= WIN_BOTH_OK; } - else if(screen->swap==WIN_BACK_OK) + else if (screen->swap==WIN_BACK_OK) screen->swap= WIN_FRONT_OK; - else if(screen->swap==WIN_BOTH_OK) + else if (screen->swap==WIN_BOTH_OK) screen->swap= WIN_BOTH_OK; } ED_area_overdraw(C); /* draw marked overlapping regions */ - for(ar=screen->regionbase.first; ar; ar= ar->next) { - if(ar->swinid && ar->do_draw) { + for (ar=screen->regionbase.first; ar; ar= ar->next) { + if (ar->swinid && ar->do_draw) { CTX_wm_menu_set(C, ar); ED_region_do_draw(C, ar); CTX_wm_menu_set(C, NULL); } } - if(screen->do_draw_gesture) + if (screen->do_draw_gesture) wm_gesture_draw(win); /* needs pixel coords in screen */ - if(wm->drags.first) { + if (wm->drags.first) { wm_drags_draw(C, win, NULL); } } @@ -368,13 +368,13 @@ static void split_width(int x, int n, int *splitx, int *nx) int a, newnx, waste; /* if already power of two just use it */ - if(is_power_of_2_i(x)) { + if (is_power_of_2_i(x)) { splitx[0]= x; (*nx)++; return; } - if(n == 1) { + if (n == 1) { /* last part, we have to go larger */ splitx[0]= power_of_2_max_i(x); (*nx)++; @@ -385,12 +385,12 @@ static void split_width(int x, int n, int *splitx, int *nx) newnx= ++(*nx); split_width(x-splitx[0], n-1, splitx+1, &newnx); - for(waste=0, a=0; a= power_of_2_max_i(x)) { + if (waste >= power_of_2_max_i(x)) { splitx[0]= power_of_2_max_i(x); memset(splitx+1, 0, sizeof(int)*(n-1)); } @@ -401,7 +401,7 @@ static void split_width(int x, int n, int *splitx, int *nx) static void wm_draw_triple_free(wmWindow *win) { - if(win->drawdata) { + if (win->drawdata) { wmDrawTriple *triple= win->drawdata; glDeleteTextures(triple->nx*triple->ny, triple->bind); @@ -426,14 +426,14 @@ static int wm_triple_gen_textures(wmWindow *win, wmDrawTriple *triple) int x, y; /* compute texture sizes */ - if(GLEW_ARB_texture_rectangle || GLEW_NV_texture_rectangle || GLEW_EXT_texture_rectangle) { + if (GLEW_ARB_texture_rectangle || GLEW_NV_texture_rectangle || GLEW_EXT_texture_rectangle) { triple->target= GL_TEXTURE_RECTANGLE_ARB; triple->nx= 1; triple->ny= 1; triple->x[0]= win->sizex; triple->y[0]= win->sizey; } - else if(GPU_non_power_of_two_support()) { + else if (GPU_non_power_of_two_support()) { triple->target= GL_TEXTURE_2D; triple->nx= 1; triple->ny= 1; @@ -451,19 +451,19 @@ static int wm_triple_gen_textures(wmWindow *win, wmDrawTriple *triple) /* generate texture names */ glGenTextures(triple->nx*triple->ny, triple->bind); - if(!triple->bind[0]) { + if (!triple->bind[0]) { /* not the typical failure case but we handle it anyway */ printf("WM: failed to allocate texture for triple buffer drawing (glGenTextures).\n"); return 0; } - for(y=0; yny; y++) { - for(x=0; xnx; x++) { + for (y=0; yny; y++) { + for (x=0; xnx; x++) { /* proxy texture is only guaranteed to test for the cases that * there is only one texture in use, which may not be the case */ glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxsize); - if(triple->x[x] > maxsize || triple->y[y] > maxsize) { + if (triple->x[x] > maxsize || triple->y[y] > maxsize) { glBindTexture(triple->target, 0); printf("WM: failed to allocate texture for triple buffer drawing " "(texture too large for graphics card).\n"); @@ -480,7 +480,7 @@ static int wm_triple_gen_textures(wmWindow *win, wmDrawTriple *triple) glBindTexture(triple->target, 0); /* not sure if this works everywhere .. */ - if(glGetError() == GL_OUT_OF_MEMORY) { + if (glGetError() == GL_OUT_OF_MEMORY) { printf("WM: failed to allocate texture for triple buffer drawing (out of memory).\n"); return 0; } @@ -497,8 +497,8 @@ static void wm_triple_draw_textures(wmWindow *win, wmDrawTriple *triple) glEnable(triple->target); - for(y=0, offy=0; yny; offy+=triple->y[y], y++) { - for(x=0, offx=0; xnx; offx+=triple->x[x], x++) { + for (y=0, offy=0; yny; offy+=triple->y[y], y++) { + for (x=0, offx=0; xnx; offx+=triple->x[x], x++) { sizex= (x == triple->nx-1)? win->sizex-offx: triple->x[x]; sizey= (y == triple->ny-1)? win->sizey-offy: triple->y[y]; @@ -509,7 +509,7 @@ static void wm_triple_draw_textures(wmWindow *win, wmDrawTriple *triple) halfy= 0.375f; /* texture rectangle has unnormalized coordinates */ - if(triple->target == GL_TEXTURE_2D) { + if (triple->target == GL_TEXTURE_2D) { ratiox /= triple->x[x]; ratioy /= triple->y[y]; halfx /= triple->x[x]; @@ -543,8 +543,8 @@ static void wm_triple_copy_textures(wmWindow *win, wmDrawTriple *triple) { int x, y, sizex, sizey, offx, offy; - for(y=0, offy=0; yny; offy+=triple->y[y], y++) { - for(x=0, offx=0; xnx; offx+=triple->x[x], x++) { + for (y=0, offy=0; yny; offy+=triple->y[y], y++) { + for (x=0, offx=0; xnx; offx+=triple->x[x], x++) { sizex= (x == triple->nx-1)? win->sizex-offx: triple->x[x]; sizey= (y == triple->ny-1)? win->sizey-offy: triple->y[y]; @@ -565,7 +565,7 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win) ARegion *ar; int copytex= 0, paintcursor= 1; - if(win->drawdata) { + if (win->drawdata) { glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); @@ -576,7 +576,7 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win) else { win->drawdata= MEM_callocN(sizeof(wmDrawTriple), "wmDrawTriple"); - if(!wm_triple_gen_textures(win, win->drawdata)) { + if (!wm_triple_gen_textures(win, win->drawdata)) { wm_draw_triple_fail(C, win); return; } @@ -585,11 +585,11 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win) triple= win->drawdata; /* draw marked area regions */ - for(sa= screen->areabase.first; sa; sa= sa->next) { + for (sa= screen->areabase.first; sa; sa= sa->next) { CTX_wm_area_set(C, sa); - for(ar=sa->regionbase.first; ar; ar= ar->next) { - if(ar->swinid && ar->do_draw) { + for (ar=sa->regionbase.first; ar; ar= ar->next) { + if (ar->swinid && ar->do_draw) { CTX_wm_region_set(C, ar); ED_region_do_draw(C, ar); ED_area_overdraw_flush(sa, ar); @@ -602,7 +602,7 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win) CTX_wm_area_set(C, NULL); } - if(copytex) { + if (copytex) { wmSubWindowSet(win, screen->mainwin); ED_area_overdraw(C); @@ -613,8 +613,8 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win) ED_screen_draw(win); /* draw overlapping regions */ - for(ar=screen->regionbase.first; ar; ar= ar->next) { - if(ar->swinid) { + for (ar=screen->regionbase.first; ar; ar= ar->next) { + if (ar->swinid) { CTX_wm_menu_set(C, ar); ED_region_do_draw(C, ar); CTX_wm_menu_set(C, NULL); @@ -624,13 +624,13 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win) } /* always draw, not only when screen tagged */ - if(win->gesture.first) + if (win->gesture.first) wm_gesture_draw(win); - if(paintcursor && wm->paintcursors.first) { - for(sa= screen->areabase.first; sa; sa= sa->next) { - for(ar=sa->regionbase.first; ar; ar= ar->next) { - if(ar->swinid == screen->subwinactive) { + if (paintcursor && wm->paintcursors.first) { + for (sa= screen->areabase.first; sa; sa= sa->next) { + for (ar=sa->regionbase.first; ar; ar= ar->next) { + if (ar->swinid == screen->subwinactive) { CTX_wm_area_set(C, sa); CTX_wm_region_set(C, ar); @@ -648,7 +648,7 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win) } /* needs pixel coords in screen */ - if(wm->drags.first) { + if (wm->drags.first) { wm_drags_draw(C, win, NULL); } @@ -663,36 +663,36 @@ static int wm_draw_update_test_window(wmWindow *win) ARegion *ar; int do_draw= 0; - for(ar= win->screen->regionbase.first; ar; ar= ar->next) { - if(ar->do_draw_overlay) { + for (ar= win->screen->regionbase.first; ar; ar= ar->next) { + if (ar->do_draw_overlay) { wm_tag_redraw_overlay(win, ar); ar->do_draw_overlay= 0; } - if(ar->swinid && ar->do_draw) + if (ar->swinid && ar->do_draw) do_draw= 1; } - for(sa= win->screen->areabase.first; sa; sa= sa->next) { - for(ar=sa->regionbase.first; ar; ar= ar->next) { + for (sa= win->screen->areabase.first; sa; sa= sa->next) { + for (ar=sa->regionbase.first; ar; ar= ar->next) { wm_region_test_render_do_draw(sa, ar); - if(ar->swinid && ar->do_draw) + if (ar->swinid && ar->do_draw) do_draw = 1; } } - if(do_draw) + if (do_draw) return 1; - if(win->screen->do_refresh) + if (win->screen->do_refresh) return 1; - if(win->screen->do_draw) + if (win->screen->do_draw) return 1; - if(win->screen->do_draw_gesture) + if (win->screen->do_draw_gesture) return 1; - if(win->screen->do_draw_paintcursor) + if (win->screen->do_draw_paintcursor) return 1; - if(win->screen->do_draw_drag) + if (win->screen->do_draw_drag) return 1; return 0; @@ -705,24 +705,24 @@ static int wm_automatic_draw_method(wmWindow *win) * 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) { + 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)) + 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)) + 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)) + 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)) + 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)) + else if (GPU_type_matches(GPU_DEVICE_SOFTWARE, GPU_OS_WIN, GPU_DRIVER_SOFTWARE)) return USER_DRAW_OVERLAP_FLIP; - else if(GPU_type_matches(GPU_DEVICE_SOFTWARE, GPU_OS_UNIX, GPU_DRIVER_SOFTWARE)) + else if (GPU_type_matches(GPU_DEVICE_SOFTWARE, GPU_OS_UNIX, GPU_DRIVER_SOFTWARE)) return USER_DRAW_OVERLAP; /* drawing lower color depth again degrades colors each time */ - else if(GPU_color_depth() < 24) + else if (GPU_color_depth() < 24) return USER_DRAW_OVERLAP; else return USER_DRAW_TRIPLE; @@ -734,8 +734,8 @@ static int wm_automatic_draw_method(wmWindow *win) void wm_tag_redraw_overlay(wmWindow *win, ARegion *ar) { /* for draw triple gestures, paint cursors don't need region redraw */ - if(ar && win) { - if(wm_automatic_draw_method(win) != USER_DRAW_TRIPLE) + if (ar && win) { + if (wm_automatic_draw_method(win) != USER_DRAW_TRIPLE) ED_region_tag_redraw(ar); win->screen->do_draw_paintcursor= 1; } @@ -749,31 +749,31 @@ void wm_draw_update(bContext *C) GPU_free_unused_buffers(); - for(win= wm->windows.first; win; win= win->next) { - if(win->drawmethod != U.wmdrawmethod) { + for (win= wm->windows.first; win; win= win->next) { + if (win->drawmethod != U.wmdrawmethod) { wm_draw_window_clear(win); win->drawmethod= U.wmdrawmethod; } - if(wm_draw_update_test_window(win)) { + if (wm_draw_update_test_window(win)) { CTX_wm_window_set(C, win); /* sets context window+screen */ wm_window_make_drawable(C, win); /* notifiers for screen redraw */ - if(win->screen->do_refresh) + if (win->screen->do_refresh) ED_screen_refresh(wm, win); drawmethod= wm_automatic_draw_method(win); - if(win->drawfail) + if (win->drawfail) wm_method_draw_overlap_all(C, win, 0); - else if(drawmethod == USER_DRAW_FULL) + else if (drawmethod == USER_DRAW_FULL) wm_method_draw_full(C, win); - else if(drawmethod == USER_DRAW_OVERLAP) + else if (drawmethod == USER_DRAW_OVERLAP) wm_method_draw_overlap_all(C, win, 0); - else if(drawmethod == USER_DRAW_OVERLAP_FLIP) + else if (drawmethod == USER_DRAW_OVERLAP_FLIP) wm_method_draw_overlap_all(C, win, 1); else // if(drawmethod == USER_DRAW_TRIPLE) wm_method_draw_triple(C, win); @@ -796,13 +796,13 @@ void wm_draw_window_clear(wmWindow *win) ARegion *ar; int drawmethod= wm_automatic_draw_method(win); - if(drawmethod == USER_DRAW_TRIPLE) + if (drawmethod == USER_DRAW_TRIPLE) wm_draw_triple_free(win); /* clear screen swap flags */ - if(screen) { - for(sa= screen->areabase.first; sa; sa= sa->next) - for(ar=sa->regionbase.first; ar; ar= ar->next) + if (screen) { + for (sa= screen->areabase.first; sa; sa= sa->next) + for (ar=sa->regionbase.first; ar; ar= ar->next) ar->swap= WIN_NONE_OK; screen->swap= WIN_NONE_OK; @@ -813,7 +813,7 @@ void wm_draw_region_clear(wmWindow *win, ARegion *ar) { int drawmethod= wm_automatic_draw_method(win); - if(ELEM(drawmethod, USER_DRAW_OVERLAP, USER_DRAW_OVERLAP_FLIP)) + if (ELEM(drawmethod, USER_DRAW_OVERLAP, USER_DRAW_OVERLAP_FLIP)) wm_flush_regions_down(win->screen, &ar->winrct); win->screen->do_draw= 1; diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 565b86f6a5f..962a59496ef 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -97,10 +97,10 @@ void wm_event_add(wmWindow *win, wmEvent *event_to_add) void wm_event_free(wmEvent *event) { - if(event->customdata) { - if(event->customdatafree) { + if (event->customdata) { + if (event->customdatafree) { /* note: pointer to listbase struct elsewhere */ - if(event->custom==EVT_DATA_LISTBASE) + if (event->custom==EVT_DATA_LISTBASE) BLI_freelistN(event->customdata); else MEM_freeN(event->customdata); @@ -113,7 +113,7 @@ void wm_event_free_all(wmWindow *win) { wmEvent *event; - while((event= win->queue.first)) { + while ((event= win->queue.first)) { BLI_remlink(&win->queue, event); wm_event_free(event); } @@ -125,8 +125,8 @@ static int wm_test_duplicate_notifier(wmWindowManager *wm, unsigned int type, vo { wmNotifier *note; - for(note=wm->queue.first; note; note=note->next) - if((note->category|note->data|note->subtype|note->action) == type && note->reference == reference) + for (note=wm->queue.first; note; note=note->next) + if ((note->category|note->data|note->subtype|note->action) == type && note->reference == reference) return 1; return 0; @@ -142,7 +142,7 @@ void WM_event_add_notifier(const bContext *C, unsigned int type, void *reference note->window= CTX_wm_window(C); - if(CTX_wm_region(C)) + if (CTX_wm_region(C)) note->swinid= CTX_wm_region(C)->swinid; note->category= type & NOTE_CATEGORY; @@ -158,7 +158,7 @@ void WM_main_add_notifier(unsigned int type, void *reference) Main *bmain= G.main; wmWindowManager *wm= bmain->wm.first; - if(wm && !wm_test_duplicate_notifier(wm, type, reference)) { + if (wm && !wm_test_duplicate_notifier(wm, type, reference)) { wmNotifier *note= MEM_callocN(sizeof(wmNotifier), "notifier"); note->wm= wm; @@ -177,7 +177,7 @@ static wmNotifier *wm_notifier_next(wmWindowManager *wm) { wmNotifier *note= wm->queue.first; - if(note) BLI_remlink(&wm->queue, note); + if (note) BLI_remlink(&wm->queue, note); return note; } @@ -189,36 +189,36 @@ void wm_event_do_notifiers(bContext *C) wmWindow *win; uint64_t win_combine_v3d_datamask= 0; - if(wm==NULL) + if (wm==NULL) return; /* cache & catch WM level notifiers, such as frame change, scene/screen set */ - for(win= wm->windows.first; win; win= win->next) { + for (win= wm->windows.first; win; win= win->next) { int do_anim= 0; CTX_wm_window_set(C, win); - for(note= wm->queue.first; note; note= next) { + for (note= wm->queue.first; note; note= next) { next= note->next; - if(note->category==NC_WM) { - if( ELEM(note->data, ND_FILEREAD, ND_FILESAVE)) { + if (note->category==NC_WM) { + if ( ELEM(note->data, ND_FILEREAD, ND_FILESAVE)) { wm->file_saved= 1; wm_window_title(wm, win); } - else if(note->data==ND_DATACHANGED) + else if (note->data==ND_DATACHANGED) wm_window_title(wm, win); } - if(note->window==win) { - if(note->category==NC_SCREEN) { - if(note->data==ND_SCREENBROWSE) { + if (note->window==win) { + if (note->category==NC_SCREEN) { + if (note->data==ND_SCREENBROWSE) { ED_screen_set(C, note->reference); // XXX hrms, think this over! - if(G.f & G_DEBUG) + if (G.f & G_DEBUG) printf("screen set %p\n", note->reference); } - else if(note->data==ND_SCREENDELETE) { + else if (note->data==ND_SCREENDELETE) { ED_screen_delete(C, note->reference); // XXX hrms, think this over! - if(G.f & G_DEBUG) + if (G.f & G_DEBUG) printf("screen delete %p\n", note->reference); } } @@ -227,22 +227,22 @@ void wm_event_do_notifiers(bContext *C) if (note->window == win || (note->window == NULL && (note->reference == NULL || note->reference == CTX_data_scene(C)))) { - if(note->category==NC_SCENE) { - if(note->data==ND_FRAME) + if (note->category==NC_SCENE) { + if (note->data==ND_FRAME) do_anim= 1; } } - if(ELEM5(note->category, NC_SCENE, NC_OBJECT, NC_GEOM, NC_SCENE, NC_WM)) { + if (ELEM5(note->category, NC_SCENE, NC_OBJECT, NC_GEOM, NC_SCENE, NC_WM)) { ED_info_stats_clear(CTX_data_scene(C)); WM_event_add_notifier(C, NC_SPACE|ND_SPACE_INFO, NULL); } } - if(do_anim) { + if (do_anim) { /* XXX, quick frame changes can cause a crash if framechange and rendering * collide (happens on slow scenes), scene_update_for_newframe can be called * twice which can depgraph update the same object at once */ - if(!G.rendering) { + if (!G.rendering) { /* depsgraph gets called, might send more notifiers */ ED_update_for_newframe(CTX_data_main(C), win->screen->scene, win->screen, 1); @@ -251,12 +251,12 @@ void wm_event_do_notifiers(bContext *C) } /* the notifiers are sent without context, to keep it clean */ - while( (note=wm_notifier_next(wm)) ) { - for(win= wm->windows.first; win; win= win->next) { + while ( (note=wm_notifier_next(wm)) ) { + for (win= wm->windows.first; win; win= win->next) { /* filter out notifiers */ - if(note->category==NC_SCREEN && note->reference && note->reference!=win->screen); - else if(note->category==NC_SCENE && note->reference && note->reference!=win->screen->scene); + if (note->category==NC_SCREEN && note->reference && note->reference!=win->screen); + else if (note->category==NC_SCENE && note->reference && note->reference!=win->screen->scene); else { ScrArea *sa; ARegion *ar; @@ -267,13 +267,13 @@ void wm_event_do_notifiers(bContext *C) /* printf("notifier win %d screen %s cat %x\n", win->winid, win->screen->id.name+2, note->category); */ ED_screen_do_listen(C, note); - for(ar=win->screen->regionbase.first; ar; ar= ar->next) { + for (ar=win->screen->regionbase.first; ar; ar= ar->next) { ED_region_do_listen(ar, note); } - for(sa= win->screen->areabase.first; sa; sa= sa->next) { + for (sa= win->screen->areabase.first; sa; sa= sa->next) { ED_area_do_listen(sa, note); - for(ar=sa->regionbase.first; ar; ar= ar->next) { + for (ar=sa->regionbase.first; ar; ar= ar->next) { ED_region_do_listen(ar, note); } } @@ -284,24 +284,24 @@ void wm_event_do_notifiers(bContext *C) } /* combine datamasks so 1 win doesn't disable UV's in another [#26448] */ - for(win= wm->windows.first; win; win= win->next) { + for (win= wm->windows.first; win; win= win->next) { win_combine_v3d_datamask |= ED_view3d_screen_datamask(win->screen); } /* cached: editor refresh callbacks now, they get context */ - for(win= wm->windows.first; win; win= win->next) { + for (win= wm->windows.first; win; win= win->next) { ScrArea *sa; CTX_wm_window_set(C, win); - for(sa= win->screen->areabase.first; sa; sa= sa->next) { - if(sa->do_refresh) { + for (sa= win->screen->areabase.first; sa; sa= sa->next) { + if (sa->do_refresh) { CTX_wm_area_set(C, sa); ED_area_do_refresh(C, sa); } } /* XXX make lock in future, or separated derivedmesh users in scene */ - if(!G.rendering) { + if (!G.rendering) { /* depsgraph & animation: update tagged datablocks */ Main *bmain = CTX_data_main(C); @@ -337,22 +337,22 @@ static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, wmEvent *eve /* UI is quite aggressive with swallowing events, like scrollwheel */ /* I realize this is not extremely nice code... when UI gets keymaps it can be maybe smarter */ - if(do_wheel_ui==0) { - if(is_wheel) + if (do_wheel_ui==0) { + if (is_wheel) return WM_HANDLER_CONTINUE; - else if(wm_event_always_pass(event)==0) + else if (wm_event_always_pass(event)==0) do_wheel_ui= 1; } /* we set context to where ui handler came from */ - if(handler->ui_area) CTX_wm_area_set(C, handler->ui_area); - if(handler->ui_region) CTX_wm_region_set(C, handler->ui_region); - if(handler->ui_menu) CTX_wm_menu_set(C, handler->ui_menu); + if (handler->ui_area) CTX_wm_area_set(C, handler->ui_area); + if (handler->ui_region) CTX_wm_region_set(C, handler->ui_region); + if (handler->ui_menu) CTX_wm_menu_set(C, handler->ui_menu); retval= handler->ui_handle(C, event, handler->ui_userdata); /* putting back screen context */ - if((retval != WM_UI_HANDLER_BREAK) || always_pass) { + if ((retval != WM_UI_HANDLER_BREAK) || always_pass) { CTX_wm_area_set(C, area); CTX_wm_region_set(C, region); CTX_wm_menu_set(C, menu); @@ -364,11 +364,11 @@ static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, wmEvent *eve CTX_wm_menu_set(C, NULL); } - if(retval == WM_UI_HANDLER_BREAK) + if (retval == WM_UI_HANDLER_BREAK) return WM_HANDLER_BREAK; /* event not handled in UI, if wheel then we temporarily disable it */ - if(is_wheel) + if (is_wheel) do_wheel_ui= 0; return WM_HANDLER_CONTINUE; @@ -380,13 +380,13 @@ static void wm_handler_ui_cancel(bContext *C) ARegion *ar= CTX_wm_region(C); wmEventHandler *handler, *nexthandler; - if(!ar) + if (!ar) return; - for(handler= ar->handlers.first; handler; handler= nexthandler) { + for (handler= ar->handlers.first; handler; handler= nexthandler) { nexthandler= handler->next; - if(handler->ui_handle) { + if (handler->ui_handle) { wmEvent event= *(win->eventstate); event.type= EVT_BUT_CANCEL; handler->ui_handle(C, &event, handler->ui_userdata); @@ -400,17 +400,17 @@ int WM_operator_poll(bContext *C, wmOperatorType *ot) { wmOperatorTypeMacro *otmacro; - for(otmacro= ot->macro.first; otmacro; otmacro= otmacro->next) { + for (otmacro= ot->macro.first; otmacro; otmacro= otmacro->next) { wmOperatorType *ot_macro= WM_operatortype_find(otmacro->idname, 0); - if(0==WM_operator_poll(C, ot_macro)) + if (0==WM_operator_poll(C, ot_macro)) return 0; } /* python needs operator type, so we added exception for it */ - if(ot->pyop_poll) + if (ot->pyop_poll) return ot->pyop_poll(C, ot); - else if(ot->poll) + else if (ot->poll) return ot->poll(C); return 1; @@ -435,7 +435,7 @@ static void wm_operator_print(bContext *C, wmOperator *op) void WM_event_print(wmEvent *event) { - if(event) { + if (event) { const char *unknown= "UNKNOWN"; const char *type_id= unknown; const char *val_id= unknown; @@ -464,13 +464,13 @@ void WM_event_print(wmEvent *event) static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int caller_owns_reports) { if (caller_owns_reports == FALSE) { /* popup */ - if(op->reports->list.first) { + if (op->reports->list.first) { /* FIXME, temp setting window, see other call to uiPupMenuReports for why */ wmWindow *win_prev= CTX_wm_window(C); ScrArea *area_prev= CTX_wm_area(C); ARegion *ar_prev= CTX_wm_region(C); - if(win_prev==NULL) + if (win_prev==NULL) CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first); uiPupMenuReports(C, op->reports); @@ -481,8 +481,8 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int cal } } - if(retval & OPERATOR_FINISHED) { - if(G.f & G_DEBUG) { + if (retval & OPERATOR_FINISHED) { + if (G.f & G_DEBUG) { /* todo - this print may double up, might want to check more flags then the FINISHED */ wm_operator_print(C, op); } @@ -492,7 +492,7 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int cal } if (op->type->flag & OPTYPE_REGISTER) { - if(G.background == 0) { /* ends up printing these in the terminal, gets annoying */ + if (G.background == 0) { /* ends up printing these in the terminal, gets annoying */ /* Report the python string representation of the operator */ char *buf = WM_operator_pystring(C, op->type, op->ptr, 1); BKE_report(CTX_wm_reports(C), RPT_OPERATOR, buf); @@ -539,18 +539,18 @@ static void wm_operator_finished(bContext *C, wmOperator *op, int repeat) /* we don't want to do undo pushes for operators that are being * called from operators that already do an undo push. usually * this will happen for python operators that call C operators */ - if(wm->op_undo_depth == 0) - if(op->type->flag & OPTYPE_UNDO) + if (wm->op_undo_depth == 0) + if (op->type->flag & OPTYPE_UNDO) ED_undo_push_op(C, op); - if(repeat==0) { - if(G.f & G_DEBUG) { + if (repeat==0) { + if (G.f & G_DEBUG) { char *buf = WM_operator_pystring(C, op->type, op->ptr, 1); BKE_report(CTX_wm_reports(C), RPT_OPERATOR, buf); MEM_freeN(buf); } - if(wm_operator_register_check(wm, op->type)) + if (wm_operator_register_check(wm, op->type)) wm_operator_register(C, op); else WM_operator_free(op); @@ -565,27 +565,27 @@ static int wm_operator_exec(bContext *C, wmOperator *op, int repeat) CTX_wm_operator_poll_msg_set(C, NULL); - if(op==NULL || op->type==NULL) + if (op==NULL || op->type==NULL) return retval; - if(0==WM_operator_poll(C, op->type)) + if (0==WM_operator_poll(C, op->type)) return retval; - if(op->type->exec) { - if(op->type->flag & OPTYPE_UNDO) + if (op->type->exec) { + if (op->type->flag & OPTYPE_UNDO) wm->op_undo_depth++; retval= op->type->exec(C, op); OPERATOR_RETVAL_CHECK(retval); - if(op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm) + if (op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm) wm->op_undo_depth--; } if (retval & (OPERATOR_FINISHED|OPERATOR_CANCELLED) && repeat == 0) wm_operator_reports(C, op, retval, FALSE); - if(retval & OPERATOR_FINISHED) { + if (retval & OPERATOR_FINISHED) { if (repeat) { if (wm->op_undo_depth == 0) { /* not called by py script */ WM_operator_last_properties_store(op); @@ -593,7 +593,7 @@ static int wm_operator_exec(bContext *C, wmOperator *op, int repeat) } wm_operator_finished(C, op, repeat); } - else if(repeat==0) { + else if (repeat==0) { WM_operator_free(op); } @@ -606,7 +606,7 @@ static int wm_operator_exec_notest(bContext *C, wmOperator *op) { int retval= OPERATOR_CANCELLED; - if(op==NULL || op->type==NULL || op->type->exec==NULL) + if (op==NULL || op->type==NULL || op->type->exec==NULL) return retval; retval= op->type->exec(C, op); @@ -656,7 +656,7 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, wmOperatorType *ot, P /* initialize properties, either copy or create */ op->ptr= MEM_callocN(sizeof(PointerRNA), "wmOperatorPtrRNA"); - if(properties && properties->data) { + if (properties && properties->data) { op->properties= IDP_CopyProperty(properties->data); } else { @@ -675,13 +675,13 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, wmOperatorType *ot, P } /* recursive filling of operator macro list */ - if(ot->macro.first) { + if (ot->macro.first) { static wmOperator *motherop= NULL; wmOperatorTypeMacro *otmacro; int root = 0; /* ensure all ops are in execution order in 1 list */ - if(motherop==NULL) { + if (motherop==NULL) { motherop = op; root = 1; } @@ -711,7 +711,8 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, wmOperatorType *ot, P } } RNA_STRUCT_END; - } else { + } + else { for (otmacro = ot->macro.first; otmacro; otmacro = otmacro->next) { wmOperatorType *otm= WM_operatortype_find(otmacro->idname, 0); wmOperator *opm= wm_operator_create(wm, otm, otmacro->ptr, NULL); @@ -733,7 +734,7 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, wmOperatorType *ot, P static void wm_region_mouse_co(bContext *C, wmEvent *event) { ARegion *ar= CTX_wm_region(C); - if(ar) { + if (ar) { /* compatibility convention */ event->mval[0]= event->x - ar->winrct.xmin; event->mval[1]= event->y - ar->winrct.ymin; @@ -758,11 +759,11 @@ int WM_operator_last_properties_init(wmOperator *op) RNA_PROP_BEGIN(op->ptr, itemptr, iterprop) { PropertyRNA *prop= itemptr.data; - if((RNA_property_flag(prop) & PROP_SKIP_SAVE) == 0) { + if ((RNA_property_flag(prop) & PROP_SKIP_SAVE) == 0) { if (!RNA_property_is_set(op->ptr, prop)) { /* don't override a setting already set */ const char *identifier= RNA_property_identifier(prop); IDProperty *idp_src= IDP_GetPropertyFromGroup(op->type->last_properties, identifier); - if(idp_src) { + if (idp_src) { IDProperty *idp_dst = IDP_CopyProperty(idp_src); /* note - in the future this may need to be done recursively, @@ -805,41 +806,41 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P int retval= OPERATOR_PASS_THROUGH; /* this is done because complicated setup is done to call this function that is better not duplicated */ - if(poll_only) + if (poll_only) return WM_operator_poll(C, ot); - if(WM_operator_poll(C, ot)) { + if (WM_operator_poll(C, ot)) { wmOperator *op= wm_operator_create(wm, ot, properties, reports); /* if reports==NULL, theyll be initialized */ const short is_nested_call = (wm->op_undo_depth != 0); /* initialize setting from previous run */ - if(!is_nested_call) { /* not called by py script */ + if (!is_nested_call) { /* not called by py script */ WM_operator_last_properties_init(op); } - if((G.f & G_DEBUG) && event && event->type!=MOUSEMOVE) + if ((G.f & G_DEBUG) && event && event->type!=MOUSEMOVE) printf("handle evt %d win %d op %s\n", event?event->type:0, CTX_wm_screen(C)->subwinactive, ot->idname); - if(op->type->invoke && event) { + if (op->type->invoke && event) { wm_region_mouse_co(C, event); - if(op->type->flag & OPTYPE_UNDO) + if (op->type->flag & OPTYPE_UNDO) wm->op_undo_depth++; retval= op->type->invoke(C, op, event); OPERATOR_RETVAL_CHECK(retval); - if(op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm) + if (op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm) wm->op_undo_depth--; } - else if(op->type->exec) { - if(op->type->flag & OPTYPE_UNDO) + else if (op->type->exec) { + if (op->type->flag & OPTYPE_UNDO) wm->op_undo_depth++; retval= op->type->exec(C, op); OPERATOR_RETVAL_CHECK(retval); - if(op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm) + if (op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm) wm->op_undo_depth--; } else { @@ -854,19 +855,19 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P wm_operator_reports(C, op, retval, (reports != NULL)); } - if(retval & OPERATOR_HANDLED) + if (retval & OPERATOR_HANDLED) ; /* do nothing, wm_operator_exec() has been called somewhere */ - else if(retval & OPERATOR_FINISHED) { + else if (retval & OPERATOR_FINISHED) { if (!is_nested_call) { /* not called by py script */ WM_operator_last_properties_store(op); } wm_operator_finished(C, op, 0); } - else if(retval & OPERATOR_RUNNING_MODAL) { + else if (retval & OPERATOR_RUNNING_MODAL) { /* grab cursor during blocking modal ops (X11) * Also check for macro */ - if(ot->flag & OPTYPE_BLOCKING || (op->opm && op->opm->type->flag & OPTYPE_BLOCKING)) { + if (ot->flag & OPTYPE_BLOCKING || (op->opm && op->opm->type->flag & OPTYPE_BLOCKING)) { int bounds[4] = {-1,-1,-1,-1}; int wrap; @@ -880,14 +881,14 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P } /* exception, cont. grab in header is annoying */ - if(wrap) { + if (wrap) { ARegion *ar= CTX_wm_region(C); - if(ar && ar->regiontype == RGN_TYPE_HEADER) { + if (ar && ar->regiontype == RGN_TYPE_HEADER) { wrap= FALSE; } } - if(wrap) { + if (wrap) { rcti *winrect= NULL; ARegion *ar= CTX_wm_region(C); ScrArea *sa= CTX_wm_area(C); @@ -897,11 +898,11 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P { winrect= &ar->winrct; } - else if(sa) { + else if (sa) { winrect= &sa->totrct; } - if(winrect) { + if (winrect) { bounds[0]= winrect->xmin; bounds[1]= winrect->ymax; bounds[2]= winrect->xmax; @@ -940,7 +941,7 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA CTX_wm_operator_poll_msg_set(C, NULL); /* dummie test */ - if(ot && C) { + if (ot && C) { switch(context) { case WM_OP_INVOKE_DEFAULT: case WM_OP_INVOKE_REGION_WIN: @@ -990,9 +991,9 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA break; } - if(!(ar && ar->regiontype == type) && area) { + if (!(ar && ar->regiontype == type) && area) { ARegion *ar1= BKE_area_find_region_type(area, type); - if(ar1) + if (ar1) CTX_wm_region_set(C, ar1); } @@ -1044,7 +1045,7 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA int WM_operator_name_call(bContext *C, const char *opstring, int context, PointerRNA *properties) { wmOperatorType *ot= WM_operatortype_find(opstring, 0); - if(ot) + if (ot) return wm_operator_call_internal(C, ot, properties, NULL, context, FALSE); return 0; @@ -1064,13 +1065,13 @@ int WM_operator_call_py(bContext *C, wmOperatorType *ot, int context, PointerRNA op= wm_operator_create(wm, ot, properties, reports); if (op->type->exec) { - if(op->type->flag & OPTYPE_UNDO) + if (op->type->flag & OPTYPE_UNDO) wm->op_undo_depth++; retval= op->type->exec(C, op); OPERATOR_RETVAL_CHECK(retval); - if(op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm) + if (op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm) wm->op_undo_depth--; } else @@ -1113,29 +1114,29 @@ static void wm_handler_op_context(bContext *C, wmEventHandler *handler) { bScreen *screen= CTX_wm_screen(C); - if(screen && handler->op) { - if(handler->op_area==NULL) + if (screen && handler->op) { + if (handler->op_area==NULL) CTX_wm_area_set(C, NULL); else { ScrArea *sa; - for(sa= screen->areabase.first; sa; sa= sa->next) - if(sa==handler->op_area) + for (sa= screen->areabase.first; sa; sa= sa->next) + if (sa==handler->op_area) break; - if(sa==NULL) { + if (sa==NULL) { /* when changing screen layouts with running modal handlers (like render display), this * is not an error to print */ - if(handler->op==NULL) + if (handler->op==NULL) printf("internal error: handler (%s) has invalid area\n", handler->op->type->idname); } else { ARegion *ar; CTX_wm_area_set(C, sa); - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar==handler->op_region) + for (ar= sa->regionbase.first; ar; ar= ar->next) + if (ar==handler->op_region) break; /* XXX no warning print here, after full-area and back regions are remade */ - if(ar) + if (ar) CTX_wm_region_set(C, ar); } } @@ -1149,22 +1150,22 @@ void WM_event_remove_handlers(bContext *C, ListBase *handlers) wmWindowManager *wm= CTX_wm_manager(C); /* C is zero on freeing database, modal handlers then already were freed */ - while((handler=handlers->first)) { + while ((handler=handlers->first)) { BLI_remlink(handlers, handler); - if(handler->op) { - if(handler->op->type->cancel) { + if (handler->op) { + if (handler->op->type->cancel) { ScrArea *area= CTX_wm_area(C); ARegion *region= CTX_wm_region(C); wm_handler_op_context(C, handler); - if(handler->op->type->flag & OPTYPE_UNDO) + if (handler->op->type->flag & OPTYPE_UNDO) wm->op_undo_depth++; handler->op->type->cancel(C, handler->op); - if(handler->op->type->flag & OPTYPE_UNDO) + if (handler->op->type->flag & OPTYPE_UNDO) wm->op_undo_depth--; CTX_wm_area_set(C, area); @@ -1174,14 +1175,14 @@ void WM_event_remove_handlers(bContext *C, ListBase *handlers) WM_cursor_ungrab(CTX_wm_window(C)); WM_operator_free(handler->op); } - else if(handler->ui_remove) { + else if (handler->ui_remove) { ScrArea *area= CTX_wm_area(C); ARegion *region= CTX_wm_region(C); ARegion *menu= CTX_wm_menu(C); - if(handler->ui_area) CTX_wm_area_set(C, handler->ui_area); - if(handler->ui_region) CTX_wm_region_set(C, handler->ui_region); - if(handler->ui_menu) CTX_wm_menu_set(C, handler->ui_menu); + if (handler->ui_area) CTX_wm_area_set(C, handler->ui_area); + if (handler->ui_region) CTX_wm_region_set(C, handler->ui_region); + if (handler->ui_menu) CTX_wm_menu_set(C, handler->ui_menu); handler->ui_remove(C, handler->ui_userdata); @@ -1199,37 +1200,37 @@ int WM_userdef_event_map(int kmitype) { switch(kmitype) { case SELECTMOUSE: - if(U.flag & USER_LMOUSESELECT) + if (U.flag & USER_LMOUSESELECT) return LEFTMOUSE; else return RIGHTMOUSE; case ACTIONMOUSE: - if(U.flag & USER_LMOUSESELECT) + if (U.flag & USER_LMOUSESELECT) return RIGHTMOUSE; else return LEFTMOUSE; case WHEELOUTMOUSE: - if(U.uiflag & USER_WHEELZOOMDIR) + if (U.uiflag & USER_WHEELZOOMDIR) return WHEELUPMOUSE; else return WHEELDOWNMOUSE; case WHEELINMOUSE: - if(U.uiflag & USER_WHEELZOOMDIR) + if (U.uiflag & USER_WHEELZOOMDIR) return WHEELDOWNMOUSE; else return WHEELUPMOUSE; case EVT_TWEAK_A: - if(U.flag & USER_LMOUSESELECT) + if (U.flag & USER_LMOUSESELECT) return EVT_TWEAK_R; else return EVT_TWEAK_L; case EVT_TWEAK_S: - if(U.flag & USER_LMOUSESELECT) + if (U.flag & USER_LMOUSESELECT) return EVT_TWEAK_L; else return EVT_TWEAK_R; @@ -1243,8 +1244,8 @@ static void wm_eventemulation(wmEvent *event) static int mmb_emulated = 0; /* this should be in a data structure somwhere */ /* middlemouse emulation */ - if(U.flag & USER_TWOBUTTONMOUSE) { - if(event->type == LEFTMOUSE && (event->alt || mmb_emulated == KM_PRESS)) { + if (U.flag & USER_TWOBUTTONMOUSE) { + if (event->type == LEFTMOUSE && (event->alt || mmb_emulated == KM_PRESS)) { event->type = MIDDLEMOUSE; event->alt = 0; mmb_emulated = event->val; @@ -1253,8 +1254,8 @@ static void wm_eventemulation(wmEvent *event) #ifdef __APPLE__ /* rightmouse emulation */ - if(U.flag & USER_TWOBUTTONMOUSE) { - if(event->type == LEFTMOUSE && (event->oskey || mmb_emulated == KM_PRESS)) { + if (U.flag & USER_TWOBUTTONMOUSE) { + if (event->type == LEFTMOUSE && (event->oskey || mmb_emulated == KM_PRESS)) { event->type = RIGHTMOUSE; event->oskey = 0; mmb_emulated = event->val; @@ -1263,7 +1264,7 @@ static void wm_eventemulation(wmEvent *event) #endif /* numpad emulation */ - if(U.flag & USER_NONUMPAD) { + if (U.flag & USER_NONUMPAD) { switch(event->type) { case ZEROKEY: event->type = PAD0; break; case ONEKEY: event->type = PAD1; break; @@ -1286,35 +1287,35 @@ static int wm_eventmatch(wmEvent *winevent, wmKeyMapItem *kmi) { int kmitype= WM_userdef_event_map(kmi->type); - if(kmi->flag & KMI_INACTIVE) return 0; + if (kmi->flag & KMI_INACTIVE) return 0; /* the matching rules */ - if(kmitype==KM_TEXTINPUT) - if(ISTEXTINPUT(winevent->type) && (winevent->ascii || winevent->utf8_buf[0])) return 1; - if(kmitype!=KM_ANY) - if(winevent->type!=kmitype) return 0; + if (kmitype==KM_TEXTINPUT) + if (ISTEXTINPUT(winevent->type) && (winevent->ascii || winevent->utf8_buf[0])) return 1; + if (kmitype!=KM_ANY) + if (winevent->type!=kmitype) return 0; - if(kmi->val!=KM_ANY) - if(winevent->val!=kmi->val) return 0; + if (kmi->val!=KM_ANY) + if (winevent->val!=kmi->val) return 0; /* modifiers also check bits, so it allows modifier order */ - if(kmi->shift!=KM_ANY) - if(winevent->shift != kmi->shift && !(winevent->shift & kmi->shift)) return 0; - if(kmi->ctrl!=KM_ANY) - if(winevent->ctrl != kmi->ctrl && !(winevent->ctrl & kmi->ctrl)) return 0; - if(kmi->alt!=KM_ANY) - if(winevent->alt != kmi->alt && !(winevent->alt & kmi->alt)) return 0; - if(kmi->oskey!=KM_ANY) - if(winevent->oskey != kmi->oskey && !(winevent->oskey & kmi->oskey)) return 0; - - if(kmi->keymodifier) - if(winevent->keymodifier!=kmi->keymodifier) return 0; + if (kmi->shift!=KM_ANY) + if (winevent->shift != kmi->shift && !(winevent->shift & kmi->shift)) return 0; + if (kmi->ctrl!=KM_ANY) + if (winevent->ctrl != kmi->ctrl && !(winevent->ctrl & kmi->ctrl)) return 0; + if (kmi->alt!=KM_ANY) + if (winevent->alt != kmi->alt && !(winevent->alt & kmi->alt)) return 0; + if (kmi->oskey!=KM_ANY) + if (winevent->oskey != kmi->oskey && !(winevent->oskey & kmi->oskey)) return 0; + + if (kmi->keymodifier) + if (winevent->keymodifier!=kmi->keymodifier) return 0; /* key modifiers always check when event has it */ /* otherwise regular keypresses with keymodifier still work */ - if(winevent->keymodifier) - if(ISTEXTINPUT(winevent->type)) - if(winevent->keymodifier!=kmi->keymodifier) return 0; + if (winevent->keymodifier) + if (ISTEXTINPUT(winevent->type)) + if (winevent->keymodifier!=kmi->keymodifier) return 0; return 1; } @@ -1327,12 +1328,12 @@ static void wm_event_modalkeymap(const bContext *C, wmOperator *op, wmEvent *eve if (op->opm) op = op->opm; - if(op->type->modalkeymap) { + if (op->type->modalkeymap) { wmKeyMap *keymap= WM_keymap_active(CTX_wm_manager(C), op->type->modalkeymap); wmKeyMapItem *kmi; - for(kmi = keymap->items.first; kmi; kmi = kmi->next) { - if(wm_eventmatch(event, kmi)) { + for (kmi = keymap->items.first; kmi; kmi = kmi->next) { + if (wm_eventmatch(event, kmi)) { event->type= EVT_MODAL_MAP; event->val= kmi->propvalue; @@ -1348,11 +1349,11 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand int retval= OPERATOR_PASS_THROUGH; /* derived, modal or blocking operator */ - if(handler->op) { + if (handler->op) { wmOperator *op= handler->op; wmOperatorType *ot= op->type; - if(ot->modal) { + if (ot->modal) { /* we set context to where modal handler came from */ wmWindowManager *wm= CTX_wm_manager(C); ScrArea *area= CTX_wm_area(C); @@ -1362,7 +1363,7 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand wm_region_mouse_co(C, event); wm_event_modalkeymap(C, op, event); - if(ot->flag & OPTYPE_UNDO) + if (ot->flag & OPTYPE_UNDO) wm->op_undo_depth++; retval= ot->modal(C, op, event); @@ -1371,13 +1372,13 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand /* when this is _not_ the case the modal modifier may have loaded * a new blend file (demo mode does this), so we have to assume * the event, operator etc have all been freed. - campbell */ - if(CTX_wm_manager(C) == wm) { + if (CTX_wm_manager(C) == wm) { - if(ot->flag & OPTYPE_UNDO) + if (ot->flag & OPTYPE_UNDO) wm->op_undo_depth--; /* putting back screen context, reval can pass trough after modal failures! */ - if((retval & OPERATOR_PASS_THROUGH) || wm_event_always_pass(event)) { + if ((retval & OPERATOR_PASS_THROUGH) || wm_event_always_pass(event)) { CTX_wm_area_set(C, area); CTX_wm_region_set(C, region); } @@ -1387,20 +1388,20 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand CTX_wm_region_set(C, NULL); } - if(retval & (OPERATOR_CANCELLED|OPERATOR_FINISHED)) + if (retval & (OPERATOR_CANCELLED|OPERATOR_FINISHED)) wm_operator_reports(C, op, retval, FALSE); - if(retval & OPERATOR_FINISHED) { + if (retval & OPERATOR_FINISHED) { wm_operator_finished(C, op, 0); handler->op= NULL; } - else if(retval & (OPERATOR_CANCELLED|OPERATOR_FINISHED)) { + else if (retval & (OPERATOR_CANCELLED|OPERATOR_FINISHED)) { WM_operator_free(op); handler->op= NULL; } /* remove modal handler, operator itself should have been canceled and freed */ - if(retval & (OPERATOR_CANCELLED|OPERATOR_FINISHED)) { + if (retval & (OPERATOR_CANCELLED|OPERATOR_FINISHED)) { WM_cursor_ungrab(CTX_wm_window(C)); BLI_remlink(handlers, handler); @@ -1418,20 +1419,20 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand else { wmOperatorType *ot= WM_operatortype_find(event->keymap_idname, 0); - if(ot) + if (ot) retval= wm_operator_invoke(C, ot, event, properties, NULL, FALSE); } /* Finished and pass through flag as handled */ /* Finished and pass through flag as handled */ - if(retval == (OPERATOR_FINISHED|OPERATOR_PASS_THROUGH)) + if (retval == (OPERATOR_FINISHED|OPERATOR_PASS_THROUGH)) return WM_HANDLER_HANDLED; /* Modal unhandled, break */ - if(retval == (OPERATOR_PASS_THROUGH|OPERATOR_RUNNING_MODAL)) + if (retval == (OPERATOR_PASS_THROUGH|OPERATOR_RUNNING_MODAL)) return (WM_HANDLER_BREAK|WM_HANDLER_MODAL); - if(retval & OPERATOR_PASS_THROUGH) + if (retval & OPERATOR_PASS_THROUGH) return WM_HANDLER_CONTINUE; return WM_HANDLER_BREAK; @@ -1444,9 +1445,9 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa SpaceFile *sfile; int action= WM_HANDLER_CONTINUE; - if(event->type != EVT_FILESELECT) + if (event->type != EVT_FILESELECT) return action; - if(handler->op != (wmOperator *)event->customdata) + if (handler->op != (wmOperator *)event->customdata) return action; switch(event->val) { @@ -1465,7 +1466,7 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa sa = handler->op_area; } - if(event->val==EVT_FILESELECT_OPEN) { + if (event->val==EVT_FILESELECT_OPEN) { ED_area_newspace(C, sa, SPACE_FILE); /* 'sa' is modified in-place */ } else { @@ -1496,8 +1497,8 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa /* remlink now, for load file case before removing*/ BLI_remlink(handlers, handler); - if(event->val!=EVT_FILESELECT_EXTERNAL_CANCEL) { - if(screen != handler->filescreen) { + if (event->val!=EVT_FILESELECT_EXTERNAL_CANCEL) { + if (screen != handler->filescreen) { ED_screen_full_prevspace(C, CTX_wm_area(C)); } else { @@ -1509,7 +1510,7 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa /* needed for uiPupMenuReports */ - if(event->val==EVT_FILESELECT_EXEC) { + if (event->val==EVT_FILESELECT_EXEC) { #if 0 // use REDALERT now /* a bit weak, might become arg for WM_event_fileselect? */ @@ -1519,7 +1520,7 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa char *path= RNA_string_get_alloc(handler->op->ptr, "filepath", NULL, 0); /* this gives ownership to pupmenu */ uiPupMenuSaveOver(C, handler->op, (path)? path: ""); - if(path) + if (path) MEM_freeN(path); } else @@ -1527,25 +1528,25 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa { int retval; - if(handler->op->type->flag & OPTYPE_UNDO) + if (handler->op->type->flag & OPTYPE_UNDO) wm->op_undo_depth++; retval= handler->op->type->exec(C, handler->op); /* XXX check this carefully, CTX_wm_manager(C) == wm is a bit hackish */ - if(handler->op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm) + if (handler->op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm) wm->op_undo_depth--; if (retval & OPERATOR_FINISHED) - if(G.f & G_DEBUG) + if (G.f & G_DEBUG) wm_operator_print(C, handler->op); /* XXX check this carefully, CTX_wm_manager(C) == wm is a bit hackish */ - if(CTX_wm_manager(C) == wm && wm->op_undo_depth == 0) - if(handler->op->type->flag & OPTYPE_UNDO) + if (CTX_wm_manager(C) == wm && wm->op_undo_depth == 0) + if (handler->op->type->flag & OPTYPE_UNDO) ED_undo_push_op(C, handler->op); - if(handler->op->reports->list.first) { + if (handler->op->reports->list.first) { /* FIXME, temp setting window, this is really bad! * only have because lib linking errors need to be seen by users :( @@ -1554,7 +1555,7 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa ScrArea *area_prev= CTX_wm_area(C); ARegion *ar_prev= CTX_wm_region(C); - if(win_prev==NULL) + if (win_prev==NULL) CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first); handler->op->reports->printlevel = RPT_WARNING; @@ -1577,13 +1578,13 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa } } else { - if(handler->op->type->cancel) { - if(handler->op->type->flag & OPTYPE_UNDO) + if (handler->op->type->cancel) { + if (handler->op->type->flag & OPTYPE_UNDO) wm->op_undo_depth++; handler->op->type->cancel(C, handler->op); - if(handler->op->type->flag & OPTYPE_UNDO) + if (handler->op->type->flag & OPTYPE_UNDO) wm->op_undo_depth--; } @@ -1604,22 +1605,22 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa static int handler_boundbox_test(wmEventHandler *handler, wmEvent *event) { - if(handler->bbwin) { - if(handler->bblocal) { + if (handler->bbwin) { + if (handler->bblocal) { rcti rect= *handler->bblocal; BLI_translate_rcti(&rect, handler->bbwin->xmin, handler->bbwin->ymin); - if(BLI_in_rcti(&rect, event->x, event->y)) + if (BLI_in_rcti(&rect, event->x, event->y)) return 1; - else if(event->type==MOUSEMOVE && BLI_in_rcti(&rect, event->prevx, event->prevy)) + else if (event->type==MOUSEMOVE && BLI_in_rcti(&rect, event->prevx, event->prevy)) return 1; else return 0; } else { - if(BLI_in_rcti(handler->bbwin, event->x, event->y)) + if (BLI_in_rcti(handler->bbwin, event->x, event->y)) return 1; - else if(event->type==MOUSEMOVE && BLI_in_rcti(handler->bbwin, event->prevx, event->prevy)) + else if (event->type==MOUSEMOVE && BLI_in_rcti(handler->bbwin, event->prevx, event->prevy)) return 1; else return 0; @@ -1640,60 +1641,60 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) int action= WM_HANDLER_CONTINUE; int always_pass; - if(handlers==NULL) return action; + if (handlers==NULL) return action; /* modal handlers can get removed in this loop, we keep the loop this way */ - for(handler= handlers->first; handler; handler= nexthandler) { + for (handler= handlers->first; handler; handler= nexthandler) { nexthandler= handler->next; /* during this loop, ui handlers for nested menus can tag multiple handlers free */ - if(handler->flag & WM_HANDLER_DO_FREE); + if (handler->flag & WM_HANDLER_DO_FREE); /* optional boundbox */ - else if(handler_boundbox_test(handler, event)) { + else if (handler_boundbox_test(handler, event)) { /* in advance to avoid access to freed event on window close */ always_pass= wm_event_always_pass(event); /* modal+blocking handler */ - if(handler->flag & WM_HANDLER_BLOCKING) + if (handler->flag & WM_HANDLER_BLOCKING) action |= WM_HANDLER_BREAK; - if(handler->keymap) { + if (handler->keymap) { wmKeyMap *keymap= WM_keymap_active(wm, handler->keymap); wmKeyMapItem *kmi; - if(!keymap->poll || keymap->poll(C)) { - for(kmi = keymap->items.first; kmi; kmi = kmi->next) { - if(wm_eventmatch(event, kmi)) { + if (!keymap->poll || keymap->poll(C)) { + for (kmi = keymap->items.first; kmi; kmi = kmi->next) { + if (wm_eventmatch(event, kmi)) { /* weak, but allows interactive callback to not use rawkey */ event->keymap_idname = kmi->idname; action |= wm_handler_operator_call(C, handlers, handler, event, kmi->ptr); - if(action & WM_HANDLER_BREAK) /* not always_pass here, it denotes removed handler */ + if (action & WM_HANDLER_BREAK) /* not always_pass here, it denotes removed handler */ break; } } } } - else if(handler->ui_handle) { + else if (handler->ui_handle) { action |= wm_handler_ui_call(C, handler, event, always_pass); } - else if(handler->type==WM_HANDLER_FILESELECT) { + else if (handler->type==WM_HANDLER_FILESELECT) { /* screen context changes here */ action |= wm_handler_fileselect_call(C, handlers, handler, event); } - else if(handler->dropboxes) { - if(event->type==EVT_DROP) { + else if (handler->dropboxes) { + if (event->type==EVT_DROP) { wmDropBox *drop= handler->dropboxes->first; - for(; drop; drop= drop->next) { + for (; drop; drop= drop->next) { /* other drop custom types allowed */ - if(event->custom==EVT_DATA_LISTBASE) { + if (event->custom==EVT_DATA_LISTBASE) { ListBase *lb= (ListBase *)event->customdata; wmDrag *drag; - for(drag= lb->first; drag; drag= drag->next) { - if(drop->poll(C, drag, event)) { + for (drag= lb->first; drag; drag= drag->next) { + if (drop->poll(C, drag, event)) { drop->copy(drag, drop); @@ -1706,7 +1707,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) action |= WM_HANDLER_BREAK; /* XXX fileread case */ - if(CTX_wm_window(C)==NULL) + if (CTX_wm_window(C)==NULL) return action; /* escape from drag loop, got freed */ @@ -1722,8 +1723,8 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) action |= wm_handler_operator_call(C, handlers, handler, event, NULL); } - if(action & WM_HANDLER_BREAK) { - if(always_pass) + if (action & WM_HANDLER_BREAK) { + if (always_pass) action &= ~WM_HANDLER_BREAK; else break; @@ -1732,15 +1733,15 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) /* XXX fileread case, if the wm is freed then the handler's * will have been too so the code below need not run. */ - if(CTX_wm_window(C)==NULL) { + if (CTX_wm_window(C)==NULL) { return action; } /* XXX code this for all modal ops, and ensure free only happens here */ /* modal ui handler can be tagged to be freed */ - if(BLI_findindex(handlers, handler) != -1) { /* could be freed already by regular modal ops */ - if(handler->flag & WM_HANDLER_DO_FREE) { + if (BLI_findindex(handlers, handler) != -1) { /* could be freed already by regular modal ops */ + if (handler->flag & WM_HANDLER_DO_FREE) { BLI_remlink(handlers, handler); wm_event_free_handler(handler); } @@ -1787,7 +1788,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) } } - if(action == (WM_HANDLER_BREAK|WM_HANDLER_MODAL)) + if (action == (WM_HANDLER_BREAK|WM_HANDLER_MODAL)) wm_cursor_arrow_move(CTX_wm_window(C), event); return action; @@ -1795,12 +1796,12 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) static int wm_event_inside_i(wmEvent *event, rcti *rect) { - if(wm_event_always_pass(event)) + if (wm_event_always_pass(event)) return 1; - if(BLI_in_rcti(rect, event->x, event->y)) + if (BLI_in_rcti(rect, event->x, event->y)) return 1; - if(event->type==MOUSEMOVE) { - if( BLI_in_rcti(rect, event->prevx, event->prevy)) { + if (event->type==MOUSEMOVE) { + if ( BLI_in_rcti(rect, event->prevx, event->prevy)) { return 1; } return 0; @@ -1813,9 +1814,9 @@ static ScrArea *area_event_inside(bContext *C, int x, int y) bScreen *screen= CTX_wm_screen(C); ScrArea *sa; - if(screen) - for(sa= screen->areabase.first; sa; sa= sa->next) - if(BLI_in_rcti(&sa->totrct, x, y)) + if (screen) + for (sa= screen->areabase.first; sa; sa= sa->next) + if (BLI_in_rcti(&sa->totrct, x, y)) return sa; return NULL; } @@ -1826,18 +1827,18 @@ static ARegion *region_event_inside(bContext *C, int x, int y) ScrArea *area= CTX_wm_area(C); ARegion *ar; - if(screen && area) - for(ar= area->regionbase.first; ar; ar= ar->next) - if(BLI_in_rcti(&ar->winrct, x, y)) + if (screen && area) + for (ar= area->regionbase.first; ar; ar= ar->next) + if (BLI_in_rcti(&ar->winrct, x, y)) return ar; return NULL; } static void wm_paintcursor_tag(bContext *C, wmPaintCursor *pc, ARegion *ar) { - if(ar) { - for(; pc; pc= pc->next) { - if(pc->poll == NULL || pc->poll(C)) { + if (ar) { + for (; pc; pc= pc->next) { + if (pc->poll == NULL || pc->poll(C)) { wmWindow *win= CTX_wm_window(C); win->screen->do_draw_paintcursor= 1; wm_tag_redraw_overlay(win, ar); @@ -1852,14 +1853,14 @@ static void wm_paintcursor_test(bContext *C, wmEvent *event) { wmWindowManager *wm= CTX_wm_manager(C); - if(wm->paintcursors.first) { + if (wm->paintcursors.first) { ARegion *ar= CTX_wm_region(C); - if(ar) + if (ar) wm_paintcursor_tag(C, wm->paintcursors.first, ar); /* if previous position was not in current region, we have to set a temp new context */ - if(ar==NULL || !BLI_in_rcti(&ar->winrct, event->prevx, event->prevy)) { + if (ar==NULL || !BLI_in_rcti(&ar->winrct, event->prevx, event->prevy)) { ScrArea *sa= CTX_wm_area(C); CTX_wm_area_set(C, area_event_inside(C, event->prevx, event->prevy)); @@ -1875,20 +1876,20 @@ static void wm_paintcursor_test(bContext *C, wmEvent *event) static void wm_event_drag_test(wmWindowManager *wm, wmWindow *win, wmEvent *event) { - if(wm->drags.first==NULL) return; + if (wm->drags.first==NULL) return; - if(event->type==MOUSEMOVE) + if (event->type==MOUSEMOVE) win->screen->do_draw_drag= 1; - else if(event->type==ESCKEY) { + else if (event->type==ESCKEY) { BLI_freelistN(&wm->drags); win->screen->do_draw_drag= 1; } - else if(event->type==LEFTMOUSE && event->val==KM_RELEASE) { + else if (event->type==LEFTMOUSE && event->val==KM_RELEASE) { event->type= EVT_DROP; /* create customdata, first free existing */ - if(event->customdata) { - if(event->customdatafree) + if (event->customdata) { + if (event->customdatafree) MEM_freeN(event->customdata); } @@ -1904,8 +1905,8 @@ static void wm_event_drag_test(wmWindowManager *wm, wmWindow *win, wmEvent *even } /* overlap fails otherwise */ - if(win->screen->do_draw_drag) - if(win->drawmethod == USER_DRAW_OVERLAP) + if (win->screen->do_draw_drag) + if (win->drawmethod == USER_DRAW_OVERLAP) win->screen->do_draw= 1; } @@ -1920,31 +1921,31 @@ void wm_event_do_handlers(bContext *C) /* update key configuration before handling events */ WM_keyconfig_update(wm); - for(win= wm->windows.first; win; win= win->next) { + for (win= wm->windows.first; win; win= win->next) { wmEvent *event; - if( win->screen==NULL ) + if ( win->screen==NULL ) wm_event_free_all(win); else { Scene* scene = win->screen->scene; - if(scene) { + if (scene) { int playing = sound_scene_playing(win->screen->scene); - if(playing != -1) { + if (playing != -1) { CTX_wm_window_set(C, win); CTX_wm_screen_set(C, win->screen); CTX_data_scene_set(C, scene); - if(((playing == 1) && (!win->screen->animtimer)) || ((playing == 0) && (win->screen->animtimer))){ + if (((playing == 1) && (!win->screen->animtimer)) || ((playing == 0) && (win->screen->animtimer))) { ED_screen_animation_play(C, -1, 1); } - if(playing == 0) { + if (playing == 0) { float time = sound_sync_scene(scene); - if(finite(time)) { + if (finite(time)) { int ncfra = sound_sync_scene(scene) * (float)FPS + 0.5f; - if(ncfra != scene->r.cfra) { + if (ncfra != scene->r.cfra) { scene->r.cfra = ncfra; ED_update_for_newframe(CTX_data_main(C), scene, win->screen, 1); WM_event_add_notifier(C, NC_WINDOW, NULL); @@ -1959,10 +1960,10 @@ void wm_event_do_handlers(bContext *C) } } - while( (event= win->queue.first) ) { + while ( (event= win->queue.first) ) { int action = WM_HANDLER_CONTINUE; - if((G.f & G_DEBUG) && event && !ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) + if ((G.f & G_DEBUG) && event && !ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) printf("pass on evt %d val %d\n", event->type, event->val); wm_eventemulation(event); @@ -1982,7 +1983,7 @@ void wm_event_do_handlers(bContext *C) action |= wm_handlers_do(C, event, &win->modalhandlers); /* fileread case */ - if(CTX_wm_window(C)==NULL) + if (CTX_wm_window(C)==NULL) return; /* check dragging, creates new event or frees, adds draw tag */ @@ -1991,13 +1992,13 @@ void wm_event_do_handlers(bContext *C) /* builtin tweak, if action is break it removes tweak */ wm_tweakevent_test(C, event, action); - if((action & WM_HANDLER_BREAK) == 0) { + if ((action & WM_HANDLER_BREAK) == 0) { ScrArea *sa; ARegion *ar; int doit= 0; /* Note: setting subwin active should be done here, after modal handlers have been done */ - if(event->type==MOUSEMOVE) { + if (event->type==MOUSEMOVE) { /* state variables in screen, cursors. Also used in wm_draw.c, fails for modal handlers though */ ED_screen_set_subwinactive(C, event); /* for regions having custom cursors */ @@ -2007,13 +2008,13 @@ void wm_event_do_handlers(bContext *C) win->addmousemove = TRUE; } - for(sa= win->screen->areabase.first; sa; sa= sa->next) { - if(wm_event_inside_i(event, &sa->totrct)) { + for (sa= win->screen->areabase.first; sa; sa= sa->next) { + if (wm_event_inside_i(event, &sa->totrct)) { CTX_wm_area_set(C, sa); - if((action & WM_HANDLER_BREAK) == 0) { - for(ar=sa->regionbase.first; ar; ar= ar->next) { - if(wm_event_inside_i(event, &ar->winrct)) { + if ((action & WM_HANDLER_BREAK) == 0) { + for (ar=sa->regionbase.first; ar; ar= ar->next) { + if (wm_event_inside_i(event, &ar->winrct)) { CTX_wm_region_set(C, ar); /* call even on non mouse events, since the */ @@ -2021,19 +2022,19 @@ void wm_event_do_handlers(bContext *C) /* does polls for drop regions and checks uibuts */ /* need to be here to make sure region context is true */ - if(ELEM(event->type, MOUSEMOVE, EVT_DROP)) { + if (ELEM(event->type, MOUSEMOVE, EVT_DROP)) { wm_drags_check_ops(C, event); } action |= wm_handlers_do(C, event, &ar->handlers); /* fileread case (python), [#29489] */ - if(CTX_wm_window(C)==NULL) + if (CTX_wm_window(C)==NULL) return; doit |= (BLI_in_rcti(&ar->winrct, event->x, event->y)); - if(action & WM_HANDLER_BREAK) + if (action & WM_HANDLER_BREAK) break; } } @@ -2041,7 +2042,7 @@ void wm_event_do_handlers(bContext *C) CTX_wm_region_set(C, NULL); - if((action & WM_HANDLER_BREAK) == 0) { + if ((action & WM_HANDLER_BREAK) == 0) { wm_region_mouse_co(C, event); /* only invalidates event->mval in this case */ action |= wm_handlers_do(C, event, &sa->handlers); } @@ -2051,7 +2052,7 @@ void wm_event_do_handlers(bContext *C) } } - if((action & WM_HANDLER_BREAK) == 0) { + if ((action & WM_HANDLER_BREAK) == 0) { /* also some non-modal handlers need active area/region */ CTX_wm_area_set(C, area_event_inside(C, event->x, event->y)); CTX_wm_region_set(C, region_event_inside(C, event->x, event->y)); @@ -2061,13 +2062,13 @@ void wm_event_do_handlers(bContext *C) action |= wm_handlers_do(C, event, &win->handlers); /* fileread case */ - if(CTX_wm_window(C)==NULL) + if (CTX_wm_window(C)==NULL) return; } /* XXX hrmf, this gives reliable previous mouse coord for area change, feels bad? * doing it on ghost queue gives errors when mousemoves go over area borders */ - if(doit && win->screen && win->screen->subwinactive != win->screen->mainwin) { + if (doit && win->screen && win->screen->subwinactive != win->screen->mainwin) { win->eventstate->prevx= event->x; win->eventstate->prevy= event->y; //printf("win->eventstate->prev = %d %d\n", event->x, event->y); @@ -2088,20 +2089,23 @@ void wm_event_do_handlers(bContext *C) win->eventstate->prevclickx = event->x; win->eventstate->prevclicky = event->y; } - } else { + } + else { /* reset click time if event type not the same */ win->eventstate->prevclicktime = 0; } win->eventstate->prevval = event->val; win->eventstate->prevtype = event->type; - } else if (event->val == KM_CLICK) { /* keep click for double click later */ + } + else if (event->val == KM_CLICK) { /* keep click for double click later */ win->eventstate->prevtype = event->type; win->eventstate->prevval = event->val; win->eventstate->prevclicktime = PIL_check_seconds_timer(); win->eventstate->prevclickx = event->x; win->eventstate->prevclicky = event->y; - } else { /* reset if not */ + } + else { /* reset if not */ win->eventstate->prevtype = -1; win->eventstate->prevval = 0; win->eventstate->prevclicktime = 0; @@ -2115,7 +2119,7 @@ void wm_event_do_handlers(bContext *C) } /* only add mousemove when queue was read entirely */ - if(win->addmousemove && win->eventstate) { + if (win->addmousemove && win->eventstate) { wmEvent tevent= *(win->eventstate); //printf("adding MOUSEMOVE %d %d\n", tevent.x, tevent.y); tevent.type= MOUSEMOVE; @@ -2139,7 +2143,7 @@ void WM_event_fileselect_event(bContext *C, void *ophandle, int eventval) /* add to all windows! */ wmWindow *win; - for(win= CTX_wm_manager(C)->windows.first; win; win= win->next) { + for (win= CTX_wm_manager(C)->windows.first; win; win= win->next) { wmEvent event= *win->eventstate; event.type= EVT_FILESELECT; @@ -2165,11 +2169,11 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op) int full= 1; // XXX preset? /* only allow 1 file selector open per window */ - for(handler= win->modalhandlers.first; handler; handler=handlernext) { + for (handler= win->modalhandlers.first; handler; handler=handlernext) { handlernext= handler->next; - if(handler->type == WM_HANDLER_FILESELECT) { - if(handler->op) + if (handler->type == WM_HANDLER_FILESELECT) { + if (handler->op) WM_operator_free(handler->op); BLI_remlink(&win->modalhandlers, handler); wm_event_free_handler(handler); @@ -2188,7 +2192,7 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op) /* check props once before invoking if check is available * ensures initial properties are valid */ - if(op->type->check) { + if (op->type->check) { op->type->check(C, op); /* ignore return value */ } @@ -2209,7 +2213,7 @@ wmEventHandler *WM_event_add_modal_handler(bContext *C, wmOperator *op) wmWindow *win= CTX_wm_window(C); /* operator was part of macro */ - if(op->opm) { + if (op->opm) { /* give the mother macro to the handler */ handler->op= op->opm; /* mother macro opm becomes the macro element */ @@ -2230,14 +2234,14 @@ wmEventHandler *WM_event_add_keymap_handler(ListBase *handlers, wmKeyMap *keymap { wmEventHandler *handler; - if(!keymap) { + if (!keymap) { printf("WM_event_add_keymap_handler called with NULL keymap\n"); return NULL; } /* only allow same keymap once */ - for(handler= handlers->first; handler; handler= handler->next) - if(handler->keymap==keymap) + for (handler= handlers->first; handler; handler= handler->next) + if (handler->keymap==keymap) return handler; handler= MEM_callocN(sizeof(wmEventHandler), "event keymap handler"); @@ -2265,7 +2269,7 @@ wmEventHandler *WM_event_add_keymap_handler_bb(ListBase *handlers, wmKeyMap *key { wmEventHandler *handler= WM_event_add_keymap_handler(handlers, keymap); - if(handler) { + if (handler) { handler->bblocal= bblocal; handler->bbwin= bbwin; } @@ -2276,8 +2280,8 @@ void WM_event_remove_keymap_handler(ListBase *handlers, wmKeyMap *keymap) { wmEventHandler *handler; - for(handler= handlers->first; handler; handler= handler->next) { - if(handler->keymap==keymap) { + for (handler= handlers->first; handler; handler= handler->next) { + if (handler->keymap==keymap) { BLI_remlink(handlers, handler); wm_event_free_handler(handler); break; @@ -2307,10 +2311,10 @@ void WM_event_remove_ui_handler(ListBase *handlers, { wmEventHandler *handler; - for(handler= handlers->first; handler; handler= handler->next) { - if(handler->ui_handle == func && handler->ui_remove == remove && handler->ui_userdata == userdata) { + for (handler= handlers->first; handler; handler= handler->next) { + if (handler->ui_handle == func && handler->ui_remove == remove && handler->ui_userdata == userdata) { /* handlers will be freed in wm_handlers_do() */ - if(postpone) { + if (postpone) { handler->flag |= WM_HANDLER_DO_FREE; } else { @@ -2327,8 +2331,8 @@ wmEventHandler *WM_event_add_dropbox_handler(ListBase *handlers, ListBase *dropb wmEventHandler *handler; /* only allow same dropbox once */ - for(handler= handlers->first; handler; handler= handler->next) - if(handler->dropboxes==dropboxes) + for (handler= handlers->first; handler; handler= handler->next) + if (handler->dropboxes==dropboxes) return handler; handler= MEM_callocN(sizeof(wmEventHandler), "dropbox handler"); @@ -2345,7 +2349,7 @@ void WM_event_remove_area_handler(ListBase *handlers, void *area) { wmEventHandler *handler, *nexthandler; - for(handler = handlers->first; handler; handler= nexthandler) { + for (handler = handlers->first; handler; handler= nexthandler) { nexthandler = handler->next; if (handler->type != WM_HANDLER_FILESELECT) { if (handler->ui_area == area) { @@ -2390,7 +2394,7 @@ int WM_modal_tweak_exit(wmEvent *evt, int tweak_event) else { /* if the initial event wasn't a tweak event then * ignore USER_RELEASECONFIRM setting: see [#26756] */ - if(ELEM3(tweak_event, EVT_TWEAK_L, EVT_TWEAK_M, EVT_TWEAK_R) == 0) { + if (ELEM3(tweak_event, EVT_TWEAK_L, EVT_TWEAK_M, EVT_TWEAK_R) == 0) { return 1; } } @@ -2413,13 +2417,17 @@ static int convert_key(GHOST_TKey key) { if (key>=GHOST_kKeyA && key<=GHOST_kKeyZ) { return (AKEY + ((int) key - GHOST_kKeyA)); - } else if (key>=GHOST_kKey0 && key<=GHOST_kKey9) { + } + else if (key>=GHOST_kKey0 && key<=GHOST_kKey9) { return (ZEROKEY + ((int) key - GHOST_kKey0)); - } else if (key>=GHOST_kKeyNumpad0 && key<=GHOST_kKeyNumpad9) { + } + else if (key>=GHOST_kKeyNumpad0 && key<=GHOST_kKeyNumpad9) { return (PAD0 + ((int) key - GHOST_kKeyNumpad0)); - } else if (key>=GHOST_kKeyF1 && key<=GHOST_kKeyF19) { + } + else if (key>=GHOST_kKeyF1 && key<=GHOST_kKeyF19) { return (F1KEY + ((int) key - GHOST_kKeyF1)); - } else { + } + else { switch (key) { case GHOST_kKeyBackSpace: return BACKSPACEKEY; case GHOST_kKeyTab: return TABKEY; @@ -2557,18 +2565,18 @@ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *wi { int mx= evt->x, my= evt->y; - if(wm->windows.first== wm->windows.last) + if (wm->windows.first== wm->windows.last) return NULL; /* top window bar... */ - if(mx<0 || my<0 || mx>win->sizex || my>win->sizey+30) { + if (mx<0 || my<0 || mx>win->sizex || my>win->sizey+30) { wmWindow *owin; wmEventHandler *handler; /* let's skip windows having modal handlers now */ /* potential XXX ugly... I wouldn't have added a modalhandlers list (introduced in rev 23331, ton) */ - for(handler= win->modalhandlers.first; handler; handler= handler->next) - if(handler->ui_handle || handler->op) + for (handler= win->modalhandlers.first; handler; handler= handler->next) + if (handler->ui_handle || handler->op) return NULL; /* to desktop space */ @@ -2576,10 +2584,10 @@ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *wi my += (int)win->posy; /* check other windows to see if it has mouse inside */ - for(owin= wm->windows.first; owin; owin= owin->next) { + for (owin= wm->windows.first; owin; owin= owin->next) { - if(owin!=win) { - if(mx-owin->posx >= 0 && my-owin->posy >= 0 && + if (owin!=win) { + if (mx-owin->posx >= 0 && my-owin->posy >= 0 && mx-owin->posx <= owin->sizex && my-owin->posy <= owin->sizey) { evt->x= mx - (int)owin->posx; evt->y= my - (int)owin->posy; @@ -2605,7 +2613,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U switch (type) { /* mouse move */ case GHOST_kEventCursorMove: { - if(win->active) { + if (win->active) { GHOST_TEventCursorData *cd= customdata; wmEvent *lastevent= win->queue.last; int cx, cy; @@ -2622,7 +2630,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U /* some painting operators want accurate mouse events, they can * handle in between mouse move moves, others can happily ignore * them for better performance */ - if(lastevent && lastevent->type == MOUSEMOVE) + if (lastevent && lastevent->type == MOUSEMOVE) lastevent->type = INBETWEEN_MOUSEMOVE; update_tablet_data(win, &event); @@ -2633,7 +2641,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U /* also add to other window if event is there, this makes overdraws disappear nicely */ /* it remaps mousecoord to other window in event */ owin= wm_event_cursor_other_windows(wm, win, &event); - if(owin) { + if (owin) { wmEvent oevent= *(owin->eventstate); oevent.x=owin->eventstate->x= event.x; @@ -2696,7 +2704,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U else event.type= MIDDLEMOUSE; - if(win->active==0) { + if (win->active==0) { int cx, cy; /* entering window, update mouse pos. (ghost sends win-activate *after* the mouseclick in window!) */ @@ -2708,7 +2716,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U /* add to other window if event is there (not to both!) */ owin= wm_event_cursor_other_windows(wm, win, &event); - if(owin) { + if (owin) { wmEvent oevent= *(owin->eventstate); oevent.x= event.x; @@ -2736,7 +2744,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U event.val= (type==GHOST_kEventKeyDown)?KM_PRESS:KM_RELEASE; /* exclude arrow keys, esc, etc from text input */ - if(type==GHOST_kEventKeyUp) { + if (type==GHOST_kEventKeyUp) { event.ascii= '\0'; /* ghost should do this already for key up */ @@ -2784,9 +2792,9 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U FALSE; break; default: - if(event.val == KM_PRESS && event.keymodifier==0) + if (event.val == KM_PRESS && event.keymodifier==0) evt->keymodifier= event.type; /* only set in eventstate, for next event */ - else if(event.val==KM_RELEASE && event.keymodifier==event.type) + else if (event.val==KM_RELEASE && event.keymodifier==event.type) event.keymodifier= evt->keymodifier= 0; break; } @@ -2795,16 +2803,16 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U * generate press events without release, we still want to keep the * modifier in win->eventstate, but for the press event of the same * key we don't want the key modifier */ - if(event.keymodifier == event.type) + if (event.keymodifier == event.type) event.keymodifier= 0; /* this case happened with an external numpad, it's not really clear * why, but it's also impossible to map a key modifier to an unknwon * key, so it shouldn't harm */ - if(event.keymodifier == UNKNOWNKEY) + if (event.keymodifier == UNKNOWNKEY) event.keymodifier= 0; /* if test_break set, it catches this. XXX Keep global for now? */ - if(event.type==ESCKEY) + if (event.type==ESCKEY) G.afbreek= 1; wm_event_add(win, &event); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 5384d6ef8f7..db75c789b06 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -138,11 +138,11 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist) /* first wrap up running stuff */ /* code copied from wm_init_exit.c */ - for(wm= wmlist->first; wm; wm= wm->id.next) { + for (wm= wmlist->first; wm; wm= wm->id.next) { WM_jobs_stop_all(wm); - for(win= wm->windows.first; win; win= win->next) { + for (win= wm->windows.first; win; win= win->next) { CTX_wm_window_set(C, win); /* needed by operator close callbacks */ WM_event_remove_handlers(C, &win->handlers); @@ -158,13 +158,13 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist) /* just had return; here from r12991, this code could just get removed?*/ #if 0 - if(wm==NULL) return; - if(G.fileflags & G_FILE_NO_UI) return; + if (wm==NULL) return; + if (G.fileflags & G_FILE_NO_UI) return; /* we take apart the used screens from non-active window */ - for(win= wm->windows.first; win; win= win->next) { + for (win= wm->windows.first; win; win= win->next) { BLI_strncpy(win->screenname, win->screen->id.name, MAX_ID_NAME); - if(win!=wm->winactive) { + if (win!=wm->winactive) { BLI_remlink(&G.main->screen, win->screen); //BLI_addtail(screenbase, win->screen); } @@ -185,8 +185,8 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist) wmWindow *oldwin, *win; /* cases 1 and 2 */ - if(oldwmlist->first==NULL) { - if(G.main->wm.first); /* nothing todo */ + if (oldwmlist->first==NULL) { + if (G.main->wm.first); /* nothing todo */ else wm_add_default(C); } @@ -194,18 +194,18 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist) /* cases 3 and 4 */ /* we've read file without wm..., keep current one entirely alive */ - if(G.main->wm.first==NULL) { + if (G.main->wm.first==NULL) { bScreen *screen= NULL; /* when loading without UI, no matching needed */ - if(!(G.fileflags & G_FILE_NO_UI) && (screen= CTX_wm_screen(C))) { + if (!(G.fileflags & G_FILE_NO_UI) && (screen= CTX_wm_screen(C))) { /* match oldwm to new dbase, only old files */ - for(wm= oldwmlist->first; wm; wm= wm->id.next) { + for (wm= oldwmlist->first; wm; wm= wm->id.next) { - for(win= wm->windows.first; win; win= win->next) { + for (win= wm->windows.first; win; win= win->next) { /* all windows get active screen from file */ - if(screen->winid==0) + if (screen->winid==0) win->screen= screen; else win->screen= ED_screen_duplicate(win, screen); @@ -243,16 +243,16 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist) wm->winactive= NULL; /* only first wm in list has ghostwins */ - for(win= wm->windows.first; win; win= win->next) { - for(oldwin= oldwm->windows.first; oldwin; oldwin= oldwin->next) { + for (win= wm->windows.first; win; win= win->next) { + for (oldwin= oldwm->windows.first; oldwin; oldwin= oldwin->next) { - if(oldwin->winid == win->winid ) { + if (oldwin->winid == win->winid ) { win->ghostwin= oldwin->ghostwin; win->active= oldwin->active; - if(win->active) + if (win->active) wm->winactive= win; - if(!G.background) /* file loading in background mode still calls this */ + if (!G.background) /* file loading in background mode still calls this */ GHOST_SetWindowUserData(win->ghostwin, win); /* pointer back */ oldwin->ghostwin= NULL; @@ -281,12 +281,12 @@ static void wm_init_userdef(bContext *C) sound_init(CTX_data_main(C)); /* needed so loading a file from the command line respects user-pref [#26156] */ - if(U.flag & USER_FILENOUI) G.fileflags |= G_FILE_NO_UI; + if (U.flag & USER_FILENOUI) G.fileflags |= G_FILE_NO_UI; else G.fileflags &= ~G_FILE_NO_UI; /* set the python auto-execute setting from user prefs */ /* enabled by default, unless explicitly enabled in the command line which overrides */ - if((G.f & G_SCRIPT_OVERRIDE_PREF) == 0) { + if ((G.f & G_SCRIPT_OVERRIDE_PREF) == 0) { if ((U.flag & USER_SCRIPT_AUTOEXEC_DISABLE) == 0) G.f |= G_SCRIPT_AUTOEXEC; else G.f &= ~G_SCRIPT_AUTOEXEC; } @@ -333,7 +333,7 @@ static int wm_read_exotic(Scene *UNUSED(scene), const char *name) else { //XXX waitcursor(1); #if 0 /* historic stuff - no longer used */ - if(is_foo_format(name)) { + if (is_foo_format(name)) { read_foo(name); retval= BKE_READ_EXOTIC_OK_OTHER; } @@ -380,7 +380,7 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports) /* this flag is initialized by the operator but overwritten on read. * need to re-enable it here else drivers + registered scripts wont work. */ - if(G.f != G_f) { + if (G.f != G_f) { const int flags_keep= (G_SCRIPT_AUTOEXEC | G_SCRIPT_OVERRIDE_PREF); G.f= (G.f & ~flags_keep) | (G_f & flags_keep); } @@ -391,14 +391,14 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports) // XXX mainwindow_set_filename_to_title(G.main->name); - if(retval == BKE_READ_FILE_OK_USERPREFS) { + if (retval == BKE_READ_FILE_OK_USERPREFS) { /* in case a userdef is read from regular .blend */ wm_init_userdef(C); } if (retval != BKE_READ_FILE_FAIL) { G.relbase_valid = 1; - if(!G.background) /* assume automated tasks with background, don't write recent file list */ + if (!G.background) /* assume automated tasks with background, don't write recent file list */ write_history(); } @@ -451,16 +451,16 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports) BKE_reset_undo(); BKE_write_undo(C, "original"); /* save current state */ } - else if(retval == BKE_READ_EXOTIC_OK_OTHER) + else if (retval == BKE_READ_EXOTIC_OK_OTHER) BKE_write_undo(C, "Import file"); - else if(retval == BKE_READ_EXOTIC_FAIL_OPEN) { + else if (retval == BKE_READ_EXOTIC_FAIL_OPEN) { BKE_reportf(reports, RPT_ERROR, IFACE_("Can't read file: \"%s\", %s."), filepath, errno ? strerror(errno) : IFACE_("Unable to open the file")); } - else if(retval == BKE_READ_EXOTIC_FAIL_FORMAT) { + else if (retval == BKE_READ_EXOTIC_FAIL_FORMAT) { BKE_reportf(reports, RPT_ERROR, IFACE_("File format is not supported in file: \"%s\"."), filepath); } - else if(retval == BKE_READ_EXOTIC_FAIL_PATH) { + else if (retval == BKE_READ_EXOTIC_FAIL_PATH) { BKE_reportf(reports, RPT_ERROR, IFACE_("File path invalid: \"%s\"."), filepath); } else { @@ -489,7 +489,8 @@ int WM_read_homefile(bContext *C, ReportList *UNUSED(reports), short from_memory char *cfgdir = BLI_get_folder(BLENDER_USER_CONFIG, NULL); if (cfgdir) { BLI_make_file_string(G.main->name, tstr, cfgdir, BLENDER_STARTUP_FILE); - } else { + } + else { tstr[0] = '\0'; from_memory = 1; } @@ -504,12 +505,12 @@ int WM_read_homefile(bContext *C, ReportList *UNUSED(reports), short from_memory if (!from_memory && BLI_exists(tstr)) { success = (BKE_read_file(C, tstr, NULL) != BKE_READ_FILE_FAIL); - if(U.themes.first==NULL) { + if (U.themes.first==NULL) { printf("\nError: No valid "STRINGIFY(BLENDER_STARTUP_FILE)", fall back to built-in default.\n\n"); success = 0; } } - if(success==0) { + if (success==0) { success = BKE_read_file_from_memory(C, datatoc_startup_blend, datatoc_startup_blend_size, NULL); if (wmbase.first == NULL) wm_clear_default_size(C); @@ -551,7 +552,7 @@ int WM_read_homefile(bContext *C, ReportList *UNUSED(reports), short from_memory DAG_on_visible_update(CTX_data_main(C), TRUE); #ifdef WITH_PYTHON - if(CTX_py_init_get(C)) { + if (CTX_py_init_get(C)) { /* sync addons, these may have changed from the defaults */ BPY_string_exec(C, "__import__('addon_utils').reset_all()"); @@ -564,7 +565,7 @@ int WM_read_homefile(bContext *C, ReportList *UNUSED(reports), short from_memory WM_event_add_notifier(C, NC_WM|ND_FILEREAD, NULL); /* in background mode the scene will stay NULL */ - if(!G.background) { + if (!G.background) { CTX_wm_window_set(C, NULL); /* exits queues */ } @@ -619,14 +620,14 @@ static void write_history(void) /* will be NULL in background mode */ user_config_dir = BLI_get_folder_create(BLENDER_USER_CONFIG, NULL); - if(!user_config_dir) + if (!user_config_dir) return; BLI_make_file_string("/", name, user_config_dir, BLENDER_HISTORY_FILE); recent = G.recent_files.first; /* refresh recent-files.txt of recent opened files, when current file was changed */ - if(!(recent) || (BLI_path_cmp(recent->filepath, G.main->name)!=0)) { + if (!(recent) || (BLI_path_cmp(recent->filepath, G.main->name)!=0)) { fp= BLI_fopen(name, "w"); if (fp) { /* add current file to the beginning of list */ @@ -638,7 +639,7 @@ static void write_history(void) recent = recent->next; i=1; /* write rest of recent opened files to recent-files.txt */ - while((ifilepath, G.main->name)!=0) { fprintf(fp, "%s\n", recent->filepath); @@ -670,7 +671,7 @@ static ImBuf *blend_file_thumb(Scene *scene, int **thumb_pt) *thumb_pt= NULL; /* scene can be NULL if running a script at startup and calling the save operator */ - if(G.background || scene==NULL || scene->camera==NULL) + if (G.background || scene==NULL || scene->camera==NULL) return NULL; /* gets scaled to BLEN_THUMB_SIZE */ @@ -678,7 +679,7 @@ static ImBuf *blend_file_thumb(Scene *scene, int **thumb_pt) BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2, IB_rect, OB_SOLID, FALSE, err_out); - if(ibuf) { + if (ibuf) { float aspect= (scene->r.xsch*scene->r.xasp) / (scene->r.ysch*scene->r.yasp); /* dirty oversampling */ @@ -715,7 +716,7 @@ int write_crash_blend(void) BLI_strncpy(path, G.main->name, sizeof(path)); BLI_replace_extension(path, sizeof(path), "_crash.blend"); - if(BLO_write_file(G.main, path, fileflags, NULL, NULL)) { + if (BLO_write_file(G.main, path, fileflags, NULL, NULL)) { printf("written: %s\n", path); return 1; } @@ -760,7 +761,7 @@ 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) { + if (U.flag & USER_SAVE_PREVIEWS) { ibuf_thumb= blend_file_thumb(CTX_data_scene(C), &thumb); } @@ -781,21 +782,21 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re fileflags |= G_FILE_HISTORY; /* write file history */ if (BLO_write_file(CTX_data_main(C), filepath, fileflags, reports, thumb)) { - if(!copy) { + if (!copy) { G.relbase_valid = 1; BLI_strncpy(G.main->name, filepath, sizeof(G.main->name)); /* is guaranteed current file */ G.save_over = 1; /* disable untitled.blend convention */ } - if(fileflags & G_FILE_COMPRESS) G.fileflags |= G_FILE_COMPRESS; + if (fileflags & G_FILE_COMPRESS) G.fileflags |= G_FILE_COMPRESS; else G.fileflags &= ~G_FILE_COMPRESS; - if(fileflags & G_FILE_AUTOPLAY) G.fileflags |= G_FILE_AUTOPLAY; + if (fileflags & G_FILE_AUTOPLAY) G.fileflags |= G_FILE_AUTOPLAY; else G.fileflags &= ~G_FILE_AUTOPLAY; /* prevent background mode scripts from clobbering history */ - if(!G.background) { + if (!G.background) { write_history(); } @@ -807,11 +808,11 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re IMB_freeImBuf(ibuf_thumb); } - if(thumb) MEM_freeN(thumb); + if (thumb) MEM_freeN(thumb); } else { - if(ibuf_thumb) IMB_freeImBuf(ibuf_thumb); - if(thumb) MEM_freeN(thumb); + if (ibuf_thumb) IMB_freeImBuf(ibuf_thumb); + if (thumb) MEM_freeN(thumb); WM_cursor_wait(0); return -1; @@ -831,7 +832,7 @@ int WM_write_homefile(bContext *C, wmOperator *op) int fileflags; /* check current window and close it if temp */ - if(win->screen->temp) + if (win->screen->temp) wm_window_close(C, wm, win); /* update keymaps in user preferences */ @@ -843,7 +844,7 @@ int WM_write_homefile(bContext *C, wmOperator *op) /* force save as regular blend file */ fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_AUTOPLAY | G_FILE_LOCK | G_FILE_SIGN | G_FILE_HISTORY); - if(BLO_write_file(CTX_data_main(C), filepath, fileflags, op->reports, NULL) == 0) { + if (BLO_write_file(CTX_data_main(C), filepath, fileflags, op->reports, NULL) == 0) { printf("fail\n"); return OPERATOR_CANCELLED; } @@ -889,7 +890,7 @@ void WM_autosave_init(wmWindowManager *wm) { wm_autosave_timer_ended(wm); - if(U.flag & USER_AUTOSAVE) + if (U.flag & USER_AUTOSAVE) wm->autosavetimer= WM_event_add_timer(wm, NULL, TIMERAUTOSAVE, U.savetime*60.0); } @@ -903,9 +904,9 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w WM_event_remove_timer(wm, NULL, wm->autosavetimer); /* if a modal operator is running, don't autosave, but try again in 10 seconds */ - for(win=wm->windows.first; win; win=win->next) { - for(handler=win->modalhandlers.first; handler; handler=handler->next) { - if(handler->op) { + for (win=wm->windows.first; win; win=win->next) { + for (handler=win->modalhandlers.first; handler; handler=handler->next) { + if (handler->op) { wm->autosavetimer= WM_event_add_timer(wm, NULL, TIMERAUTOSAVE, 10.0); return; } @@ -926,7 +927,7 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w void wm_autosave_timer_ended(wmWindowManager *wm) { - if(wm->autosavetimer) { + if (wm->autosavetimer) { WM_event_remove_timer(wm, NULL, wm->autosavetimer); wm->autosavetimer= NULL; } @@ -938,12 +939,12 @@ void wm_autosave_delete(void) wm_autosave_location(filename); - if(BLI_exists(filename)) { + if (BLI_exists(filename)) { char str[FILE_MAX]; BLI_make_file_string("/", str, BLI_temporary_dir(), "quit.blend"); /* if global undo; remove tempsave, otherwise rename */ - if(U.uiflag & USER_GLOBALUNDO) BLI_delete(filename, 0, 0); + if (U.uiflag & USER_GLOBALUNDO) BLI_delete(filename, 0, 0); else BLI_rename(filename, str); } } diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index 46f307d5ee5..a2630b5c6e1 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -81,13 +81,14 @@ wmGesture *WM_gesture_new(bContext *C, wmEvent *event, int type) gesture->customdata= rect; rect->xmin = event->x - sx; rect->ymin = event->y - sy; - if(type==WM_GESTURE_CIRCLE) { + if (type==WM_GESTURE_CIRCLE) { #ifdef GESTURE_MEMORY rect->xmax = circle_select_size; #else rect->xmax = 25; // XXX temp #endif - } else { + } + else { rect->xmax = event->x - sx; rect->ymax = event->y - sy; } @@ -108,7 +109,7 @@ void WM_gesture_end(bContext *C, wmGesture *gesture) { wmWindow *win= CTX_wm_window(C); - if(win->tweak==gesture) + if (win->tweak==gesture) win->tweak= NULL; BLI_remlink(&win->gesture, gesture); MEM_freeN(gesture->customdata); @@ -119,7 +120,7 @@ void WM_gestures_remove(bContext *C) { wmWindow *win= CTX_wm_window(C); - while(win->gesture.first) + while (win->gesture.first) WM_gesture_end(C, win->gesture.first); } @@ -127,32 +128,32 @@ void WM_gestures_remove(bContext *C) /* tweak and line gestures */ int wm_gesture_evaluate(wmGesture *gesture) { - if(gesture->type==WM_GESTURE_TWEAK) { + if (gesture->type==WM_GESTURE_TWEAK) { rcti *rect= gesture->customdata; int dx= rect->xmax - rect->xmin; int dy= rect->ymax - rect->ymin; - if(ABS(dx)+ABS(dy) > U.tweak_threshold) { + if (ABS(dx)+ABS(dy) > U.tweak_threshold) { int theta= (int)floor(4.0f*atan2f((float)dy, (float)dx)/(float)M_PI + 0.5f); int val= EVT_GESTURE_W; - if(theta==0) val= EVT_GESTURE_E; - else if(theta==1) val= EVT_GESTURE_NE; - else if(theta==2) val= EVT_GESTURE_N; - else if(theta==3) val= EVT_GESTURE_NW; - else if(theta==-1) val= EVT_GESTURE_SE; - else if(theta==-2) val= EVT_GESTURE_S; - else if(theta==-3) val= EVT_GESTURE_SW; + if (theta==0) val= EVT_GESTURE_E; + else if (theta==1) val= EVT_GESTURE_NE; + else if (theta==2) val= EVT_GESTURE_N; + else if (theta==3) val= EVT_GESTURE_NW; + else if (theta==-1) val= EVT_GESTURE_SE; + else if (theta==-2) val= EVT_GESTURE_S; + else if (theta==-3) val= EVT_GESTURE_SW; #if 0 /* debug */ - if(val==1) printf("tweak north\n"); - if(val==2) printf("tweak north-east\n"); - if(val==3) printf("tweak east\n"); - if(val==4) printf("tweak south-east\n"); - if(val==5) printf("tweak south\n"); - if(val==6) printf("tweak south-west\n"); - if(val==7) printf("tweak west\n"); - if(val==8) printf("tweak north-west\n"); + if (val==1) printf("tweak north\n"); + if (val==2) printf("tweak north-east\n"); + if (val==3) printf("tweak east\n"); + if (val==4) printf("tweak south-east\n"); + if (val==5) printf("tweak south\n"); + if (val==6) printf("tweak south-west\n"); + if (val==7) printf("tweak west\n"); + if (val==8) printf("tweak north-west\n"); #endif return val; } @@ -250,7 +251,7 @@ static void draw_filled_lasso(wmGesture *gt) } /* highly unlikely this will fail, but could crash if (gt->points == 0) */ - if(firstv) { + if (firstv) { BLI_addfilledge(firstv, v); BLI_edgefill(0); @@ -280,9 +281,9 @@ static void wm_gesture_draw_lasso(wmGesture *gt) glColor3ub(96, 96, 96); glLineStipple(1, 0xAAAA); glBegin(GL_LINE_STRIP); - for(i=0; ipoints; i++, lasso+=2) + for (i=0; ipoints; i++, lasso+=2) glVertex2sv(lasso); - if(gt->type==WM_GESTURE_LASSO) + if (gt->type==WM_GESTURE_LASSO) glVertex2sv((short *)gt->customdata); glEnd(); @@ -290,9 +291,9 @@ static void wm_gesture_draw_lasso(wmGesture *gt) glLineStipple(1, 0x5555); glBegin(GL_LINE_STRIP); lasso= (short *)gt->customdata; - for(i=0; ipoints; i++, lasso+=2) + for (i=0; ipoints; i++, lasso+=2) glVertex2sv(lasso); - if(gt->type==WM_GESTURE_LASSO) + if (gt->type==WM_GESTURE_LASSO) glVertex2sv((short *)gt->customdata); glEnd(); @@ -322,27 +323,27 @@ void wm_gesture_draw(wmWindow *win) { wmGesture *gt= (wmGesture *)win->gesture.first; - for(; gt; gt= gt->next) { + for (; gt; gt= gt->next) { /* all in subwindow space */ wmSubWindowSet(win, gt->swinid); - if(gt->type==WM_GESTURE_RECT) + if (gt->type==WM_GESTURE_RECT) wm_gesture_draw_rect(gt); -// else if(gt->type==WM_GESTURE_TWEAK) +// else if (gt->type==WM_GESTURE_TWEAK) // wm_gesture_draw_line(gt); - else if(gt->type==WM_GESTURE_CIRCLE) + else if (gt->type==WM_GESTURE_CIRCLE) wm_gesture_draw_circle(gt); - else if(gt->type==WM_GESTURE_CROSS_RECT) { - if(gt->mode==1) + else if (gt->type==WM_GESTURE_CROSS_RECT) { + if (gt->mode==1) wm_gesture_draw_rect(gt); else wm_gesture_draw_cross(win, gt); } - else if(gt->type==WM_GESTURE_LINES) + else if (gt->type==WM_GESTURE_LINES) wm_gesture_draw_lasso(gt); - else if(gt->type==WM_GESTURE_LASSO) + else if (gt->type==WM_GESTURE_LASSO) wm_gesture_draw_lasso(gt); - else if(gt->type==WM_GESTURE_STRAIGHTLINE) + else if (gt->type==WM_GESTURE_STRAIGHTLINE) wm_gesture_draw_line(gt); } } @@ -353,7 +354,7 @@ void wm_gesture_tag_redraw(bContext *C) bScreen *screen= CTX_wm_screen(C); ARegion *ar= CTX_wm_region(C); - if(screen) + if (screen) screen->do_draw_gesture= 1; wm_tag_redraw_overlay(win, ar); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 9656a45509c..0255a2249f5 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -193,7 +193,7 @@ void WM_init(bContext *C, int argc, const char **argv) /* allow a path of "", this is what happens when making a new file */ #if 0 - if(G.main->name[0] == 0) + if (G.main->name[0] == 0) BLI_make_file_string("/", G.main->name, BLI_getDefaultDocumentFolder(), "untitled.blend"); #endif @@ -202,11 +202,11 @@ void WM_init(bContext *C, int argc, const char **argv) void WM_init_splash(bContext *C) { - if((U.uiflag & USER_SPLASH_DISABLE) == 0) { + if ((U.uiflag & USER_SPLASH_DISABLE) == 0) { wmWindowManager *wm= CTX_wm_manager(C); wmWindow *prevwin= CTX_wm_window(C); - if(wm->windows.first) { + if (wm->windows.first) { CTX_wm_window_set(C, wm->windows.first); WM_operator_name_call(C, "WM_OT_splash", WM_OP_INVOKE_DEFAULT, NULL); CTX_wm_window_set(C, prevwin); @@ -233,7 +233,7 @@ int WM_init_game(bContext *C) win = wm->windows.first; //first to get a valid window - if(win) + if (win) CTX_wm_window_set(C, win); sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_VIEW3D, 0); @@ -247,25 +247,25 @@ int WM_init_game(bContext *C) CTX_wm_region_set(C, ar); /* disable quad view */ - if(ar->alignment == RGN_ALIGN_QSPLIT) + 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)) { + 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) { + if (!sa->full) { ED_screen_full_toggle(C, win, sa); } /* Fullscreen */ - if((scene->gm.playerflag & GAME_PLAYER_FULLSCREEN)) { + if ((scene->gm.playerflag & GAME_PLAYER_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); ar->winx = ar->winrct.xmax + 1; @@ -308,7 +308,7 @@ static void free_openrecent(void) { struct RecentFile *recent; - for(recent = G.recent_files.first; recent; recent=recent->next) + for (recent = G.recent_files.first; recent; recent=recent->next) MEM_freeN(recent->filepath); BLI_freelistN(&(G.recent_files)); @@ -335,11 +335,11 @@ void WM_exit_ext(bContext *C, const short do_python) /* first wrap up running stuff, we assume only the active WM is running */ /* modal handlers are on window level freed, others too? */ /* note; same code copied in wm_files.c */ - if(C && CTX_wm_manager(C)) { + if (C && CTX_wm_manager(C)) { WM_jobs_stop_all(CTX_wm_manager(C)); - for(win= CTX_wm_manager(C)->windows.first; win; win= win->next) { + for (win= CTX_wm_manager(C)->windows.first; win; win= win->next) { CTX_wm_window_set(C, win); /* needed by operator close callbacks */ WM_event_remove_handlers(C, &win->handlers); @@ -352,7 +352,7 @@ void WM_exit_ext(bContext *C, const short do_python) WM_menutype_free(); /* all non-screen and non-space stuff editors did, like editmode */ - if(C) + if (C) ED_editors_exit(C); // XXX @@ -368,7 +368,7 @@ void WM_exit_ext(bContext *C, const short do_python) ED_preview_free_dbase(); /* frees a Main dbase, before free_blender! */ - if(C && CTX_wm_manager(C)) + if (C && CTX_wm_manager(C)) wm_free_reports(C); /* before free_blender! - since the ListBases get freed there */ seq_free_clipboard(); /* sequencer.c */ @@ -399,7 +399,7 @@ void WM_exit_ext(bContext *C, const short do_python) #ifdef WITH_PYTHON /* option not to close python so we can use 'atexit' */ - if(do_python) { + if (do_python) { /* XXX - old note */ /* before free_blender so py's gc happens while library still exists */ /* needed at least for a rare sigsegv that can happen in pydrivers */ @@ -438,7 +438,7 @@ void WM_exit_ext(bContext *C, const short do_python) GHOST_DisposeSystemPaths(); - if(MEM_get_memory_blocks_in_use()!=0) { + if (MEM_get_memory_blocks_in_use()!=0) { printf("Error: Not freed memory blocks: %d\n", MEM_get_memory_blocks_in_use()); MEM_printmemlist(); } @@ -448,7 +448,7 @@ void WM_exit_ext(bContext *C, const short do_python) #ifdef WIN32 /* ask user to press enter when in debug mode */ - if(G.f & G_DEBUG) { + if (G.f & G_DEBUG) { printf("press enter key to exit...\n\n"); getchar(); } diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index ba2df4e2363..3b3280a6f62 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -136,8 +136,8 @@ static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const char *name) { wmJob *steve, *found=NULL; - for(steve= wm->jobs.first; steve; steve= steve->next) - if(steve->owner==owner) { + for (steve= wm->jobs.first; steve; steve= steve->next) + if (steve->owner==owner) { found= steve; if (name && strcmp(steve->name, name)==0) return steve; @@ -155,7 +155,7 @@ wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char * { wmJob *steve= wm_job_find(wm, owner, name); - if(steve==NULL) { + if (steve==NULL) { steve= MEM_callocN(sizeof(wmJob), "new job"); BLI_addtail(&wm->jobs, steve); @@ -173,9 +173,9 @@ int WM_jobs_test(wmWindowManager *wm, void *owner) { wmJob *steve; - for(steve= wm->jobs.first; steve; steve= steve->next) - if(steve->owner==owner) - if(steve->running) + for (steve= wm->jobs.first; steve; steve= steve->next) + if (steve->owner==owner) + if (steve->running) return 1; return 0; } @@ -209,7 +209,8 @@ void* WM_jobs_get_customdata(wmJob * steve) { if (!steve->customdata) { return steve->run_customdata; - } else { + } + else { return steve->customdata; } } @@ -217,13 +218,13 @@ void* WM_jobs_get_customdata(wmJob * steve) void WM_jobs_customdata(wmJob *steve, void *customdata, void (*free)(void *)) { /* pending job? just free */ - if(steve->customdata) + if (steve->customdata) steve->free(steve->customdata); steve->customdata= customdata; steve->free= free; - if(steve->running) { + if (steve->running) { /* signal job to end */ steve->stop= 1; } @@ -265,30 +266,30 @@ static void wm_jobs_test_suspend_stop(wmWindowManager *wm, wmJob *test) int suspend= 0; /* job added with suspend flag, we wait 1 timer step before activating it */ - if(test->flag & WM_JOB_SUSPEND) { + if (test->flag & WM_JOB_SUSPEND) { suspend= 1; test->flag &= ~WM_JOB_SUSPEND; } else { /* check other jobs */ - for(steve= wm->jobs.first; steve; steve= steve->next) { + for (steve= wm->jobs.first; steve; steve= steve->next) { /* obvious case, no test needed */ - if(steve==test || !steve->running) continue; + if (steve==test || !steve->running) continue; /* if new job is not render, then check for same startjob */ - if(0==(test->flag & WM_JOB_EXCL_RENDER)) - if(steve->startjob!=test->startjob) + if (0==(test->flag & WM_JOB_EXCL_RENDER)) + if (steve->startjob!=test->startjob) continue; /* if new job is render, any render job should be stopped */ - if(test->flag & WM_JOB_EXCL_RENDER) - if(0==(steve->flag & WM_JOB_EXCL_RENDER)) + if (test->flag & WM_JOB_EXCL_RENDER) + if (0==(steve->flag & WM_JOB_EXCL_RENDER)) continue; suspend= 1; /* if this job has higher priority, stop others */ - if(test->flag & WM_JOB_PRIORITY) { + if (test->flag & WM_JOB_PRIORITY) { steve->stop= 1; // printf("job stopped: %s\n", steve->name); } @@ -304,18 +305,18 @@ static void wm_jobs_test_suspend_stop(wmWindowManager *wm, wmJob *test) /* if different owner starts existing startjob, it suspends itself */ void WM_jobs_start(wmWindowManager *wm, wmJob *steve) { - if(steve->running) { + if (steve->running) { /* signal job to end and restart */ steve->stop= 1; // printf("job started a running job, ending... %s\n", steve->name); } else { - if(steve->customdata && steve->startjob) { + if (steve->customdata && steve->startjob) { wm_jobs_test_suspend_stop(wm, steve); - if(steve->suspended==0) { + if (steve->suspended==0) { /* copy to ensure proper free in end */ steve->run_customdata= steve->customdata; steve->run_free= steve->free; @@ -323,7 +324,7 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *steve) steve->customdata= NULL; steve->running= 1; - if(steve->initjob) + if (steve->initjob) steve->initjob(steve->run_customdata); steve->stop= 0; @@ -337,7 +338,7 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *steve) } /* restarted job has timer already */ - if(steve->wt==NULL) + if (steve->wt==NULL) steve->wt= WM_event_add_timer(wm, steve->win, TIMERJOBS, steve->timestep); } else printf("job fails, not initialized\n"); @@ -347,20 +348,20 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *steve) /* stop job, free data completely */ static void wm_jobs_kill_job(wmWindowManager *wm, wmJob *steve) { - if(steve->running) { + if (steve->running) { /* signal job to end */ steve->stop= 1; BLI_end_threads(&steve->threads); - if(steve->endjob) + if (steve->endjob) steve->endjob(steve->run_customdata); } - if(steve->wt) + if (steve->wt) WM_event_remove_timer(wm, steve->win, steve->wt); - if(steve->customdata) + if (steve->customdata) steve->free(steve->customdata); - if(steve->run_customdata) + if (steve->run_customdata) steve->run_free(steve->run_customdata); /* remove steve */ @@ -373,7 +374,7 @@ void WM_jobs_stop_all(wmWindowManager *wm) { wmJob *steve; - while((steve= wm->jobs.first)) + while ((steve= wm->jobs.first)) wm_jobs_kill_job(wm, steve); } @@ -383,9 +384,9 @@ void WM_jobs_stop(wmWindowManager *wm, void *owner, void *startjob) { wmJob *steve; - for(steve= wm->jobs.first; steve; steve= steve->next) - if(steve->owner==owner || steve->startjob==startjob) - if(steve->running) + for (steve= wm->jobs.first; steve; steve= steve->next) + if (steve->owner==owner || steve->startjob==startjob) + if (steve->running) steve->stop= 1; } @@ -395,12 +396,13 @@ void WM_jobs_kill(wmWindowManager *wm, void *owner, void (*startjob)(void *, sho wmJob *steve; steve= wm->jobs.first; - while(steve) { - if(steve->owner==owner || steve->startjob==startjob) { + while (steve) { + if (steve->owner==owner || steve->startjob==startjob) { wmJob* bill = steve; steve= steve->next; wm_jobs_kill_job(wm, bill); - } else { + } + else { steve= steve->next; } } @@ -412,8 +414,8 @@ void wm_jobs_timer_ended(wmWindowManager *wm, wmTimer *wt) { wmJob *steve; - for(steve= wm->jobs.first; steve; steve= steve->next) { - if(steve->wt==wt) { + for (steve= wm->jobs.first; steve; steve= steve->next) { + if (steve->wt==wt) { wm_jobs_kill_job(wm, steve); return; } @@ -428,19 +430,19 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) float jobs_progress=0; - for(; steve; steve= stevenext) { + for (; steve; steve= stevenext) { stevenext= steve->next; - if(steve->wt==wt) { + if (steve->wt==wt) { /* running threads */ - if(steve->threads.first) { + if (steve->threads.first) { /* always call note and update when ready */ - if(steve->do_update || steve->ready) { - if(steve->update) + if (steve->do_update || steve->ready) { + if (steve->update) steve->update(steve->run_customdata); - if(steve->note) + if (steve->note) WM_event_add_notifier(C, steve->note, NULL); if (steve->flag & WM_JOB_PROGRESS) @@ -448,8 +450,8 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) steve->do_update= 0; } - if(steve->ready) { - if(steve->endjob) + if (steve->ready) { + if (steve->endjob) steve->endjob(steve->run_customdata); /* free own data */ @@ -463,13 +465,13 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) steve->running= 0; BLI_end_threads(&steve->threads); - if(steve->endnote) + if (steve->endnote) WM_event_add_notifier(C, steve->endnote, NULL); WM_event_add_notifier(C, NC_WM|ND_JOB, NULL); /* new job added for steve? */ - if(steve->customdata) { + if (steve->customdata) { // printf("job restarted with new data %s\n", steve->name); WM_jobs_start(wm, steve); } @@ -481,18 +483,19 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) BLI_remlink(&wm->jobs, steve); MEM_freeN(steve); } - } else if (steve->flag & WM_JOB_PROGRESS) { + } + else if (steve->flag & WM_JOB_PROGRESS) { /* accumulate global progress for running jobs */ jobs_progress++; total_progress += steve->progress; } } - else if(steve->suspended) { + else if (steve->suspended) { WM_jobs_start(wm, steve); } } - else if(steve->threads.first && !steve->ready) { - if(steve->flag & WM_JOB_PROGRESS) { + else if (steve->threads.first && !steve->ready) { + if (steve->flag & WM_JOB_PROGRESS) { /* accumulate global progress for running jobs */ jobs_progress++; total_progress += steve->progress; @@ -501,12 +504,13 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) } /* on file load 'winactive' can be NULL, possibly it should not happen but for now do a NULL check - campbell */ - if(wm->winactive) { + if (wm->winactive) { /* if there are running jobs, set the global progress indicator */ if (jobs_progress > 0) { float progress = total_progress / (float)jobs_progress; WM_progress_set(wm->winactive, progress); - } else { + } + else { WM_progress_clear(wm->winactive); } } @@ -516,8 +520,8 @@ int WM_jobs_has_running(wmWindowManager *wm) { wmJob *steve; - for(steve= wm->jobs.first; steve; steve= steve->next) - if(steve->running) + for (steve= wm->jobs.first; steve; steve= steve->next) + if (steve->running) return 1; return 0; diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 8e218e405b6..8814a044901 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -70,7 +70,7 @@ static wmKeyMapItem *wm_keymap_item_copy(wmKeyMapItem *kmi) kmin->prev= kmin->next= NULL; kmin->flag &= ~KMI_UPDATE; - if(kmin->properties) { + if (kmin->properties) { kmin->ptr= MEM_callocN(sizeof(PointerRNA), "UserKeyMapItemPtr"); WM_operator_properties_create(kmin->ptr, kmin->idname); @@ -84,7 +84,7 @@ static wmKeyMapItem *wm_keymap_item_copy(wmKeyMapItem *kmi) static void wm_keymap_item_free(wmKeyMapItem *kmi) { /* not kmi itself */ - if(kmi->ptr) { + if (kmi->ptr) { WM_operator_properties_free(kmi->ptr); MEM_freeN(kmi->ptr); } @@ -98,14 +98,14 @@ static void wm_keymap_item_properties_set(wmKeyMapItem *kmi) static int wm_keymap_item_equals_result(wmKeyMapItem *a, wmKeyMapItem *b) { - if(strcmp(a->idname, b->idname) != 0) + if (strcmp(a->idname, b->idname) != 0) return 0; - if(!((a->ptr==NULL && b->ptr==NULL) || + if (!((a->ptr==NULL && b->ptr==NULL) || (a->ptr && b->ptr && IDP_EqualsProperties(a->ptr->data, b->ptr->data)))) return 0; - if((a->flag & KMI_INACTIVE) != (b->flag & KMI_INACTIVE)) + if ((a->flag & KMI_INACTIVE) != (b->flag & KMI_INACTIVE)) return 0; return (a->propvalue == b->propvalue); @@ -144,9 +144,9 @@ static wmKeyMapDiffItem *wm_keymap_diff_item_copy(wmKeyMapDiffItem *kmdi) wmKeyMapDiffItem *kmdin = MEM_dupallocN(kmdi); kmdin->next = kmdin->prev = NULL; - if(kmdi->add_item) + if (kmdi->add_item) kmdin->add_item = wm_keymap_item_copy(kmdi->add_item); - if(kmdi->remove_item) + if (kmdi->remove_item) kmdin->remove_item = wm_keymap_item_copy(kmdi->remove_item); return kmdin; @@ -154,11 +154,11 @@ static wmKeyMapDiffItem *wm_keymap_diff_item_copy(wmKeyMapDiffItem *kmdi) static void wm_keymap_diff_item_free(wmKeyMapDiffItem *kmdi) { - if(kmdi->remove_item) { + if (kmdi->remove_item) { wm_keymap_item_free(kmdi->remove_item); MEM_freeN(kmdi->remove_item); } - if(kmdi->add_item) { + if (kmdi->add_item) { wm_keymap_item_free(kmdi->add_item); MEM_freeN(kmdi->add_item); } @@ -205,7 +205,7 @@ void WM_keyconfig_free(wmKeyConfig *keyconf) { wmKeyMap *km; - while((km= keyconf->keymaps.first)) { + while ((km= keyconf->keymaps.first)) { WM_keymap_free(km); BLI_freelinkN(&keyconf->keymaps, km); } @@ -217,8 +217,8 @@ static wmKeyConfig *wm_keyconfig_list_find(ListBase *lb, char *idname) { wmKeyConfig *kc; - for(kc= lb->first; kc; kc= kc->next) - if(0==strncmp(idname, kc->idname, KMAP_MAX_NAME)) + for (kc= lb->first; kc; kc= kc->next) + if (0==strncmp(idname, kc->idname, KMAP_MAX_NAME)) return kc; return NULL; @@ -230,7 +230,7 @@ static wmKeyConfig *WM_keyconfig_active(wmWindowManager *wm) /* first try from preset */ keyconf= wm_keyconfig_list_find(&wm->keyconfigs, U.keyconfigstr); - if(keyconf) + if (keyconf) return keyconf; /* otherwise use default */ @@ -275,12 +275,12 @@ static wmKeyMap *wm_keymap_copy(wmKeyMap *keymap) keymapn->items.first= keymapn->items.last= NULL; keymapn->flag &= ~(KEYMAP_UPDATE|KEYMAP_EXPANDED); - for(kmdi=keymap->diff_items.first; kmdi; kmdi=kmdi->next) { + for (kmdi=keymap->diff_items.first; kmdi; kmdi=kmdi->next) { kmdin= wm_keymap_diff_item_copy(kmdi); BLI_addtail(&keymapn->items, kmdin); } - for(kmi=keymap->items.first; kmi; kmi=kmi->next) { + for (kmi=keymap->items.first; kmi; kmi=kmi->next) { kmin= wm_keymap_item_copy(kmi); BLI_addtail(&keymapn->items, kmin); } @@ -293,10 +293,10 @@ void WM_keymap_free(wmKeyMap *keymap) wmKeyMapItem *kmi; wmKeyMapDiffItem *kmdi; - for(kmdi=keymap->diff_items.first; kmdi; kmdi=kmdi->next) + for (kmdi=keymap->diff_items.first; kmdi; kmdi=kmdi->next) wm_keymap_diff_item_free(kmdi); - for(kmi=keymap->items.first; kmi; kmi=kmi->next) + for (kmi=keymap->items.first; kmi; kmi=kmi->next) wm_keymap_item_free(kmi); BLI_freelistN(&keymap->diff_items); @@ -309,7 +309,7 @@ static void keymap_event_set(wmKeyMapItem *kmi, short type, short val, int modif kmi->val= val; kmi->keymodifier= keymodifier; - if(modifier == KM_ANY) { + if (modifier == KM_ANY) { kmi->shift= kmi->ctrl= kmi->alt= kmi->oskey= KM_ANY; } else { @@ -325,7 +325,8 @@ static void keymap_item_set_id(wmKeyMap *keymap, wmKeyMapItem *kmi) keymap->kmi_id++; if ((keymap->flag & KEYMAP_USER) == 0) { kmi->id = keymap->kmi_id; - } else { + } + else { kmi->id = -keymap->kmi_id; // User defined keymap entries have negative ids } } @@ -335,10 +336,10 @@ wmKeyMapItem *WM_keymap_verify_item(wmKeyMap *keymap, const char *idname, int ty { wmKeyMapItem *kmi; - for(kmi = keymap->items.first; kmi; kmi = kmi->next) - if(strncmp(kmi->idname, idname, OP_MAX_TYPENAME)==0) + for (kmi = keymap->items.first; kmi; kmi = kmi->next) + if (strncmp(kmi->idname, idname, OP_MAX_TYPENAME)==0) break; - if(kmi==NULL) { + if (kmi==NULL) { kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry"); BLI_addtail(&keymap->items, kmi); @@ -380,8 +381,8 @@ wmKeyMapItem *WM_keymap_add_menu(wmKeyMap *keymap, const char *idname, int type, void WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi) { - if(BLI_findindex(&keymap->items, kmi) != -1) { - if(kmi->ptr) { + if (BLI_findindex(&keymap->items, kmi) != -1) { + if (kmi->ptr) { WM_operator_properties_free(kmi->ptr); MEM_freeN(kmi->ptr); } @@ -401,7 +402,7 @@ static void wm_keymap_addon_add(wmKeyMap *keymap, wmKeyMap *addonmap) { wmKeyMapItem *kmi, *kmin; - for(kmi=addonmap->items.first; kmi; kmi=kmi->next) { + for (kmi=addonmap->items.first; kmi; kmi=kmi->next) { kmin = wm_keymap_item_copy(kmi); keymap_item_set_id(keymap, kmin); BLI_addhead(&keymap->items, kmin); @@ -412,8 +413,8 @@ static wmKeyMapItem *wm_keymap_find_item_equals(wmKeyMap *km, wmKeyMapItem *need { wmKeyMapItem *kmi; - for(kmi=km->items.first; kmi; kmi=kmi->next) - if(wm_keymap_item_equals(kmi, needle)) + for (kmi=km->items.first; kmi; kmi=kmi->next) + if (wm_keymap_item_equals(kmi, needle)) return kmi; return NULL; @@ -423,8 +424,8 @@ static wmKeyMapItem *wm_keymap_find_item_equals_result(wmKeyMap *km, wmKeyMapIte { wmKeyMapItem *kmi; - for(kmi=km->items.first; kmi; kmi=kmi->next) - if(wm_keymap_item_equals_result(kmi, needle)) + for (kmi=km->items.first; kmi; kmi=kmi->next) + if (wm_keymap_item_equals_result(kmi, needle)) return kmi; return NULL; @@ -435,16 +436,16 @@ static void wm_keymap_diff(wmKeyMap *diff_km, wmKeyMap *from_km, wmKeyMap *to_km wmKeyMapItem *kmi, *to_kmi, *orig_kmi; wmKeyMapDiffItem *kmdi; - for(kmi=from_km->items.first; kmi; kmi=kmi->next) { + for (kmi=from_km->items.first; kmi; kmi=kmi->next) { to_kmi = WM_keymap_item_find_id(to_km, kmi->id); - if(!to_kmi) { + if (!to_kmi) { /* remove item */ kmdi = MEM_callocN(sizeof(wmKeyMapDiffItem), "wmKeyMapDiffItem"); kmdi->remove_item = wm_keymap_item_copy(kmi); BLI_addtail(&diff_km->diff_items, kmdi); } - else if(to_kmi && !wm_keymap_item_equals(kmi, to_kmi)) { + else if (to_kmi && !wm_keymap_item_equals(kmi, to_kmi)) { /* replace item */ kmdi = MEM_callocN(sizeof(wmKeyMapDiffItem), "wmKeyMapDiffItem"); kmdi->remove_item = wm_keymap_item_copy(kmi); @@ -453,21 +454,21 @@ static void wm_keymap_diff(wmKeyMap *diff_km, wmKeyMap *from_km, wmKeyMap *to_km } /* sync expanded flag back to original so we don't loose it on repatch */ - if(to_kmi) { + if (to_kmi) { orig_kmi = WM_keymap_item_find_id(orig_km, kmi->id); - if(!orig_kmi) + if (!orig_kmi) orig_kmi = wm_keymap_find_item_equals(addon_km, kmi); - if(orig_kmi) { + if (orig_kmi) { orig_kmi->flag &= ~KMI_EXPANDED; orig_kmi->flag |= (to_kmi->flag & KMI_EXPANDED); } } } - for(kmi=to_km->items.first; kmi; kmi=kmi->next) { - if(kmi->id < 0) { + for (kmi=to_km->items.first; kmi; kmi=kmi->next) { + if (kmi->id < 0) { /* add item */ kmdi = MEM_callocN(sizeof(wmKeyMapDiffItem), "wmKeyMapDiffItem"); kmdi->add_item = wm_keymap_item_copy(kmi); @@ -481,23 +482,23 @@ static void wm_keymap_patch(wmKeyMap *km, wmKeyMap *diff_km) wmKeyMapDiffItem *kmdi; wmKeyMapItem *kmi_remove, *kmi_add; - for(kmdi=diff_km->diff_items.first; kmdi; kmdi=kmdi->next) { + for (kmdi=diff_km->diff_items.first; kmdi; kmdi=kmdi->next) { /* find item to remove */ kmi_remove = NULL; - if(kmdi->remove_item) { + if (kmdi->remove_item) { kmi_remove = wm_keymap_find_item_equals(km, kmdi->remove_item); - if(!kmi_remove) + if (!kmi_remove) kmi_remove = wm_keymap_find_item_equals_result(km, kmdi->remove_item); } /* add item */ - if(kmdi->add_item) { + if (kmdi->add_item) { /* only if nothing to remove or item to remove found */ - if(!kmdi->remove_item || kmi_remove) { + if (!kmdi->remove_item || kmi_remove) { kmi_add = wm_keymap_item_copy(kmdi->add_item); kmi_add->flag |= KMI_USER_MODIFIED; - if(kmi_remove) { + if (kmi_remove) { kmi_add->flag &= ~KMI_EXPANDED; kmi_add->flag |= (kmi_remove->flag & KMI_EXPANDED); kmi_add->id = kmi_remove->id; @@ -511,7 +512,7 @@ static void wm_keymap_patch(wmKeyMap *km, wmKeyMap *diff_km) } /* remove item */ - if(kmi_remove) { + if (kmi_remove) { wm_keymap_item_free(kmi_remove); BLI_freelinkN(&km->items, kmi_remove); } @@ -525,14 +526,14 @@ static wmKeyMap *wm_keymap_patch_update(ListBase *lb, wmKeyMap *defaultmap, wmKe /* remove previous keymap in list, we will replace it */ km = WM_keymap_list_find(lb, defaultmap->idname, defaultmap->spaceid, defaultmap->regionid); - if(km) { + if (km) { expanded = (km->flag & (KEYMAP_EXPANDED|KEYMAP_CHILDREN_EXPANDED)); WM_keymap_free(km); BLI_freelinkN(lb, km); } /* copy new keymap from an existing one */ - if(usermap && !(usermap->flag & KEYMAP_DIFF)) { + if (usermap && !(usermap->flag & KEYMAP_DIFF)) { /* for compatibiltiy with old user preferences with non-diff * keymaps we override the original entirely */ wmKeyMapItem *kmi, *orig_kmi; @@ -540,12 +541,12 @@ static wmKeyMap *wm_keymap_patch_update(ListBase *lb, wmKeyMap *defaultmap, wmKe km = wm_keymap_copy(usermap); /* try to find corresponding id's for items */ - for(kmi=km->items.first; kmi; kmi=kmi->next) { + for (kmi=km->items.first; kmi; kmi=kmi->next) { orig_kmi = wm_keymap_find_item_equals(defaultmap, kmi); - if(!orig_kmi) + if (!orig_kmi) orig_kmi = wm_keymap_find_item_equals_result(defaultmap, kmi); - if(orig_kmi) + if (orig_kmi) kmi->id = orig_kmi->id; else kmi->id = -(km->kmi_id++); @@ -557,16 +558,16 @@ static wmKeyMap *wm_keymap_patch_update(ListBase *lb, wmKeyMap *defaultmap, wmKe km = wm_keymap_copy(defaultmap); /* add addon keymap items */ - if(addonmap) + if (addonmap) wm_keymap_addon_add(km, addonmap); /* tag as being user edited */ - if(usermap) + if (usermap) km->flag |= KEYMAP_USER_MODIFIED; km->flag |= KEYMAP_USER|expanded; /* apply user changes of diff keymap */ - if(usermap && (usermap->flag & KEYMAP_DIFF)) + if (usermap && (usermap->flag & KEYMAP_DIFF)) wm_keymap_patch(km, usermap); /* add to list */ @@ -582,14 +583,14 @@ static void wm_keymap_diff_update(ListBase *lb, wmKeyMap *defaultmap, wmKeyMap * /* create temporary default + addon keymap for diff */ origmap = defaultmap; - if(addonmap) { + if (addonmap) { defaultmap = wm_keymap_copy(defaultmap); wm_keymap_addon_add(defaultmap, addonmap); } /* remove previous diff keymap in list, we will replace it */ prevmap = WM_keymap_list_find(lb, km->idname, km->spaceid, km->regionid); - if(prevmap) { + if (prevmap) { WM_keymap_free(prevmap); BLI_freelinkN(lb, prevmap); } @@ -597,12 +598,12 @@ static void wm_keymap_diff_update(ListBase *lb, wmKeyMap *defaultmap, wmKeyMap * /* create diff keymap */ diffmap= wm_keymap_new(km->idname, km->spaceid, km->regionid); diffmap->flag |= KEYMAP_DIFF; - if(defaultmap->flag & KEYMAP_MODAL) + if (defaultmap->flag & KEYMAP_MODAL) diffmap->flag |= KEYMAP_MODAL; wm_keymap_diff(diffmap, defaultmap, km, origmap, addonmap); /* add to list if not empty */ - if(diffmap->diff_items.first) { + if (diffmap->diff_items.first) { BLI_addtail(lb, diffmap); } else { @@ -611,7 +612,7 @@ static void wm_keymap_diff_update(ListBase *lb, wmKeyMap *defaultmap, wmKeyMap * } /* free temporary default map */ - if(addonmap) { + if (addonmap) { WM_keymap_free(defaultmap); MEM_freeN(defaultmap); } @@ -627,9 +628,9 @@ wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int { wmKeyMap *km; - for(km= lb->first; km; km= km->next) - if(km->spaceid==spaceid && km->regionid==regionid) - if(0==strncmp(idname, km->idname, KMAP_MAX_NAME)) + for (km= lb->first; km; km= km->next) + if (km->spaceid==spaceid && km->regionid==regionid) + if (0==strncmp(idname, km->idname, KMAP_MAX_NAME)) return km; return NULL; @@ -639,7 +640,7 @@ wmKeyMap *WM_keymap_find(wmKeyConfig *keyconf, const char *idname, int spaceid, { wmKeyMap *km= WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid); - if(km==NULL) { + if (km==NULL) { km= wm_keymap_new(idname, spaceid, regionid); BLI_addtail(&keyconf->keymaps, km); @@ -666,12 +667,12 @@ wmKeyMap *WM_modalkeymap_add(wmKeyConfig *keyconf, const char *idname, EnumPrope km->flag |= KEYMAP_MODAL; km->modal_items= items; - if(!items) { + if (!items) { /* init modal items from default config */ wmWindowManager *wm = G.main->wm.first; wmKeyMap *defaultkm= WM_keymap_list_find(&wm->defaultconf->keymaps, km->idname, 0, 0); - if(defaultkm) { + if (defaultkm) { km->modal_items = defaultkm->modal_items; km->poll = defaultkm->poll; } @@ -684,9 +685,9 @@ wmKeyMap *WM_modalkeymap_get(wmKeyConfig *keyconf, const char *idname) { wmKeyMap *km; - for(km= keyconf->keymaps.first; km; km= km->next) - if(km->flag & KEYMAP_MODAL) - if(0==strncmp(idname, km->idname, KMAP_MAX_NAME)) + for (km= keyconf->keymaps.first; km; km= km->next) + if (km->flag & KEYMAP_MODAL) + if (0==strncmp(idname, km->idname, KMAP_MAX_NAME)) break; return km; @@ -713,7 +714,7 @@ void WM_modalkeymap_assign(wmKeyMap *km, const char *opname) { wmOperatorType *ot= WM_operatortype_find(opname, 0); - if(ot) + if (ot) ot->modalkeymap = km; else printf("error: modalkeymap_assign, unknown operator %s\n", opname); @@ -724,7 +725,7 @@ void WM_modalkeymap_assign(wmKeyMap *km, const char *opname) const char *WM_key_event_string(short type) { const char *name= NULL; - if(RNA_enum_name(event_type_items, (int)type, &name)) + if (RNA_enum_name(event_type_items, (int)type, &name)) return name; return ""; @@ -742,21 +743,22 @@ char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len) kmi->oskey == KM_ANY) { strcat(buf, "Any "); - } else { - if(kmi->shift) + } + else { + if (kmi->shift) strcat(buf, "Shift "); - if(kmi->ctrl) + if (kmi->ctrl) strcat(buf, "Ctrl "); - if(kmi->alt) + if (kmi->alt) strcat(buf, "Alt "); - if(kmi->oskey) + if (kmi->oskey) strcat(buf, "Cmd "); } - if(kmi->keymodifier) { + if (kmi->keymodifier) { strcat(buf, WM_key_event_string(kmi->keymodifier)); strcat(buf, " "); } @@ -777,25 +779,25 @@ static wmKeyMapItem *wm_keymap_item_find_handlers( wmKeyMapItem *kmi; /* find keymap item in handlers */ - for(handler=handlers->first; handler; handler=handler->next) { + for (handler=handlers->first; handler; handler=handler->next) { keymap= WM_keymap_active(wm, handler->keymap); - if(keymap && (!keymap->poll || keymap->poll((bContext*)C))) { - for(kmi=keymap->items.first; kmi; kmi=kmi->next) { + if (keymap && (!keymap->poll || keymap->poll((bContext*)C))) { + for (kmi=keymap->items.first; kmi; kmi=kmi->next) { - if(strcmp(kmi->idname, opname) == 0 && WM_key_event_string(kmi->type)[0]) { + if (strcmp(kmi->idname, opname) == 0 && WM_key_event_string(kmi->type)[0]) { if (hotkey) if (!ISHOTKEY(kmi->type)) continue; - if(compare_props) { - if(kmi->ptr && IDP_EqualsProperties(properties, kmi->ptr->data)) { - if(keymap_r) *keymap_r= keymap; + if (compare_props) { + if (kmi->ptr && IDP_EqualsProperties(properties, kmi->ptr->data)) { + if (keymap_r) *keymap_r= keymap; return kmi; } } else { - if(keymap_r) *keymap_r= keymap; + if (keymap_r) *keymap_r= keymap; return kmi; } } @@ -804,7 +806,7 @@ static wmKeyMapItem *wm_keymap_item_find_handlers( } /* ensure un-initialized keymap is never used */ - if(keymap_r) *keymap_r= NULL; + if (keymap_r) *keymap_r= NULL; return NULL; } @@ -818,39 +820,39 @@ static wmKeyMapItem *wm_keymap_item_find_props( wmKeyMapItem *found= NULL; /* look into multiple handler lists to find the item */ - if(win) + if (win) found= wm_keymap_item_find_handlers(C, &win->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); - if(sa && found==NULL) + if (sa && found==NULL) found= wm_keymap_item_find_handlers(C, &sa->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); - if(found==NULL) { - if(ELEM(opcontext, WM_OP_EXEC_REGION_WIN, WM_OP_INVOKE_REGION_WIN)) { - if(sa) { + if (found==NULL) { + if (ELEM(opcontext, WM_OP_EXEC_REGION_WIN, WM_OP_INVOKE_REGION_WIN)) { + if (sa) { if (!(ar && ar->regiontype == RGN_TYPE_WINDOW)) ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); - if(ar) + if (ar) found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); } } - else if(ELEM(opcontext, WM_OP_EXEC_REGION_CHANNELS, WM_OP_INVOKE_REGION_CHANNELS)) { + else if (ELEM(opcontext, WM_OP_EXEC_REGION_CHANNELS, WM_OP_INVOKE_REGION_CHANNELS)) { if (!(ar && ar->regiontype == RGN_TYPE_CHANNELS)) ar= BKE_area_find_region_type(sa, RGN_TYPE_CHANNELS); - if(ar) + if (ar) found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); } - else if(ELEM(opcontext, WM_OP_EXEC_REGION_PREVIEW, WM_OP_INVOKE_REGION_PREVIEW)) { + else if (ELEM(opcontext, WM_OP_EXEC_REGION_PREVIEW, WM_OP_INVOKE_REGION_PREVIEW)) { if (!(ar && ar->regiontype == RGN_TYPE_PREVIEW)) ar= BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW); - if(ar) + if (ar) found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); } else { - if(ar) + if (ar) found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); } } @@ -864,7 +866,7 @@ static wmKeyMapItem *wm_keymap_item_find( { wmKeyMapItem *found= wm_keymap_item_find_props(C, opname, opcontext, properties, 1, hotkey, keymap_r); - if(!found && sloppy) + if (!found && sloppy) found= wm_keymap_item_find_props(C, opname, opcontext, NULL, 0, hotkey, keymap_r); return found; @@ -876,7 +878,7 @@ char *WM_key_event_operator_string( { wmKeyMapItem *kmi = wm_keymap_item_find(C, opname, opcontext, properties, 0, sloppy, NULL); - if(kmi) { + if (kmi) { WM_keymap_item_to_string(kmi, str, len); return str; } @@ -890,7 +892,7 @@ int WM_key_event_operator_id( { wmKeyMapItem *kmi = wm_keymap_item_find(C, opname, opcontext, properties, hotkey, TRUE, keymap_r); - if(kmi) + if (kmi) return kmi->id; else return 0; @@ -907,10 +909,10 @@ int WM_keymap_item_compare(wmKeyMapItem *k1, wmKeyMapItem *k2) k1type = WM_userdef_event_map(k1->type); k2type = WM_userdef_event_map(k2->type); - if(k1type != KM_ANY && k2type != KM_ANY && k1type != k2type) + if (k1type != KM_ANY && k2type != KM_ANY && k1type != k2type) return 0; - if(k1->val != KM_ANY && k2->val != KM_ANY) { + if (k1->val != KM_ANY && k2->val != KM_ANY) { /* take click, press, release conflict into account */ if (k1->val == KM_CLICK && ELEM3(k2->val, KM_PRESS, KM_RELEASE, KM_CLICK) == 0) return 0; @@ -920,19 +922,19 @@ int WM_keymap_item_compare(wmKeyMapItem *k1, wmKeyMapItem *k2) return 0; } - if(k1->shift != KM_ANY && k2->shift != KM_ANY && k1->shift != k2->shift) + if (k1->shift != KM_ANY && k2->shift != KM_ANY && k1->shift != k2->shift) return 0; - if(k1->ctrl != KM_ANY && k2->ctrl != KM_ANY && k1->ctrl != k2->ctrl) + if (k1->ctrl != KM_ANY && k2->ctrl != KM_ANY && k1->ctrl != k2->ctrl) return 0; - if(k1->alt != KM_ANY && k2->alt != KM_ANY && k1->alt != k2->alt) + if (k1->alt != KM_ANY && k2->alt != KM_ANY && k1->alt != k2->alt) return 0; - if(k1->oskey != KM_ANY && k2->oskey != KM_ANY && k1->oskey != k2->oskey) + if (k1->oskey != KM_ANY && k2->oskey != KM_ANY && k1->oskey != k2->oskey) return 0; - if(k1->keymodifier != k2->keymodifier) + if (k1->keymodifier != k2->keymodifier) return 0; return 1; @@ -950,9 +952,9 @@ void WM_keyconfig_update_tag(wmKeyMap *km, wmKeyMapItem *kmi) /* quick tag to do delayed keymap updates */ WM_KEYMAP_UPDATE= 1; - if(km) + if (km) km->flag |= KEYMAP_UPDATE; - if(kmi) + if (kmi) kmi->flag |= KMI_UPDATE; } @@ -964,7 +966,7 @@ static int wm_keymap_test_and_clear_update(wmKeyMap *km) update= (km->flag & KEYMAP_UPDATE); km->flag &= ~KEYMAP_UPDATE; - for(kmi=km->items.first; kmi; kmi=kmi->next) { + for (kmi=km->items.first; kmi; kmi=kmi->next) { update= update || (kmi->flag & KMI_UPDATE); kmi->flag &= ~KMI_UPDATE; } @@ -978,7 +980,7 @@ static wmKeyMap *wm_keymap_preset(wmWindowManager *wm, wmKeyMap *km) wmKeyMap *keymap; keymap= WM_keymap_list_find(&keyconf->keymaps, km->idname, km->spaceid, km->regionid); - if(!keymap) + if (!keymap) keymap= WM_keymap_list_find(&wm->defaultconf->keymaps, km->idname, km->spaceid, km->regionid); return keymap; @@ -991,42 +993,42 @@ void WM_keyconfig_update(wmWindowManager *wm) wmKeyMapDiffItem *kmdi; int compat_update = 0; - if(G.background) + if (G.background) return; - if(!WM_KEYMAP_UPDATE) + if (!WM_KEYMAP_UPDATE) return; /* update operator properties for non-modal user keymaps */ - for(km=U.user_keymaps.first; km; km=km->next) { - if((km->flag & KEYMAP_MODAL) == 0) { - for(kmdi=km->diff_items.first; kmdi; kmdi=kmdi->next) { - if(kmdi->add_item) + for (km=U.user_keymaps.first; km; km=km->next) { + if ((km->flag & KEYMAP_MODAL) == 0) { + for (kmdi=km->diff_items.first; kmdi; kmdi=kmdi->next) { + if (kmdi->add_item) wm_keymap_item_properties_set(kmdi->add_item); - if(kmdi->remove_item) + if (kmdi->remove_item) wm_keymap_item_properties_set(kmdi->remove_item); } - for(kmi=km->items.first; kmi; kmi=kmi->next) + for (kmi=km->items.first; kmi; kmi=kmi->next) wm_keymap_item_properties_set(kmi); } } /* update U.user_keymaps with user key configuration changes */ - for(km=wm->userconf->keymaps.first; km; km=km->next) { + for (km=wm->userconf->keymaps.first; km; km=km->next) { /* only diff if the user keymap was modified */ - if(wm_keymap_test_and_clear_update(km)) { + if (wm_keymap_test_and_clear_update(km)) { /* find keymaps */ defaultmap= wm_keymap_preset(wm, km); addonmap= WM_keymap_list_find(&wm->addonconf->keymaps, km->idname, km->spaceid, km->regionid); /* diff */ - if(defaultmap) + if (defaultmap) wm_keymap_diff_update(&U.user_keymaps, defaultmap, addonmap, km); } } /* create user key configuration from preset + addon + user preferences */ - for(km=wm->defaultconf->keymaps.first; km; km=km->next) { + for (km=wm->defaultconf->keymaps.first; km; km=km->next) { /* find keymaps */ defaultmap= wm_keymap_preset(wm, km); addonmap= WM_keymap_list_find(&wm->addonconf->keymaps, km->idname, km->spaceid, km->regionid); @@ -1035,7 +1037,7 @@ void WM_keyconfig_update(wmWindowManager *wm) /* add */ kmn= wm_keymap_patch_update(&wm->userconf->keymaps, defaultmap, addonmap, usermap); - if(kmn) { + if (kmn) { kmn->modal_items= km->modal_items; kmn->poll= km->poll; } @@ -1046,7 +1048,7 @@ void WM_keyconfig_update(wmWindowManager *wm) WM_KEYMAP_UPDATE= 0; - if(compat_update) { + if (compat_update) { WM_keyconfig_update_tag(NULL, NULL); WM_keyconfig_update(wm); } @@ -1061,13 +1063,13 @@ wmKeyMap *WM_keymap_active(wmWindowManager *wm, wmKeyMap *keymap) { wmKeyMap *km; - if(!keymap) + if (!keymap) return NULL; /* first user defined keymaps */ km= WM_keymap_list_find(&wm->userconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid); - if(km) + if (km) return km; return keymap; @@ -1082,14 +1084,14 @@ void WM_keymap_restore_item_to_default(bContext *C, wmKeyMap *keymap, wmKeyMapIt wmKeyMap *defaultmap, *addonmap; wmKeyMapItem *orig; - if(!keymap) + if (!keymap) return; /* construct default keymap from preset + addons */ defaultmap= wm_keymap_preset(wm, keymap); addonmap= WM_keymap_list_find(&wm->addonconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid); - if(addonmap) { + if (addonmap) { defaultmap = wm_keymap_copy(defaultmap); wm_keymap_addon_add(defaultmap, addonmap); } @@ -1097,15 +1099,15 @@ void WM_keymap_restore_item_to_default(bContext *C, wmKeyMap *keymap, wmKeyMapIt /* find original item */ orig = WM_keymap_item_find_id(defaultmap, kmi->id); - if(orig) { + if (orig) { /* restore to original */ - if(strcmp(orig->idname, kmi->idname) != 0) { + if (strcmp(orig->idname, kmi->idname) != 0) { BLI_strncpy(kmi->idname, orig->idname, sizeof(kmi->idname)); WM_keymap_properties_reset(kmi, NULL); } if (orig->properties) { - if(kmi->properties) { + if (kmi->properties) { IDP_FreeProperty(kmi->properties); MEM_freeN(kmi->properties); kmi->properties= NULL; @@ -1129,7 +1131,7 @@ void WM_keymap_restore_item_to_default(bContext *C, wmKeyMap *keymap, wmKeyMapIt } /* free temporary keymap */ - if(addonmap) { + if (addonmap) { WM_keymap_free(defaultmap); MEM_freeN(defaultmap); } @@ -1143,7 +1145,7 @@ void WM_keymap_restore_to_default(wmKeyMap *keymap, bContext *C) /* remove keymap from U.user_keymaps and update */ usermap= WM_keymap_list_find(&U.user_keymaps, keymap->idname, keymap->spaceid, keymap->regionid); - if(usermap) { + if (usermap) { WM_keymap_free(usermap); BLI_freelinkN(&U.user_keymaps, usermap); @@ -1204,7 +1206,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) km = WM_keymap_find_all(C, "Mesh", 0, 0); /* some mesh operators are active in object mode too, like add-prim */ - if(km && km->poll && km->poll((bContext *)C)==0) { + if (km && km->poll && km->poll((bContext *)C)==0) { km = WM_keymap_find_all(C, "Object Mode", 0, 0); } } @@ -1212,7 +1214,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) km = WM_keymap_find_all(C, "Curve", 0, 0); /* some curve operators are active in object mode too, like add-prim */ - if(km && km->poll && km->poll((bContext *)C)==0) { + if (km && km->poll && km->poll((bContext *)C)==0) { km = WM_keymap_find_all(C, "Object Mode", 0, 0); } } @@ -1236,7 +1238,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) km = WM_keymap_find_all(C, "Metaball", 0, 0); /* some mball operators are active in object mode too, like add-prim */ - if(km && km->poll && km->poll((bContext *)C)==0) { + if (km && km->poll && km->poll((bContext *)C)==0) { km = WM_keymap_find_all(C, "Object Mode", 0, 0); } } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 953d266e7f5..6448fc2ac34 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -108,7 +108,7 @@ static GHash *global_ops_hash= NULL; wmOperatorType *WM_operatortype_find(const char *idname, int quiet) { - if(idname[0]) { + if (idname[0]) { wmOperatorType *ot; /* needed to support python style names without the _OT_ syntax */ @@ -116,16 +116,16 @@ wmOperatorType *WM_operatortype_find(const char *idname, int quiet) WM_operator_bl_idname(idname_bl, idname); ot= BLI_ghash_lookup(global_ops_hash, idname_bl); - if(ot) { + if (ot) { return ot; } - if(!quiet) { + if (!quiet) { printf("search for unknown operator '%s', '%s'\n", idname_bl, idname); } } else { - if(!quiet) { + if (!quiet) { printf("search for empty operator\n"); } } @@ -150,7 +150,7 @@ void WM_operatortype_append(void (*opfunc)(wmOperatorType*)) RNA_def_struct_translation_context(ot->srna, WM_OPERATOR_DEFAULT_I18NCONTEXT); opfunc(ot); - if(ot->name==NULL) { + if (ot->name==NULL) { fprintf(stderr, "ERROR: Operator %s has no name property!\n", ot->idname); ot->name = N_("Dummy Name"); } @@ -220,16 +220,17 @@ static int wm_macro_exec(bContext *C, wmOperator *op) wm_macro_start(op); - for(opm= op->macro.first; opm; opm= opm->next) { + for (opm= op->macro.first; opm; opm= opm->next) { - if(opm->type->exec) { + if (opm->type->exec) { retval= opm->type->exec(C, opm); OPERATOR_RETVAL_CHECK(retval); if (retval & OPERATOR_FINISHED) { MacroData *md = op->customdata; md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */ - } else { + } + else { break; /* operator didn't finish, end macro */ } } @@ -243,10 +244,10 @@ static int wm_macro_invoke_internal(bContext *C, wmOperator *op, wmEvent *event, int retval= OPERATOR_FINISHED; /* start from operator received as argument */ - for( ; opm; opm= opm->next) { - if(opm->type->invoke) + for ( ; opm; opm= opm->next) { + if (opm->type->invoke) retval= opm->type->invoke(C, opm, event); - else if(opm->type->exec) + else if (opm->type->exec) retval= opm->type->exec(C, opm); OPERATOR_RETVAL_CHECK(retval); @@ -256,7 +257,8 @@ static int wm_macro_invoke_internal(bContext *C, wmOperator *op, wmEvent *event, if (retval & OPERATOR_FINISHED) { MacroData *md = op->customdata; md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */ - } else { + } + else { break; /* operator didn't finish, end macro */ } } @@ -275,7 +277,7 @@ static int wm_macro_modal(bContext *C, wmOperator *op, wmEvent *event) wmOperator *opm = op->opm; int retval= OPERATOR_FINISHED; - if(opm==NULL) + if (opm==NULL) printf("%s: macro error, calling NULL modal()\n", __func__); else { retval = opm->type->modal(C, opm, event); @@ -308,13 +310,13 @@ static int wm_macro_modal(bContext *C, wmOperator *op, wmEvent *event) /* if operator is blocking, grab cursor * This may end up grabbing twice, but we don't care. * */ - if(op->opm->type->flag & OPTYPE_BLOCKING) { + if (op->opm->type->flag & OPTYPE_BLOCKING) { int bounds[4] = {-1,-1,-1,-1}; int wrap = (U.uiflag & USER_CONTINUOUS_MOUSE) && ((op->opm->flag & OP_GRAB_POINTER) || (op->opm->type->flag & OPTYPE_GRAB_POINTER)); - if(wrap) { + if (wrap) { ARegion *ar= CTX_wm_region(C); - if(ar) { + if (ar) { bounds[0]= ar->winrct.xmin; bounds[1]= ar->winrct.ymax; bounds[2]= ar->winrct.xmax; @@ -346,7 +348,7 @@ wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *nam { wmOperatorType *ot; - if(WM_operatortype_find(idname, TRUE)) { + if (WM_operatortype_find(idname, TRUE)) { printf("%s: macro error: operator %s exists\n", __func__, idname); return NULL; } @@ -364,7 +366,7 @@ wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *nam ot->cancel = wm_macro_cancel; ot->poll = NULL; - if(!ot->description) /* XXX All ops should have a description but for now allow them not to. */ + if (!ot->description) /* XXX All ops should have a description but for now allow them not to. */ ot->description = N_("(undocumented operator)"); RNA_def_struct_ui_text(ot->srna, ot->name, ot->description); @@ -390,7 +392,7 @@ void WM_operatortype_append_macro_ptr(void (*opfunc)(wmOperatorType*, void*), vo ot->cancel = wm_macro_cancel; ot->poll = NULL; - if(!ot->description) + if (!ot->description) ot->description = N_("(undocumented operator)"); /* Set the default i18n context now, so that opfunc can redefine it if needed! */ @@ -418,7 +420,7 @@ wmOperatorTypeMacro *WM_operatortype_macro_define(wmOperatorType *ot, const char { /* operator should always be found but in the event its not. don't segfault */ wmOperatorType *otsub = WM_operatortype_find(idname, 0); - if(otsub) { + if (otsub) { RNA_def_pointer_runtime(ot->srna, otsub->idname, otsub->srna, otsub->name, otsub->description); } @@ -431,8 +433,8 @@ static void wm_operatortype_free_macro(wmOperatorType *ot) { wmOperatorTypeMacro *otmacro; - for(otmacro= ot->macro.first; otmacro; otmacro= otmacro->next) { - if(otmacro->ptr) { + for (otmacro= ot->macro.first; otmacro; otmacro= otmacro->next) { + if (otmacro->ptr) { WM_operator_properties_free(otmacro->ptr); MEM_freeN(otmacro->ptr); } @@ -455,7 +457,7 @@ int WM_operatortype_remove(const char *idname) MEM_freeN(ot->last_properties); } - if(ot->macro.first) + if (ot->macro.first) wm_operatortype_free_macro(ot); BLI_ghash_remove(global_ops_hash, (void *)ot->idname, NULL, NULL); @@ -468,7 +470,7 @@ int WM_operatortype_remove(const char *idname) void WM_operator_py_idname(char *to, const char *from) { char *sep= strstr(from, "_OT_"); - if(sep) { + if (sep) { int ofs= (sep-from); /* note, we use ascii tolower instead of system tolower, because the @@ -491,7 +493,7 @@ void WM_operator_bl_idname(char *to, const char *from) if (from) { char *sep= strchr(from, '.'); - if(sep) { + if (sep) { int ofs= (sep-from); memcpy(to, from, sizeof(char)*ofs); @@ -530,7 +532,7 @@ char *WM_operator_pystring(bContext *C, wmOperatorType *ot, PointerRNA *opptr, i if (all_args==0 || opptr==NULL) { WM_operator_properties_create_ptr(&opptr_default, ot); - if(opptr==NULL) + if (opptr==NULL) opptr = &opptr_default; } @@ -541,7 +543,7 @@ char *WM_operator_pystring(bContext *C, wmOperatorType *ot, PointerRNA *opptr, i BLI_dynstr_append(dynstr, cstring_args); MEM_freeN(cstring_args); - if(all_args==0 || opptr==&opptr_default ) + if (all_args==0 || opptr==&opptr_default ) WM_operator_properties_free(&opptr_default); BLI_dynstr_append(dynstr, ")"); @@ -560,7 +562,7 @@ void WM_operator_properties_create(PointerRNA *ptr, const char *opstring) { wmOperatorType *ot= WM_operatortype_find(opstring, 0); - if(ot) + if (ot) WM_operator_properties_create_ptr(ptr, ot); else RNA_pointer_create(NULL, &RNA_OperatorProperties, NULL, ptr); @@ -570,12 +572,12 @@ void WM_operator_properties_create(PointerRNA *ptr, const char *opstring) * used for keymaps and macros */ void WM_operator_properties_alloc(PointerRNA **ptr, IDProperty **properties, const char *opstring) { - if(*properties==NULL) { + if (*properties==NULL) { IDPropertyTemplate val = {0}; *properties= IDP_New(IDP_GROUP, &val, "wmOpItemProp"); } - if(*ptr==NULL) { + if (*ptr==NULL) { *ptr= MEM_callocN(sizeof(PointerRNA), "wmOpItemPtr"); WM_operator_properties_create(*ptr, opstring); } @@ -622,7 +624,7 @@ void WM_operator_properties_reset(wmOperator *op) RNA_PROP_BEGIN(op->ptr, itemptr, iterprop) { PropertyRNA *prop= itemptr.data; - if((RNA_property_flag(prop) & PROP_SKIP_SAVE) == 0) { + if ((RNA_property_flag(prop) & PROP_SKIP_SAVE) == 0) { const char *identifier = RNA_property_identifier(prop); RNA_struct_idprops_unset(op->ptr, identifier); } @@ -635,7 +637,7 @@ void WM_operator_properties_free(PointerRNA *ptr) { IDProperty *properties= ptr->data; - if(properties) { + if (properties) { IDP_FreeProperty(properties); MEM_freeN(properties); ptr->data= NULL; /* just in case */ @@ -651,7 +653,7 @@ int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) uiPopupMenu *pup; uiLayout *layout; - if(prop==NULL) { + if (prop==NULL) { printf("%s: %s has no enum property set\n", __func__, op->type->idname); } else if (RNA_property_type(prop) != PROP_ENUM) { @@ -680,7 +682,7 @@ static void operator_enum_search_cb(const struct bContext *C, void *arg_ot, cons wmOperatorType *ot = (wmOperatorType *)arg_ot; PropertyRNA *prop= ot->prop; - if(prop==NULL) { + if (prop==NULL) { printf("%s: %s has no enum property set\n", __func__, ot->idname); } @@ -697,14 +699,14 @@ static void operator_enum_search_cb(const struct bContext *C, void *arg_ot, cons RNA_pointer_create(NULL, ot->srna, NULL, &ptr); RNA_property_enum_items((bContext *)C, &ptr, prop, &item_array, NULL, &do_free); - for(item= item_array; item->identifier; item++) { + for (item= item_array; item->identifier; item++) { /* note: need to give the intex rather than the dientifier because the enum can be freed */ - if(BLI_strcasestr(item->name, str)) - if(0==uiSearchItemAdd(items, item->name, SET_INT_IN_POINTER(item->value), 0)) + if (BLI_strcasestr(item->name, str)) + if (0==uiSearchItemAdd(items, item->name, SET_INT_IN_POINTER(item->value), 0)) break; } - if(do_free) + if (do_free) MEM_freeN(item_array); } } @@ -713,8 +715,8 @@ static void operator_enum_call_cb(struct bContext *C, void *arg1, void *arg2) { wmOperatorType *ot= arg1; - if(ot) { - if(ot->prop) { + if (ot) { + if (ot->prop) { PointerRNA props_ptr; WM_operator_properties_create_ptr(&props_ptr, ot); RNA_property_enum_set(&props_ptr, ot->prop, GET_INT_FROM_POINTER(arg2)); @@ -773,7 +775,7 @@ int WM_operator_confirm_message(bContext *C, wmOperator *op, const char *message uiLayout *layout; IDProperty *properties= op->ptr->data; - if(properties && properties->len) + if (properties && properties->len) properties= IDP_CopyProperty(op->ptr->data); else properties= NULL; @@ -817,16 +819,16 @@ void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type, {0, NULL, 0, NULL, NULL}}; - if(flag & WM_FILESEL_FILEPATH) + if (flag & WM_FILESEL_FILEPATH) RNA_def_string_file_path(ot->srna, "filepath", "", FILE_MAX, "File Path", "Path to file"); - if(flag & WM_FILESEL_DIRECTORY) + if (flag & WM_FILESEL_DIRECTORY) RNA_def_string_dir_path(ot->srna, "directory", "", FILE_MAX, "Directory", "Directory of the file"); - if(flag & WM_FILESEL_FILENAME) + if (flag & WM_FILESEL_FILENAME) RNA_def_string_file_name(ot->srna, "filename", "", FILE_MAX, "File Name", "Name of the file"); - if(flag & WM_FILESEL_FILES) + if (flag & WM_FILESEL_FILES) RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, "Files", ""); if (action == FILE_SAVE) { @@ -860,7 +862,7 @@ void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type, FILE_LOADLIB, FILE_SPECIAL); RNA_def_property_flag(prop, PROP_HIDDEN); - if(flag & WM_FILESEL_RELPATH) + if (flag & WM_FILESEL_RELPATH) RNA_def_boolean(ot->srna, "relative_path", TRUE, "Relative Path", "Select the file relative to the blend file"); prop= RNA_def_enum(ot->srna, "display_type", file_display_items, display, "Display Type", ""); @@ -888,7 +890,7 @@ void WM_operator_properties_gesture_border(wmOperatorType *ot, int extend) RNA_def_int(ot->srna, "ymin", 0, INT_MIN, INT_MAX, "Y Min", "", INT_MIN, INT_MAX); RNA_def_int(ot->srna, "ymax", 0, INT_MIN, INT_MAX, "Y Max", "", INT_MIN, INT_MAX); - if(extend) + if (extend) RNA_def_boolean(ot->srna, "extend", 1, "Extend", "Extend selection instead of deselecting everything first"); } @@ -899,7 +901,7 @@ void WM_operator_properties_gesture_straightline(wmOperatorType *ot, int cursor) RNA_def_int(ot->srna, "ystart", 0, INT_MIN, INT_MAX, "Y Start", "", INT_MIN, INT_MAX); RNA_def_int(ot->srna, "yend", 0, INT_MIN, INT_MAX, "Y End", "", INT_MIN, INT_MAX); - if(cursor) + if (cursor) RNA_def_int(ot->srna, "cursor", cursor, 0, INT_MAX, "Cursor", "Mouse cursor style to use during the modal operator", 0, INT_MAX); } @@ -907,7 +909,7 @@ void WM_operator_properties_gesture_straightline(wmOperatorType *ot, int cursor) /* op->poll */ int WM_operator_winactive(bContext *C) { - if(CTX_wm_window(C)==NULL) return 0; + if (CTX_wm_window(C)==NULL) return 0; return 1; } @@ -926,8 +928,8 @@ wmOperator *WM_operator_last_redo(const bContext *C) wmOperator *op; /* only for operators that are registered and did an undo push */ - for(op= wm->operators.last; op; op= op->prev) - if((op->type->flag & OPTYPE_REGISTER) && (op->type->flag & OPTYPE_UNDO)) + for (op= wm->operators.last; op; op= op->prev) + if ((op->type->flag & OPTYPE_REGISTER) && (op->type->flag & OPTYPE_UNDO)) break; return op; @@ -956,8 +958,8 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op) if (!WM_operator_check_ui_enabled(C, op->type->name)) uiLayoutSetEnabled(layout, 0); - if(op->type->flag & OPTYPE_MACRO) { - for(op= op->macro.first; op; op= op->next) { + if (op->type->flag & OPTYPE_MACRO) { + for (op= op->macro.first; op; op= op->next) { uiItemL(layout, op->type->name, ICON_NONE); uiLayoutOperatorButs(C, layout, op, NULL, 'H', UI_LAYOUT_OP_SHOW_TITLE); } @@ -1002,8 +1004,8 @@ static void dialog_exec_cb(bContext *C, void *arg1, void *arg2) static void dialog_check_cb(bContext *C, void *op_ptr, void *UNUSED(arg)) { wmOperator *op= op_ptr; - if(op->type->check) { - if(op->type->check(C, op)) { + if (op->type->check) { + if (op->type->check(C, op)) { /* refresh */ } } @@ -1077,7 +1079,7 @@ static uiBlock *wm_operator_ui_create(bContext *C, ARegion *ar, void *userData) static void wm_operator_ui_popup_cancel(void *userData) { wmOpPopUp *data= userData; - if(data->free_op && data->op) { + if (data->free_op && data->op) { wmOperator *op= data->op; WM_operator_free(op); } @@ -1090,7 +1092,7 @@ static void wm_operator_ui_popup_ok(struct bContext *C, void *arg, int retval) wmOpPopUp *data= arg; wmOperator *op= data->op; - if(op && retval > 0) + if (op && retval > 0) WM_operator_call(C, op); } @@ -1109,7 +1111,7 @@ int WM_operator_ui_popup(bContext *C, wmOperator *op, int width, int height) int WM_operator_props_popup(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - if((op->type->flag & OPTYPE_REGISTER)==0) { + if ((op->type->flag & OPTYPE_REGISTER)==0) { BKE_reportf(op->reports, RPT_ERROR, "Operator '%s' does not have register enabled, incorrect invoke function.", op->type->idname); return OPERATOR_CANCELLED; @@ -1141,11 +1143,11 @@ int WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width, int h int WM_operator_redo_popup(bContext *C, wmOperator *op) { /* CTX_wm_reports(C) because operator is on stack, not active in event system */ - if((op->type->flag & OPTYPE_REGISTER)==0) { + if ((op->type->flag & OPTYPE_REGISTER)==0) { BKE_reportf(CTX_wm_reports(C), RPT_ERROR, "Operator redo '%s' does not have register enabled, incorrect invoke function.", op->type->idname); return OPERATOR_CANCELLED; } - if(op->type->poll && op->type->poll(C)==0) { + if (op->type->poll && op->type->poll(C)==0) { BKE_reportf(CTX_wm_reports(C), RPT_ERROR, "Operator redo '%s': wrong context.", op->type->idname); return OPERATOR_CANCELLED; } @@ -1215,14 +1217,14 @@ static int wm_resource_check_prev(void) // if(res) printf("USER: %s\n", res); #if 0 /* ignore the local folder */ - if(res == NULL) { + if (res == NULL) { /* with a local dir, copying old files isn't useful since local dir get priority for config */ res= BLI_get_folder_version(BLENDER_RESOURCE_PATH_LOCAL, BLENDER_VERSION, TRUE); } #endif // if(res) printf("LOCAL: %s\n", res); - if(res) { + if (res) { return FALSE; } else { @@ -1304,7 +1306,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar uiItemStringO(col, IFACE_("Manual"), ICON_URL, "WM_OT_url_open", "url", "http://wiki.blender.org/index.php/Doc:2.5/Manual"); uiItemStringO(col, IFACE_("Blender Website"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org"); uiItemStringO(col, IFACE_("User Community"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/community/user-community"); - if(strcmp(STRINGIFY(BLENDER_VERSION_CYCLE), "release")==0) { + if (strcmp(STRINGIFY(BLENDER_VERSION_CYCLE), "release")==0) { BLI_snprintf(url, sizeof(url), "http://www.blender.org/documentation/blender_python_api_%d_%d" STRINGIFY(BLENDER_VERSION_CHAR) "_release", BLENDER_VERSION/100, BLENDER_VERSION%100); } else { @@ -1315,13 +1317,13 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar col = uiLayoutColumn(split, 0); - if(wm_resource_check_prev()) { + if (wm_resource_check_prev()) { uiItemO(col, NULL, ICON_NEW, "WM_OT_copy_prev_settings"); uiItemS(col); } uiItemL(col, IFACE_("Recent"), ICON_NONE); - for(recent = G.recent_files.first, i=0; (i<5) && (recent); recent = recent->next, i++) { + for (recent = G.recent_files.first, i=0; (i<5) && (recent); recent = recent->next, i++) { uiItemStringO(col, BLI_path_basename(recent->filepath), ICON_FILE_BLEND, "WM_OT_open_mainfile", "filepath", recent->filepath); } @@ -1358,7 +1360,7 @@ static void operator_call_cb(struct bContext *C, void *UNUSED(arg1), void *arg2) { wmOperatorType *ot= arg2; - if(ot) + if (ot) WM_operator_name_call(C, ot->idname, WM_OP_INVOKE_DEFAULT, NULL); } @@ -1366,14 +1368,14 @@ static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), cons { GHashIterator *iter= WM_operatortype_iter(); - for( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { + for ( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { wmOperatorType *ot= BLI_ghashIterator_getValue(iter); - if((ot->flag & OPTYPE_INTERNAL) && (G.f & G_DEBUG) == 0) + if ((ot->flag & OPTYPE_INTERNAL) && (G.f & G_DEBUG) == 0) continue; - if(BLI_strcasestr(ot->name, str)) { - if(WM_operator_poll((bContext*)C, ot)) { + if (BLI_strcasestr(ot->name, str)) { + if (WM_operator_poll((bContext*)C, ot)) { char name[256]; int len= strlen(ot->name); @@ -1389,7 +1391,7 @@ static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), cons } } - if(0==uiSearchItemAdd(items, name, ot, 0)) + if (0==uiSearchItemAdd(items, name, ot, 0)) break; } } @@ -1442,18 +1444,18 @@ static int wm_search_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(ev /* op->poll */ static int wm_search_menu_poll(bContext *C) { - if(CTX_wm_window(C)==NULL) { + if (CTX_wm_window(C)==NULL) { return 0; } else { ScrArea *sa= CTX_wm_area(C); - if(sa) { - if(sa->spacetype==SPACE_CONSOLE) return 0; // XXX - so we can use the shortcut in the console - if(sa->spacetype==SPACE_TEXT) return 0; // XXX - so we can use the spacebar in the text editor + if (sa) { + if (sa->spacetype==SPACE_CONSOLE) return 0; // XXX - so we can use the shortcut in the console + if (sa->spacetype==SPACE_TEXT) return 0; // XXX - so we can use the spacebar in the text editor } else { Object *editob= CTX_data_edit_object(C); - if(editob && editob->type==OB_FONT) return 0; // XXX - so we can use the spacebar for entering text + if (editob && editob->type==OB_FONT) return 0; // XXX - so we can use the spacebar for entering text } } return 1; @@ -1500,7 +1502,7 @@ static int wm_operator_winactive_normal(bContext *C) { wmWindow *win= CTX_wm_window(C); - if(win==NULL || win->screen==NULL || win->screen->full != SCREENNORMAL) + if (win==NULL || win->screen==NULL || win->screen->full != SCREENNORMAL) return 0; return 1; @@ -1553,13 +1555,13 @@ static void WM_OT_read_factory_settings(wmOperatorType *ot) static void open_set_load_ui(wmOperator *op) { - if(!RNA_struct_property_is_set(op->ptr, "load_ui")) + if (!RNA_struct_property_is_set(op->ptr, "load_ui")) RNA_boolean_set(op->ptr, "load_ui", !(U.flag & USER_FILENOUI)); } static void open_set_use_scripts(wmOperator *op) { - if(!RNA_struct_property_is_set(op->ptr, "use_scripts")) { + if (!RNA_struct_property_is_set(op->ptr, "use_scripts")) { /* use G_SCRIPT_AUTOEXEC rather than the userpref because this means if * the flag has been disabled from the command line, then opening * from the menu wont enable this setting. */ @@ -1571,7 +1573,7 @@ static int wm_open_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED( { const char *openname= G.main->name; - if(CTX_wm_window(C) == NULL) { + if (CTX_wm_window(C) == NULL) { /* in rare cases this could happen, when trying to invoke in background * mode on load for example. Don't use poll for this because exec() * can still run without a window */ @@ -1602,12 +1604,12 @@ static int wm_open_mainfile_exec(bContext *C, wmOperator *op) open_set_load_ui(op); open_set_use_scripts(op); - if(RNA_boolean_get(op->ptr, "load_ui")) + if (RNA_boolean_get(op->ptr, "load_ui")) G.fileflags &= ~G_FILE_NO_UI; else G.fileflags |= G_FILE_NO_UI; - if(RNA_boolean_get(op->ptr, "use_scripts")) + if (RNA_boolean_get(op->ptr, "use_scripts")) G.f |= G_SCRIPT_AUTOEXEC; else G.f &= ~G_SCRIPT_AUTOEXEC; @@ -1643,12 +1645,12 @@ static void WM_OT_open_mainfile(wmOperatorType *ot) int wm_link_append_poll(bContext *C) { - if(WM_operator_winactive(C)) { + if (WM_operator_winactive(C)) { /* linking changes active object which is pretty useful in general, * but which totally confuses edit mode (i.e. it becoming not so obvious * to leave from edit mode and inwalid tools in toolbar might be displayed) * so disable link/append when in edit mode (sergey) */ - if(CTX_data_edit_object(C)) + if (CTX_data_edit_object(C)) return 0; return 1; @@ -1659,15 +1661,15 @@ int wm_link_append_poll(bContext *C) static int wm_link_append_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - if(RNA_struct_property_is_set(op->ptr, "filepath")) { + if (RNA_struct_property_is_set(op->ptr, "filepath")) { return WM_operator_call_notest(C, op); } else { /* XXX TODO solve where to get last linked library from */ - if(G.lib[0] != '\0') { + if (G.lib[0] != '\0') { RNA_string_set(op->ptr, "filepath", G.lib); } - else if(G.relbase_valid) { + else if (G.relbase_valid) { char path[FILE_MAX]; BLI_strncpy(path, G.main->name, sizeof(G.main->name)); BLI_parent_dir(path); @@ -1682,11 +1684,11 @@ static short wm_link_append_flag(wmOperator *op) { short flag= 0; - if(RNA_boolean_get(op->ptr, "autoselect")) flag |= FILE_AUTOSELECT; - if(RNA_boolean_get(op->ptr, "active_layer")) flag |= FILE_ACTIVELAY; - if(RNA_boolean_get(op->ptr, "relative_path")) flag |= FILE_RELPATH; - if(RNA_boolean_get(op->ptr, "link")) flag |= FILE_LINK; - if(RNA_boolean_get(op->ptr, "instance_groups")) flag |= FILE_GROUP_INSTANCE; + if (RNA_boolean_get(op->ptr, "autoselect")) flag |= FILE_AUTOSELECT; + if (RNA_boolean_get(op->ptr, "active_layer")) flag |= FILE_ACTIVELAY; + if (RNA_boolean_get(op->ptr, "relative_path")) flag |= FILE_RELPATH; + if (RNA_boolean_get(op->ptr, "link")) flag |= FILE_LINK; + if (RNA_boolean_get(op->ptr, "instance_groups")) flag |= FILE_GROUP_INSTANCE; return flag; } @@ -1706,38 +1708,38 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "directory", dir); /* test if we have a valid data */ - if(BLO_is_a_library(dir, libname, group) == 0) { + if (BLO_is_a_library(dir, libname, group) == 0) { BKE_report(op->reports, RPT_ERROR, "Not a library"); return OPERATOR_CANCELLED; } - else if(group[0] == 0) { + else if (group[0] == 0) { BKE_report(op->reports, RPT_ERROR, "Nothing indicated"); return OPERATOR_CANCELLED; } - else if(BLI_path_cmp(bmain->name, libname) == 0) { + else if (BLI_path_cmp(bmain->name, libname) == 0) { BKE_report(op->reports, RPT_ERROR, "Cannot use current file as library"); return OPERATOR_CANCELLED; } /* check if something is indicated for append/link */ prop = RNA_struct_find_property(op->ptr, "files"); - if(prop) { + if (prop) { totfiles= RNA_property_collection_length(op->ptr, prop); - if(totfiles == 0) { - if(name[0] == '\0') { + if (totfiles == 0) { + if (name[0] == '\0') { BKE_report(op->reports, RPT_ERROR, "Nothing indicated"); return OPERATOR_CANCELLED; } } } - else if(name[0] == '\0') { + else if (name[0] == '\0') { BKE_report(op->reports, RPT_ERROR, "Nothing indicated"); return OPERATOR_CANCELLED; } bh = BLO_blendhandle_from_file(libname, op->reports); - if(bh == NULL) { + if (bh == NULL) { /* unlikely since we just browsed it, but possible * error reports will have been made by BLO_blendhandle_from_file() */ return OPERATOR_CANCELLED; @@ -1749,14 +1751,14 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) idcode = BKE_idcode_from_name(group); /* now we have or selected, or an indicated file */ - if(RNA_boolean_get(op->ptr, "autoselect")) + if (RNA_boolean_get(op->ptr, "autoselect")) scene_deselect_all(scene); flag = wm_link_append_flag(op); /* sanity checks for flag */ - if(scene->id.lib && (flag & FILE_GROUP_INSTANCE)) { + if (scene->id.lib && (flag & FILE_GROUP_INSTANCE)) { /* TODO, user never gets this message */ BKE_reportf(op->reports, RPT_WARNING, "Scene '%s' is linked, group instance disabled", scene->id.name+2); flag &= ~FILE_GROUP_INSTANCE; @@ -1771,7 +1773,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) /* here appending/linking starts */ mainl = BLO_library_append_begin(bmain, &bh, libname); - if(totfiles == 0) { + if (totfiles == 0) { BLO_library_append_named_part_ex(C, mainl, &bh, name, idcode, flag); } else { @@ -1787,9 +1789,9 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) recalc_all_library_objects(bmain); /* append, rather than linking */ - if((flag & FILE_LINK)==0) { + if ((flag & FILE_LINK)==0) { Library *lib= BLI_findstring(&bmain->library, libname, offsetof(Library, filepath)); - if(lib) BKE_library_make_local(bmain, lib, 1); + if (lib) BKE_library_make_local(bmain, lib, 1); else BLI_assert(!"cant find name of just added library!"); } @@ -1914,10 +1916,10 @@ static void WM_OT_recover_auto_save(wmOperatorType *ot) static void untitled(char *name) { - if(G.save_over == 0 && strlen(name) < FILE_MAX-16) { + if (G.save_over == 0 && strlen(name) < FILE_MAX-16) { char *c= BLI_last_slash(name); - if(c) + if (c) strcpy(&c[1], "untitled.blend"); else strcpy(name, "untitled.blend"); @@ -1926,8 +1928,8 @@ static void untitled(char *name) static void save_set_compress(wmOperator *op) { - if(!RNA_struct_property_is_set(op->ptr, "compress")) { - if(G.save_over) /* keep flag for existing file */ + if (!RNA_struct_property_is_set(op->ptr, "compress")) { + if (G.save_over) /* keep flag for existing file */ RNA_boolean_set(op->ptr, "compress", G.fileflags & G_FILE_COMPRESS); else /* use userdef for new file */ RNA_boolean_set(op->ptr, "compress", U.flag & USER_FILECOMPRESS); @@ -1941,7 +1943,7 @@ static int wm_save_as_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *UNUS save_set_compress(op); /* if not saved before, get the name of the most recently used .blend file */ - if(G.main->name[0]==0 && G.recent_files.first) { + if (G.main->name[0]==0 && G.recent_files.first) { struct RecentFile *recent = G.recent_files.first; BLI_strncpy(name, recent->filepath, FILE_MAX); } @@ -1965,27 +1967,27 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op) save_set_compress(op); - if(RNA_struct_property_is_set(op->ptr, "filepath")) + if (RNA_struct_property_is_set(op->ptr, "filepath")) RNA_string_get(op->ptr, "filepath", path); else { BLI_strncpy(path, G.main->name, FILE_MAX); untitled(path); } - if(RNA_struct_property_is_set(op->ptr, "copy")) + if (RNA_struct_property_is_set(op->ptr, "copy")) copy = RNA_boolean_get(op->ptr, "copy"); fileflags= G.fileflags; /* set compression flag */ - if(RNA_boolean_get(op->ptr, "compress")) fileflags |= G_FILE_COMPRESS; + if (RNA_boolean_get(op->ptr, "compress")) fileflags |= G_FILE_COMPRESS; else fileflags &= ~G_FILE_COMPRESS; - if(RNA_boolean_get(op->ptr, "relative_remap")) fileflags |= G_FILE_RELATIVE_REMAP; + if (RNA_boolean_get(op->ptr, "relative_remap")) fileflags |= G_FILE_RELATIVE_REMAP; else fileflags &= ~G_FILE_RELATIVE_REMAP; #ifdef USE_BMESH_SAVE_AS_COMPAT /* property only exists for 'Save As' */ if (RNA_struct_find_property(op->ptr, "use_mesh_compat")) { - if(RNA_boolean_get(op->ptr, "use_mesh_compat")) fileflags |= G_FILE_MESH_COMPAT; + if (RNA_boolean_get(op->ptr, "use_mesh_compat")) fileflags |= G_FILE_MESH_COMPAT; else fileflags &= ~G_FILE_MESH_COMPAT; } else { @@ -2006,7 +2008,7 @@ static int blend_save_check(bContext *UNUSED(C), wmOperator *op) { char filepath[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filepath); - if(!BLO_has_bfile_extension(filepath)) { + if (!BLO_has_bfile_extension(filepath)) { /* some users would prefer BLI_replace_extension(), * we keep getting knit-picking bug reports about this - campbell */ BLI_ensure_extension(filepath, FILE_MAX, ".blend"); @@ -2051,7 +2053,7 @@ static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED( save_set_compress(op); /* if not saved before, get the name of the most recently used .blend file */ - if(G.main->name[0]==0 && G.recent_files.first) { + if (G.main->name[0]==0 && G.recent_files.first) { struct RecentFile *recent = G.recent_files.first; BLI_strncpy(name, recent->filepath, FILE_MAX); } @@ -2106,7 +2108,7 @@ static void WM_OT_save_mainfile(wmOperatorType *ot) static int wm_collada_export_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - if(!RNA_struct_property_is_set(op->ptr, "filepath")) { + if (!RNA_struct_property_is_set(op->ptr, "filepath")) { char filepath[FILE_MAX]; BLI_strncpy(filepath, G.main->name, sizeof(filepath)); BLI_replace_extension(filepath, sizeof(filepath), ".dae"); @@ -2124,7 +2126,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) char filename[FILE_MAX]; int selected, second_life; - if(!RNA_struct_property_is_set(op->ptr, "filepath")) { + if (!RNA_struct_property_is_set(op->ptr, "filepath")) { BKE_report(op->reports, RPT_ERROR, "No filename given"); return OPERATOR_CANCELLED; } @@ -2132,7 +2134,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filepath", filename); selected = RNA_boolean_get(op->ptr, "selected"); second_life = RNA_boolean_get(op->ptr, "second_life"); - if(collada_export(CTX_data_scene(C), filename, selected, second_life)) { + if (collada_export(CTX_data_scene(C), filename, selected, second_life)) { return OPERATOR_FINISHED; } else { @@ -2161,13 +2163,13 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op) { char filename[FILE_MAX]; - if(!RNA_struct_property_is_set(op->ptr, "filepath")) { + if (!RNA_struct_property_is_set(op->ptr, "filepath")) { BKE_report(op->reports, RPT_ERROR, "No filename given"); return OPERATOR_CANCELLED; } RNA_string_get(op->ptr, "filepath", filename); - if(collada_import(C, filename)) return OPERATOR_FINISHED; + if (collada_import(C, filename)) return OPERATOR_FINISHED; BKE_report(op->reports, RPT_ERROR, "Errors found during parsing COLLADA document. Please see console for error log."); @@ -2268,8 +2270,8 @@ void WM_paint_cursor_end(wmWindowManager *wm, void *handle) { wmPaintCursor *pc; - for(pc= wm->paintcursors.first; pc; pc= pc->next) { - if(pc == (wmPaintCursor *)handle) { + for (pc= wm->paintcursors.first; pc; pc= pc->next) { + if (pc == (wmPaintCursor *)handle) { BLI_remlink(&wm->paintcursors, pc); MEM_freeN(pc); return; @@ -2296,7 +2298,7 @@ static int border_apply_rect(wmOperator *op) wmGesture *gesture= op->customdata; rcti *rect= gesture->customdata; - if(rect->xmin ==rect->xmax || rect->ymin==rect->ymax) + if (rect->xmin ==rect->xmax || rect->ymin==rect->ymax) return 0; @@ -2315,7 +2317,7 @@ static int border_apply(bContext *C, wmOperator *op, int gesture_mode) return 0; /* XXX weak; border should be configured for this without reading event types */ - if( RNA_struct_find_property(op->ptr, "gesture_mode") ) + if ( RNA_struct_find_property(op->ptr, "gesture_mode") ) RNA_int_set(op->ptr, "gesture_mode", gesture_mode); op->type->exec(C, op); @@ -2331,13 +2333,13 @@ static void wm_gesture_end(bContext *C, wmOperator *op) ED_area_tag_redraw(CTX_wm_area(C)); - if( RNA_struct_find_property(op->ptr, "cursor") ) + if ( RNA_struct_find_property(op->ptr, "cursor") ) WM_cursor_restore(CTX_wm_window(C)); } int WM_border_select_invoke(bContext *C, wmOperator *op, wmEvent *event) { - if(ISTWEAK(event->type)) + if (ISTWEAK(event->type)) op->customdata= WM_gesture_new(C, event, WM_GESTURE_RECT); else op->customdata= WM_gesture_new(C, event, WM_GESTURE_CROSS_RECT); @@ -2356,10 +2358,10 @@ int WM_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) rcti *rect= gesture->customdata; int sx, sy; - if(event->type== MOUSEMOVE) { + if (event->type== MOUSEMOVE) { wm_subwindow_getorigin(CTX_wm_window(C), gesture->swinid, &sx, &sy); - if(gesture->type==WM_GESTURE_CROSS_RECT && gesture->mode==0) { + if (gesture->type==WM_GESTURE_CROSS_RECT && gesture->mode==0) { rect->xmin = rect->xmax = event->x - sx; rect->ymin = rect->ymax = event->y - sy; } @@ -2374,7 +2376,7 @@ int WM_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) else if (event->type==EVT_MODAL_MAP) { switch (event->val) { case GESTURE_MODAL_BEGIN: - if(gesture->type==WM_GESTURE_CROSS_RECT && gesture->mode==0) { + if (gesture->type==WM_GESTURE_CROSS_RECT && gesture->mode==0) { gesture->mode= 1; wm_gesture_tag_redraw(C); } @@ -2383,7 +2385,7 @@ int WM_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) case GESTURE_MODAL_DESELECT: case GESTURE_MODAL_IN: case GESTURE_MODAL_OUT: - if(border_apply(C, op, event->val)) { + if (border_apply(C, op, event->val)) { wm_gesture_end(C, op); return OPERATOR_FINISHED; } @@ -2436,7 +2438,7 @@ static void gesture_circle_apply(bContext *C, wmOperator *op) wmGesture *gesture= op->customdata; rcti *rect= gesture->customdata; - if(RNA_int_get(op->ptr, "gesture_mode")==GESTURE_MODAL_NOP) + if (RNA_int_get(op->ptr, "gesture_mode")==GESTURE_MODAL_NOP) return; /* operator arguments and storage. */ @@ -2444,7 +2446,7 @@ static void gesture_circle_apply(bContext *C, wmOperator *op) RNA_int_set(op->ptr, "y", rect->ymin); RNA_int_set(op->ptr, "radius", rect->xmax); - if(op->type->exec) + if (op->type->exec) op->type->exec(C, op); #ifdef GESTURE_MEMORY circle_select_size= rect->xmax; @@ -2457,7 +2459,7 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, wmEvent *event) rcti *rect= gesture->customdata; int sx, sy; - if(event->type== MOUSEMOVE) { + if (event->type== MOUSEMOVE) { wm_subwindow_getorigin(CTX_wm_window(C), gesture->swinid, &sx, &sy); rect->xmin = event->x - sx; @@ -2465,7 +2467,7 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, wmEvent *event) wm_gesture_tag_redraw(C); - if(gesture->mode) + if (gesture->mode) gesture_circle_apply(C, op); } else if (event->type==EVT_MODAL_MAP) { @@ -2476,16 +2478,16 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, wmEvent *event) break; case GESTURE_MODAL_CIRCLE_SUB: rect->xmax -= 2 + rect->xmax/10; - if(rect->xmax < 1) rect->xmax = 1; + if (rect->xmax < 1) rect->xmax = 1; wm_gesture_tag_redraw(C); break; case GESTURE_MODAL_SELECT: case GESTURE_MODAL_DESELECT: case GESTURE_MODAL_NOP: - if(RNA_struct_find_property(op->ptr, "gesture_mode")) + if (RNA_struct_find_property(op->ptr, "gesture_mode")) RNA_int_set(op->ptr, "gesture_mode", event->val); - if(event->val != GESTURE_MODAL_NOP) { + if (event->val != GESTURE_MODAL_NOP) { /* apply first click */ gesture_circle_apply(C, op); gesture->mode= 1; @@ -2552,13 +2554,13 @@ static void tweak_gesture_modal(bContext *C, wmEvent *event) rect->xmax = event->x - sx; rect->ymax = event->y - sy; - if((val= wm_gesture_evaluate(gesture))) { + if ((val= wm_gesture_evaluate(gesture))) { wmEvent tevent; tevent= *(window->eventstate); - if(gesture->event_type==LEFTMOUSE) + if (gesture->event_type==LEFTMOUSE) tevent.type= EVT_TWEAK_L; - else if(gesture->event_type==RIGHTMOUSE) + else if (gesture->event_type==RIGHTMOUSE) tevent.type= EVT_TWEAK_R; else tevent.type= EVT_TWEAK_M; @@ -2574,7 +2576,7 @@ static void tweak_gesture_modal(bContext *C, wmEvent *event) case LEFTMOUSE: case RIGHTMOUSE: case MIDDLEMOUSE: - if(gesture->event_type==event->type) { + if (gesture->event_type==event->type) { WM_gesture_end(C, gesture); /* when tweak fails we should give the other keymap entries a chance */ @@ -2582,7 +2584,7 @@ static void tweak_gesture_modal(bContext *C, wmEvent *event) } break; default: - if(!ISTIMER(event->type)) { + if (!ISTIMER(event->type)) { WM_gesture_end(C, gesture); } break; @@ -2594,17 +2596,17 @@ void wm_tweakevent_test(bContext *C, wmEvent *event, int action) { wmWindow *win= CTX_wm_window(C); - if(win->tweak==NULL) { - if(CTX_wm_region(C)) { - if(event->val==KM_PRESS) { - if( ELEM3(event->type, LEFTMOUSE, MIDDLEMOUSE, RIGHTMOUSE) ) + if (win->tweak==NULL) { + if (CTX_wm_region(C)) { + if (event->val==KM_PRESS) { + if ( ELEM3(event->type, LEFTMOUSE, MIDDLEMOUSE, RIGHTMOUSE) ) win->tweak= WM_gesture_new(C, event, WM_GESTURE_TWEAK); } } } else { /* no tweaks if event was handled */ - if((action & WM_HANDLER_BREAK)) { + if ((action & WM_HANDLER_BREAK)) { WM_gesture_end(C, win->tweak); } else @@ -2623,7 +2625,7 @@ int WM_gesture_lasso_invoke(bContext *C, wmOperator *op, wmEvent *event) wm_gesture_tag_redraw(C); - if( RNA_struct_find_property(op->ptr, "cursor") ) + if ( RNA_struct_find_property(op->ptr, "cursor") ) WM_cursor_modal(CTX_wm_window(C), RNA_int_get(op->ptr, "cursor")); return OPERATOR_RUNNING_MODAL; @@ -2638,7 +2640,7 @@ int WM_gesture_lines_invoke(bContext *C, wmOperator *op, wmEvent *event) wm_gesture_tag_redraw(C); - if( RNA_struct_find_property(op->ptr, "cursor") ) + if ( RNA_struct_find_property(op->ptr, "cursor") ) WM_cursor_modal(CTX_wm_window(C), RNA_int_get(op->ptr, "cursor")); return OPERATOR_RUNNING_MODAL; @@ -2656,7 +2658,7 @@ static void gesture_lasso_apply(bContext *C, wmOperator *op) /* operator storage as path. */ RNA_collection_clear(op->ptr, "path"); - for(i=0; ipoints; i++, lasso+=2) { + for (i=0; ipoints; i++, lasso+=2) { loc[0]= lasso[0]; loc[1]= lasso[1]; RNA_collection_add(op->ptr, "path", &itemptr); @@ -2665,7 +2667,7 @@ static void gesture_lasso_apply(bContext *C, wmOperator *op) wm_gesture_end(C, op); - if(op->type->exec) + if (op->type->exec) op->type->exec(C, op); } @@ -2682,7 +2684,7 @@ int WM_gesture_lasso_modal(bContext *C, wmOperator *op, wmEvent *event) wm_subwindow_getorigin(CTX_wm_window(C), gesture->swinid, &sx, &sy); - if(gesture->points == gesture->size) { + if (gesture->points == gesture->size) { short *old_lasso = gesture->customdata; gesture->customdata= MEM_callocN(2*sizeof(short)*(gesture->size + WM_LASSO_MIN_POINTS), "lasso points"); memcpy(gesture->customdata, old_lasso, 2*sizeof(short)*gesture->size); @@ -2701,7 +2703,7 @@ int WM_gesture_lasso_modal(bContext *C, wmOperator *op, wmEvent *event) /* make a simple distance check to get a smoother lasso * add only when at least 2 pixels between this and previous location */ - if((x*x+y*y) > 4) { + if ((x*x+y*y) > 4) { lasso += 2; lasso[0] = event->x - sx; lasso[1] = event->y - sy; @@ -2713,7 +2715,7 @@ int WM_gesture_lasso_modal(bContext *C, wmOperator *op, wmEvent *event) case LEFTMOUSE: case MIDDLEMOUSE: case RIGHTMOUSE: - if(event->val==KM_RELEASE) { /* key release */ + if (event->val==KM_RELEASE) { /* key release */ gesture_lasso_apply(C, op); return OPERATOR_FINISHED; } @@ -2786,7 +2788,7 @@ static int straightline_apply(bContext *C, wmOperator *op) wmGesture *gesture= op->customdata; rcti *rect= gesture->customdata; - if(rect->xmin ==rect->xmax && rect->ymin==rect->ymax) + if (rect->xmin ==rect->xmax && rect->ymin==rect->ymax) return 0; /* operator arguments and storage. */ @@ -2795,7 +2797,7 @@ static int straightline_apply(bContext *C, wmOperator *op) RNA_int_set(op->ptr, "xend", rect->xmax); RNA_int_set(op->ptr, "yend", rect->ymax); - if(op->type->exec) + if (op->type->exec) op->type->exec(C, op); return 1; @@ -2811,7 +2813,7 @@ int WM_gesture_straightline_invoke(bContext *C, wmOperator *op, wmEvent *event) wm_gesture_tag_redraw(C); - if( RNA_struct_find_property(op->ptr, "cursor") ) + if ( RNA_struct_find_property(op->ptr, "cursor") ) WM_cursor_modal(CTX_wm_window(C), RNA_int_get(op->ptr, "cursor")); return OPERATOR_RUNNING_MODAL; @@ -2823,10 +2825,10 @@ int WM_gesture_straightline_modal(bContext *C, wmOperator *op, wmEvent *event) rcti *rect= gesture->customdata; int sx, sy; - if(event->type== MOUSEMOVE) { + if (event->type== MOUSEMOVE) { wm_subwindow_getorigin(CTX_wm_window(C), gesture->swinid, &sx, &sy); - if(gesture->mode==0) { + if (gesture->mode==0) { rect->xmin = rect->xmax = event->x - sx; rect->ymin = rect->ymax = event->y - sy; } @@ -2841,13 +2843,13 @@ int WM_gesture_straightline_modal(bContext *C, wmOperator *op, wmEvent *event) else if (event->type==EVT_MODAL_MAP) { switch (event->val) { case GESTURE_MODAL_BEGIN: - if(gesture->mode==0) { + if (gesture->mode==0) { gesture->mode= 1; wm_gesture_tag_redraw(C); } break; case GESTURE_MODAL_SELECT: - if(straightline_apply(C, op)) { + if (straightline_apply(C, op)) { wm_gesture_end(C, op); return OPERATOR_FINISHED; } @@ -2932,7 +2934,7 @@ static void radial_control_set_initial_mouse(RadialControl *rc, wmEvent *event) return; } - if(rc->zoom_prop) { + if (rc->zoom_prop) { RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom); d[0] *= zoom[0]; d[1] *= zoom[1]; @@ -2948,7 +2950,7 @@ static void radial_control_set_tex(RadialControl *rc) switch(RNA_type_to_ID_code(rc->image_id_ptr.type)) { case ID_BR: - if((ibuf = brush_gen_radial_control_imbuf(rc->image_id_ptr.data))) { + if ((ibuf = brush_gen_radial_control_imbuf(rc->image_id_ptr.data))) { glGenTextures(1, &rc->gltex); glBindTexture(GL_TEXTURE_2D, rc->gltex); glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, ibuf->x, ibuf->y, 0, @@ -2968,18 +2970,18 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph float rot; /* set fill color */ - if(rc->fill_col_prop) + if (rc->fill_col_prop) RNA_property_float_get_array(&rc->fill_col_ptr, rc->fill_col_prop, col); glColor4f(col[0], col[1], col[2], alpha); - if(rc->gltex) { + if (rc->gltex) { glBindTexture(GL_TEXTURE_2D, rc->gltex); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); /* set up rotation if available */ - if(rc->rot_prop) { + if (rc->rot_prop) { rot = RNA_property_float_get(&rc->rot_ptr, rc->rot_prop); glPushMatrix(); glRotatef(RAD2DEGF(rot), 0, 0, 1); @@ -3000,7 +3002,7 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph glDisable(GL_TEXTURE_2D); /* undo rotation */ - if(rc->rot_prop) + if (rc->rot_prop) glPopMatrix(); } else { @@ -3047,7 +3049,7 @@ static void radial_control_paint_cursor(bContext *C, int x, int y, void *customd glEnable(GL_LINE_SMOOTH); /* apply zoom if available */ - if(rc->zoom_prop) { + if (rc->zoom_prop) { RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom); glScalef(zoom[0], zoom[1], 1); } @@ -3056,11 +3058,11 @@ static void radial_control_paint_cursor(bContext *C, int x, int y, void *customd radial_control_paint_tex(rc, tex_radius, alpha); /* set line color */ - if(rc->col_prop) + if (rc->col_prop) RNA_property_float_get_array(&rc->col_ptr, rc->col_prop, col); glColor4f(col[0], col[1], col[2], 0.5); - if(rc->subtype == PROP_ANGLE) { + if (rc->subtype == PROP_ANGLE) { glPushMatrix(); /* draw original angle line */ glRotatef(RAD2DEGF(rc->initial_value), 0, 0, 1); @@ -3097,28 +3099,28 @@ static int radial_control_get_path(PointerRNA *ctx_ptr, wmOperator *op, char *str; /* check flags */ - if((flags & RC_PROP_REQUIRE_BOOL) && (flags & RC_PROP_REQUIRE_FLOAT)) { + if ((flags & RC_PROP_REQUIRE_BOOL) && (flags & RC_PROP_REQUIRE_FLOAT)) { BKE_reportf(op->reports, RPT_ERROR, "Property can't be both boolean and float"); return 0; } /* get an rna string path from the operator's properties */ - if(!(str = RNA_string_get_alloc(op->ptr, name, NULL, 0))) + if (!(str = RNA_string_get_alloc(op->ptr, name, NULL, 0))) return 1; - if(str[0] == '\0') { - if(r_prop) *r_prop = NULL; + if (str[0] == '\0') { + if (r_prop) *r_prop = NULL; MEM_freeN(str); return 1; } - if(!r_prop) + if (!r_prop) r_prop = &unused_prop; /* get rna from path */ - if(!RNA_path_resolve(ctx_ptr, str, r_ptr, r_prop)) { + if (!RNA_path_resolve(ctx_ptr, str, r_ptr, r_prop)) { MEM_freeN(str); - if(flags & RC_PROP_ALLOW_MISSING) + if (flags & RC_PROP_ALLOW_MISSING) return 1; else { BKE_reportf(op->reports, RPT_ERROR, "Couldn't resolve path %s", name); @@ -3127,10 +3129,10 @@ static int radial_control_get_path(PointerRNA *ctx_ptr, wmOperator *op, } /* check property type */ - if(flags & (RC_PROP_REQUIRE_BOOL | RC_PROP_REQUIRE_FLOAT)) { + if (flags & (RC_PROP_REQUIRE_BOOL | RC_PROP_REQUIRE_FLOAT)) { PropertyType prop_type = RNA_property_type(*r_prop); - if(((flags & RC_PROP_REQUIRE_BOOL) && (prop_type != PROP_BOOLEAN)) || + if (((flags & RC_PROP_REQUIRE_BOOL) && (prop_type != PROP_BOOLEAN)) || ((flags & RC_PROP_REQUIRE_FLOAT) && prop_type != PROP_FLOAT)) { MEM_freeN(str); BKE_reportf(op->reports, RPT_ERROR, @@ -3140,7 +3142,7 @@ static int radial_control_get_path(PointerRNA *ctx_ptr, wmOperator *op, } /* check property's array length */ - if(*r_prop && (len = RNA_property_array_length(r_ptr, *r_prop)) != req_length) { + if (*r_prop && (len = RNA_property_array_length(r_ptr, *r_prop)) != req_length) { MEM_freeN(str); BKE_reportf(op->reports, RPT_ERROR, "Property from path %s has length %d instead of %d", @@ -3164,47 +3166,47 @@ static int radial_control_get_properties(bContext *C, wmOperator *op) RNA_pointer_create(NULL, &RNA_Context, C, &ctx_ptr); /* check if we use primary or secondary path */ - if(!radial_control_get_path(&ctx_ptr, op, "use_secondary", + if (!radial_control_get_path(&ctx_ptr, op, "use_secondary", &use_secondary_ptr, &use_secondary_prop, 0, (RC_PROP_ALLOW_MISSING| RC_PROP_REQUIRE_BOOL))) { return 0; } else { - if(use_secondary_prop && + if (use_secondary_prop && RNA_property_boolean_get(&use_secondary_ptr, use_secondary_prop)) data_path = "data_path_secondary"; else data_path = "data_path_primary"; } - if(!radial_control_get_path(&ctx_ptr, op, data_path, &rc->ptr, &rc->prop, 0, 0)) + if (!radial_control_get_path(&ctx_ptr, op, data_path, &rc->ptr, &rc->prop, 0, 0)) return 0; /* data path is required */ - if(!rc->prop) + if (!rc->prop) return 0; - if(!radial_control_get_path(&ctx_ptr, op, "rotation_path", &rc->rot_ptr, &rc->rot_prop, 0, RC_PROP_REQUIRE_FLOAT)) + if (!radial_control_get_path(&ctx_ptr, op, "rotation_path", &rc->rot_ptr, &rc->rot_prop, 0, RC_PROP_REQUIRE_FLOAT)) return 0; - if(!radial_control_get_path(&ctx_ptr, op, "color_path", &rc->col_ptr, &rc->col_prop, 3, RC_PROP_REQUIRE_FLOAT)) + if (!radial_control_get_path(&ctx_ptr, op, "color_path", &rc->col_ptr, &rc->col_prop, 3, RC_PROP_REQUIRE_FLOAT)) return 0; - if(!radial_control_get_path(&ctx_ptr, op, "fill_color_path", &rc->fill_col_ptr, &rc->fill_col_prop, 3, RC_PROP_REQUIRE_FLOAT)) + if (!radial_control_get_path(&ctx_ptr, op, "fill_color_path", &rc->fill_col_ptr, &rc->fill_col_prop, 3, RC_PROP_REQUIRE_FLOAT)) return 0; /* slightly ugly; allow this property to not resolve * correctly. needed because 3d texture paint shares the same * keymap as 2d image paint */ - if(!radial_control_get_path(&ctx_ptr, op, "zoom_path", + if (!radial_control_get_path(&ctx_ptr, op, "zoom_path", &rc->zoom_ptr, &rc->zoom_prop, 2, RC_PROP_REQUIRE_FLOAT|RC_PROP_ALLOW_MISSING)) return 0; - if(!radial_control_get_path(&ctx_ptr, op, "image_id", &rc->image_id_ptr, NULL, 0, 0)) + if (!radial_control_get_path(&ctx_ptr, op, "image_id", &rc->image_id_ptr, NULL, 0, 0)) return 0; - else if(rc->image_id_ptr.data) { + else if (rc->image_id_ptr.data) { /* extra check, pointer must be to an ID */ - if(!RNA_struct_is_ID(rc->image_id_ptr.type)) { + if (!RNA_struct_is_ID(rc->image_id_ptr.type)) { BKE_report(op->reports, RPT_ERROR, "Pointer from path image_id is not an ID"); return 0; @@ -3221,10 +3223,10 @@ static int radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) int min_value_int, max_value_int, step_int; float step_float, precision; - if(!(op->customdata = rc = MEM_callocN(sizeof(RadialControl), "RadialControl"))) + if (!(op->customdata = rc = MEM_callocN(sizeof(RadialControl), "RadialControl"))) return OPERATOR_CANCELLED; - if(!radial_control_get_properties(C, op)) { + if (!radial_control_get_properties(C, op)) { MEM_freeN(rc); return OPERATOR_CANCELLED; } @@ -3251,7 +3253,7 @@ static int radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) /* get subtype of property */ rc->subtype = RNA_property_subtype(rc->prop); - if(!ELEM3(rc->subtype, PROP_DISTANCE, PROP_FACTOR, PROP_ANGLE)) { + if (!ELEM3(rc->subtype, PROP_DISTANCE, PROP_FACTOR, PROP_ANGLE)) { BKE_report(op->reports, RPT_ERROR, "Property must be a distance, a factor, or an angle"); MEM_freeN(rc); return OPERATOR_CANCELLED; @@ -3326,7 +3328,7 @@ static int radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) delta[0]= rc->initial_mouse[0] - event->x; delta[1]= rc->initial_mouse[1] - event->y; - if(rc->zoom_prop) { + if (rc->zoom_prop) { RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom); delta[0] /= zoom[0]; delta[1] /= zoom[1]; @@ -3338,15 +3340,15 @@ static int radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) switch(rc->subtype) { case PROP_DISTANCE: new_value = dist; - if(snap) new_value = ((int)new_value + 5) / 10*10; + if (snap) new_value = ((int)new_value + 5) / 10*10; break; case PROP_FACTOR: new_value = 1 - dist / WM_RADIAL_CONTROL_DISPLAY_SIZE; - if(snap) new_value = ((int)ceil(new_value * 10.f) * 10.0f) / 100.f; + if (snap) new_value = ((int)ceil(new_value * 10.f) * 10.0f) / 100.f; break; case PROP_ANGLE: new_value = atan2(delta[1], delta[0]) + M_PI; - if(snap) new_value = DEG2RADF(((int)RAD2DEGF(new_value) + 5) / 10*10); + if (snap) new_value = DEG2RADF(((int)RAD2DEGF(new_value) + 5) / 10*10); break; default: new_value = dist; /* dummy value, should this ever happen? - campbell */ @@ -3375,7 +3377,7 @@ static int radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) ED_region_tag_redraw(CTX_wm_region(C)); - if(ret != OPERATOR_RUNNING_MODAL) + if (ret != OPERATOR_RUNNING_MODAL) radial_control_cancel(C, op); return ret; @@ -3412,7 +3414,7 @@ static void redraw_timer_window_swap(bContext *C) wmWindow *win= CTX_wm_window(C); ScrArea *sa; - for(sa= CTX_wm_screen(C)->areabase.first; sa; sa= sa->next) + for (sa= CTX_wm_screen(C)->areabase.first; sa; sa= sa->next) ED_area_tag_redraw(sa); wm_draw_update(C); @@ -3441,9 +3443,9 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) WM_cursor_wait(1); - for(a=0; aareabase.first; sa; sa= sa->next) { + for (sa= CTX_wm_screen(C)->areabase.first; sa; sa= sa->next) { ARegion *ar_iter; CTX_wm_area_set(C, sa); - for(ar_iter= sa->regionbase.first; ar_iter; ar_iter= ar_iter->next) { - if(ar_iter->swinid) { + for (ar_iter= sa->regionbase.first; ar_iter; ar_iter= ar_iter->next) { + if (ar_iter->swinid) { CTX_wm_region_set(C, ar_iter); ED_region_do_draw(C, ar_iter); } @@ -3485,7 +3487,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); - if(a & 1) scene->r.cfra--; + if (a & 1) scene->r.cfra--; else scene->r.cfra++; scene_update_for_newframe(bmain, scene, scene->lay); } @@ -3496,10 +3498,10 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); int tot= (scene->r.efra - scene->r.sfra) + 1; - while(tot--) { + while (tot--) { /* todo, ability to escape! */ scene->r.cfra++; - if(scene->r.cfra > scene->r.efra) + if (scene->r.cfra > scene->r.efra) scene->r.cfra= scene->r.sfra; scene_update_for_newframe(bmain, scene, scene->lay); @@ -3585,12 +3587,12 @@ static int wm_ndof_sensitivity_exec(bContext *UNUSED(C), wmOperator *op) float change; float sensitivity = U.ndof_sensitivity; - if(RNA_boolean_get(op->ptr, "fast")) + if (RNA_boolean_get(op->ptr, "fast")) change = 0.5f; // 50% change else change = 0.1f; // 10% - if(RNA_boolean_get(op->ptr, "decrease")) { + if (RNA_boolean_get(op->ptr, "decrease")) { sensitivity -= sensitivity * change; if (sensitivity < min) sensitivity = min; @@ -3628,10 +3630,10 @@ static void operatortype_ghash_free_cb(wmOperatorType *ot) MEM_freeN(ot->last_properties); } - if(ot->macro.first) + if (ot->macro.first) wm_operatortype_free_macro(ot); - if(ot->ext.srna) /* python operator, allocs own string */ + if (ot->ext.srna) /* python operator, allocs own string */ MEM_freeN((void *)ot->idname); MEM_freeN(ot); @@ -3701,7 +3703,7 @@ static void gesture_circle_modal_keymap(wmKeyConfig *keyconf) wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "View3D Gesture Circle"); /* this function is called for each spacetype, only needs to add map once */ - if(keymap) return; + if (keymap) return; keymap= WM_modalkeymap_add(keyconf, "View3D Gesture Circle", modal_items); @@ -3748,7 +3750,7 @@ static void gesture_straightline_modal_keymap(wmKeyConfig *keyconf) wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "Gesture Straight Line"); /* this function is called for each spacetype, only needs to add map once */ - if(keymap) return; + if (keymap) return; keymap= WM_modalkeymap_add(keyconf, "Gesture Straight Line", modal_items); @@ -3777,7 +3779,7 @@ static void gesture_border_modal_keymap(wmKeyConfig *keyconf) wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "Gesture Border"); /* this function is called for each spacetype, only needs to add map once */ - if(keymap) return; + if (keymap) return; keymap= WM_modalkeymap_add(keyconf, "Gesture Border", modal_items); @@ -3836,7 +3838,7 @@ static void gesture_zoom_border_modal_keymap(wmKeyConfig *keyconf) wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "Gesture Zoom Border"); /* this function is called for each spacetype, only needs to add map once */ - if(keymap) return; + if (keymap) return; keymap= WM_modalkeymap_add(keyconf, "Gesture Zoom Border", modal_items); @@ -3974,8 +3976,8 @@ static EnumPropertyItem *rna_id_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(pt int totitem= 0; int i= 0; - for( ; id; id= id->next) { - if(local==FALSE || id->lib==NULL) { + for ( ; id; id= id->next) { + if (local==FALSE || id->lib==NULL) { item_tmp.identifier= item_tmp.name= id->name+2; item_tmp.value= i++; RNA_enum_item_add(&item, &totitem, &item_tmp); diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c index 662c8eb254c..149c1355c06 100644 --- a/source/blender/windowmanager/intern/wm_subwindow.c +++ b/source/blender/windowmanager/intern/wm_subwindow.c @@ -87,7 +87,7 @@ void wm_subwindows_free(wmWindow *win) { wmSubWindow *swin; - for(swin= win->subwindows.first; swin; swin= swin->next) + for (swin= win->subwindows.first; swin; swin= swin->next) wm_subwindow_free(swin); BLI_freelistN(&win->subwindows); @@ -96,7 +96,7 @@ void wm_subwindows_free(wmWindow *win) int wm_subwindow_get(wmWindow *win) { - if(win->curswin) + if (win->curswin) return win->curswin->swinid; return 0; } @@ -105,8 +105,8 @@ static wmSubWindow *swin_from_swinid(wmWindow *win, int swinid) { wmSubWindow *swin; - for(swin= win->subwindows.first; swin; swin= swin->next) - if(swin->swinid==swinid) + for (swin= win->subwindows.first; swin; swin= swin->next) + if (swin->swinid==swinid) break; return swin; } @@ -115,7 +115,7 @@ void wm_subwindow_getsize(wmWindow *win, int swinid, int *x, int *y) { wmSubWindow *swin= swin_from_swinid(win, swinid); - if(swin) { + if (swin) { *x= swin->winrct.xmax - swin->winrct.xmin + 1; *y= swin->winrct.ymax - swin->winrct.ymin + 1; } @@ -125,7 +125,7 @@ void wm_subwindow_getorigin(wmWindow *win, int swinid, int *x, int *y) { wmSubWindow *swin= swin_from_swinid(win, swinid); - if(swin) { + if (swin) { *x= swin->winrct.xmin; *y= swin->winrct.ymin; } @@ -135,9 +135,9 @@ void wm_subwindow_getmatrix(wmWindow *win, int swinid, float mat[][4]) { wmSubWindow *swin= swin_from_swinid(win, swinid); - if(swin) { + if (swin) { /* used by UI, should find a better way to get the matrix there */ - if(swinid == win->screen->mainwin) { + if (swinid == win->screen->mainwin) { int width, height; wm_subwindow_getsize(win, swin->swinid, &width, &height); @@ -156,14 +156,14 @@ int wm_subwindow_open(wmWindow *win, rcti *winrct) int width, height; int freewinid= 1; - for(swin= win->subwindows.first; swin; swin= swin->next) - if(freewinid <= swin->swinid) + for (swin= win->subwindows.first; swin; swin= swin->next) + if (freewinid <= swin->swinid) freewinid= swin->swinid+1; win->curswin= swin= MEM_callocN(sizeof(wmSubWindow), "swinopen"); BLI_addtail(&win->subwindows, swin); - if(G.f & G_DEBUG) printf("swin %d added\n", freewinid); + if (G.f & G_DEBUG) printf("swin %d added\n", freewinid); swin->swinid= freewinid; swin->winrct= *winrct; @@ -201,7 +201,7 @@ void wm_subwindow_position(wmWindow *win, int swinid, rcti *winrct) { wmSubWindow *swin= swin_from_swinid(win, swinid); - if(swin) { + if (swin) { int width, height; swin->winrct= *winrct; @@ -246,7 +246,7 @@ void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct) int width, height; _curswin= swin_from_swinid(win, swinid); - if(_curswin==NULL) { + if (_curswin==NULL) { printf("wmSubWindowSet %d: doesn't exist\n", swinid); return; } @@ -258,7 +258,7 @@ void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct) height= _curswin->winrct.ymax - _curswin->winrct.ymin + 1; glViewport(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height); - if(srct) { + if (srct) { width= srct->xmax - srct->xmin + 1; height= srct->ymax - srct->ymin + 1; glScissor(srct->xmin, srct->ymin, width, height); @@ -300,8 +300,8 @@ void wmOrtho(float x1, float x2, float y1, float y2, float n, float f) void wmOrtho2(float x1, float x2, float y1, float y2) { /* prevent opengl from generating errors */ - if(x1==x2) x2+=1.0f; - if(y1==y2) y2+=1.0f; + if (x1==x2) x2+=1.0f; + if (y1==y2) y2+=1.0f; wmOrtho(x1, x2, y1, y2, -100, 100); } diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index cc5b9abdd69..b79a89b89bd 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -119,33 +119,33 @@ static void wm_window_check_position(rcti *rect) height -= 70; #endif - if(rect->xmin < 0) { + if (rect->xmin < 0) { rect->xmax -= rect->xmin; rect->xmin = 0; } - if(rect->ymin < 0) { + if (rect->ymin < 0) { rect->ymax -= rect->ymin; rect->ymin = 0; } - if(rect->xmax > width) { + if (rect->xmax > width) { d= rect->xmax - width; rect->xmax -= d; rect->xmin -= d; } - if(rect->ymax > height) { + if (rect->ymax > height) { d= rect->ymax - height; rect->ymax -= d; rect->ymin -= d; } - if(rect->xmin < 0) rect->xmin = 0; - if(rect->ymin < 0) rect->ymin = 0; + if (rect->xmin < 0) rect->xmin = 0; + if (rect->ymin < 0) rect->ymin = 0; } static void wm_ghostwindow_destroy(wmWindow *win) { - if(win->ghostwin) { + if (win->ghostwin) { GHOST_DisposeWindow(g_system, win->ghostwin); win->ghostwin= NULL; } @@ -158,11 +158,11 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win) wmTimer *wt, *wtnext; /* update context */ - if(C) { + if (C) { WM_event_remove_handlers(C, &win->handlers); WM_event_remove_handlers(C, &win->modalhandlers); - if(CTX_wm_window(C)==win) + if (CTX_wm_window(C)==win) CTX_wm_window_set(C, NULL); } @@ -172,25 +172,25 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win) wm->winactive= NULL; /* end running jobs, a job end also removes its timer */ - for(wt= wm->timers.first; wt; wt= wtnext) { + for (wt= wm->timers.first; wt; wt= wtnext) { wtnext= wt->next; - if(wt->win==win && wt->event_type==TIMERJOBS) + if (wt->win==win && wt->event_type==TIMERJOBS) wm_jobs_timer_ended(wm, wt); } /* timer removing, need to call this api function */ - for(wt= wm->timers.first; wt; wt=wtnext) { + for (wt= wm->timers.first; wt; wt=wtnext) { wtnext= wt->next; - if(wt->win==win) + if (wt->win==win) WM_event_remove_timer(wm, win, wt); } - if(win->eventstate) MEM_freeN(win->eventstate); + if (win->eventstate) MEM_freeN(win->eventstate); wm_event_free_all(win); wm_subwindows_free(win); - if(win->drawdata) + if (win->drawdata) MEM_freeN(win->drawdata); wm_ghostwindow_destroy(win); @@ -203,8 +203,8 @@ static int find_free_winid(wmWindowManager *wm) wmWindow *win; int id= 1; - for(win= wm->windows.first; win; win= win->next) - if(id <= win->winid) + for (win= wm->windows.first; win; win= win->next) + if (id <= win->winid) id= win->winid+1; return id; @@ -254,16 +254,16 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win) bScreen *screen= win->screen; /* first check if we have any non-temp remaining windows */ - if((U.uiflag & USER_QUIT_PROMPT) && !wm->file_saved){ - if(wm->windows.first) { - for(tmpwin = wm->windows.first; tmpwin; tmpwin = tmpwin->next){ - if(tmpwin == win) + if ((U.uiflag & USER_QUIT_PROMPT) && !wm->file_saved) { + if (wm->windows.first) { + for (tmpwin = wm->windows.first; tmpwin; tmpwin = tmpwin->next) { + if (tmpwin == win) continue; - if(tmpwin->screen->temp == 0) + if (tmpwin->screen->temp == 0) break; } - if(tmpwin == NULL){ - if(!GHOST_confirmQuit(win->ghostwin)) + if (tmpwin == NULL) { + if (!GHOST_confirmQuit(win->ghostwin)) return; } } @@ -280,18 +280,18 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win) wm_window_free(C, wm, win); /* if temp screen, delete it after window free (it stops jobs that can access it) */ - if(screen->temp) { + if (screen->temp) { Main *bmain= CTX_data_main(C); free_libblock(&bmain->screen, screen); } /* check remaining windows */ - if(wm->windows.first) { - for(win= wm->windows.first; win; win= win->next) - if(win->screen->temp == 0) + if (wm->windows.first) { + for (win= wm->windows.first; win; win= win->next) + if (win->screen->temp == 0) break; /* in this case we close all */ - if(win==NULL) + if (win==NULL) WM_exit(C); } else @@ -301,15 +301,15 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win) void wm_window_title(wmWindowManager *wm, wmWindow *win) { /* handle the 'temp' window, only set title when not set before */ - if(win->screen && win->screen->temp) { + if (win->screen && win->screen->temp) { char *title= GHOST_GetTitle(win->ghostwin); - if(title==NULL || title[0]==0) + if (title==NULL || title[0]==0) GHOST_SetTitle(win->ghostwin, "Blender"); } else { /* this is set to 1 if you don't have startup.blend open */ - if(G.save_over && G.main->name[0]) { + if (G.save_over && G.main->name[0]) { char str[sizeof(G.main->name) + 12]; BLI_snprintf(str, sizeof(str), "Blender%s [%s]", wm->file_saved ? "":"*", G.main->name); GHOST_SetTitle(win->ghostwin, str); @@ -323,7 +323,7 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win) GHOST_SetWindowModifiedState(win->ghostwin, (GHOST_TUns8)!wm->file_saved); #if defined(__APPLE__) && !defined(GHOST_COCOA) - if(wm->file_saved) + if (wm->file_saved) GHOST_SetWindowState(win->ghostwin, GHOST_kWindowStateUnModified); else GHOST_SetWindowState(win->ghostwin, GHOST_kWindowStateModified); @@ -365,13 +365,13 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win) win->ghostwin= ghostwin; GHOST_SetWindowUserData(ghostwin, win); /* pointer back */ - if(win->eventstate==NULL) + if (win->eventstate==NULL) win->eventstate= MEM_callocN(sizeof(wmEvent), "window event state"); /* until screens get drawn, make it nice grey */ glClearColor(.55, .55, .55, 0.0); /* Crash on OSS ATI: bugs.launchpad.net/ubuntu/+source/mesa/+bug/656100 */ - if(!GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) { + if (!GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) { glClear(GL_COLOR_BUFFER_BIT); } @@ -433,7 +433,7 @@ void wm_window_add_ghostwindows(wmWindowManager *wm) wm_window_add_ghostwindow("Blender", win); } /* happens after fileread */ - if(win->eventstate==NULL) + if (win->eventstate==NULL) win->eventstate= MEM_callocN(sizeof(wmEvent), "window event state"); /* add keymap handlers (1 handler for all keys in map!) */ @@ -488,12 +488,12 @@ void WM_window_open_temp(bContext *C, rcti *position, int type) wm_window_check_position(position); /* test if we have a temp screen already */ - for(win= CTX_wm_manager(C)->windows.first; win; win= win->next) - if(win->screen->temp) + for (win= CTX_wm_manager(C)->windows.first; win; win= win->next) + if (win->screen->temp) break; /* add new window? */ - if(win==NULL) { + if (win==NULL) { win= wm_window_new(C); win->posx= position->xmin; @@ -503,13 +503,13 @@ void WM_window_open_temp(bContext *C, rcti *position, int type) win->sizex= position->xmax - position->xmin; win->sizey= position->ymax - position->ymin; - if(win->ghostwin) { + if (win->ghostwin) { wm_window_set_size(win, win->sizex, win->sizey); wm_window_raise(win); } /* add new screen? */ - if(win->screen==NULL) + if (win->screen==NULL) win->screen= ED_screen_add(win, CTX_data_scene(C), "temp"); win->screen->temp = 1; @@ -521,7 +521,7 @@ void WM_window_open_temp(bContext *C, rcti *position, int type) sa= win->screen->areabase.first; CTX_wm_area_set(C, sa); - if(type==WM_WINDOW_RENDER) { + if (type==WM_WINDOW_RENDER) { ED_area_newspace(C, sa, SPACE_IMAGE); } else { @@ -530,11 +530,11 @@ void WM_window_open_temp(bContext *C, rcti *position, int type) ED_screen_set(C, win->screen); - if(sa->spacetype==SPACE_IMAGE) + if (sa->spacetype==SPACE_IMAGE) GHOST_SetTitle(win->ghostwin, IFACE_("Blender Render")); - else if(ELEM(sa->spacetype, SPACE_OUTLINER, SPACE_USERPREF)) + else if (ELEM(sa->spacetype, SPACE_OUTLINER, SPACE_USERPREF)) GHOST_SetTitle(win->ghostwin, IFACE_("Blender User Preferences")); - else if(sa->spacetype==SPACE_FILE) + else if (sa->spacetype==SPACE_FILE) GHOST_SetTitle(win->ghostwin, IFACE_("Blender File View")); else GHOST_SetTitle(win->ghostwin, "Blender"); @@ -561,11 +561,11 @@ int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator *UNUSED(op)) wmWindow *window= CTX_wm_window(C); GHOST_TWindowState state; - if(G.background) + if (G.background) return OPERATOR_CANCELLED; state= GHOST_GetWindowState(window->ghostwin); - if(state!=GHOST_kWindowStateFullScreen) + if (state!=GHOST_kWindowStateFullScreen) GHOST_SetWindowState(window->ghostwin, GHOST_kWindowStateFullScreen); else GHOST_SetWindowState(window->ghostwin, GHOST_kWindowStateNormal); @@ -625,7 +625,7 @@ void wm_window_make_drawable(bContext *C, wmWindow *win) // win->lmbut= 0; /* keeps hanging when mousepressed while other window opened */ wm->windrawable= win; - if(G.f & G_DEBUG) printf("set drawable %d\n", win->winid); + if (G.f & G_DEBUG) printf("set drawable %d\n", win->winid); GHOST_ActivateWindowDrawingContext(win->ghostwin); } } @@ -640,7 +640,8 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) if (type == GHOST_kEventQuit) { WM_exit(C); - } else { + } + else { GHOST_WindowHandle ghostwin= GHOST_GetEventWindow(evt); GHOST_TEventDataPtr data= GHOST_GetEventData(evt); wmWindow *win; @@ -650,12 +651,14 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) // what is it? puts(" event has no window"); return 1; - } else if (!GHOST_ValidWindow(g_system, ghostwin)) { + } + else if (!GHOST_ValidWindow(g_system, ghostwin)) { // XXX - should be checked, why are we getting an event here, and // what is it? puts(" event has invalid window"); return 1; - } else { + } + else { win= GHOST_GetWindowUserData(ghostwin); } @@ -713,7 +716,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) break; } case GHOST_kEventWindowUpdate: { - if(G.f & G_DEBUG) printf("ghost redraw\n"); + if (G.f & G_DEBUG) printf("ghost redraw\n"); wm_window_make_drawable(C, win); WM_event_add_notifier(C, NC_WINDOW, NULL); @@ -727,7 +730,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) win->windowstate = state; /* win32: gives undefined window size when minimized */ - if(state!=GHOST_kWindowStateMinimized) { + if (state!=GHOST_kWindowStateMinimized) { GHOST_RectangleHandle client_rect; int l, t, r, b, scr_w, scr_h; int sizex, sizey, posx, posy; @@ -762,24 +765,24 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) win->posy= posy; /* debug prints */ - if(0) { + if (0) { state = GHOST_GetWindowState(win->ghostwin); - if(state==GHOST_kWindowStateNormal) { - if(G.f & G_DEBUG) printf("window state: normal\n"); + if (state==GHOST_kWindowStateNormal) { + if (G.f & G_DEBUG) printf("window state: normal\n"); } - else if(state==GHOST_kWindowStateMinimized) { - if(G.f & G_DEBUG) printf("window state: minimized\n"); + else if (state==GHOST_kWindowStateMinimized) { + if (G.f & G_DEBUG) printf("window state: minimized\n"); } - else if(state==GHOST_kWindowStateMaximized) { - if(G.f & G_DEBUG) printf("window state: maximized\n"); + else if (state==GHOST_kWindowStateMaximized) { + if (G.f & G_DEBUG) printf("window state: maximized\n"); } - else if(state==GHOST_kWindowStateFullScreen) { - if(G.f & G_DEBUG) printf("window state: fullscreen\n"); + else if (state==GHOST_kWindowStateFullScreen) { + if (G.f & G_DEBUG) printf("window state: fullscreen\n"); } - if(type!=GHOST_kEventWindowSize) { - if(G.f & G_DEBUG) { + if (type!=GHOST_kEventWindowSize) { + if (G.f & G_DEBUG) { printf("win move event pos %d %d size %d %d\n", win->posx, win->posy, win->sizex, win->sizey); } @@ -856,11 +859,11 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) /* add drag data to wm for paths: */ - if(ddd->dataType == GHOST_kDragnDropTypeFilenames) { + if (ddd->dataType == GHOST_kDragnDropTypeFilenames) { GHOST_TStringArray *stra= ddd->data; int a, icon; - for(a=0; acount; a++) { + for (a=0; acount; a++) { printf("drop file %s\n", stra->strings[a]); /* try to get icon type from extension */ icon= ED_file_extension_icon((char *)stra->strings[a]); @@ -900,22 +903,22 @@ static int wm_window_timer(const bContext *C) double time= PIL_check_seconds_timer(); int retval= 0; - for(wt= wm->timers.first; wt; wt= wtnext) { + for (wt= wm->timers.first; wt; wt= wtnext) { wtnext= wt->next; /* in case timer gets removed */ win= wt->win; - if(wt->sleep==0) { - if(time > wt->ntime) { + if (wt->sleep==0) { + if (time > wt->ntime) { wt->delta= time - wt->ltime; wt->duration += wt->delta; wt->ltime= time; wt->ntime= wt->stime + wt->timestep*ceil(wt->duration/wt->timestep); - if(wt->event_type == TIMERJOBS) + if (wt->event_type == TIMERJOBS) wm_jobs_timer(C, wm, wt); - else if(wt->event_type == TIMERAUTOSAVE) + else if (wt->event_type == TIMERAUTOSAVE) wm_autosave_timer(C, wm, wt); - else if(win) { + else if (win) { wmEvent event= *(win->eventstate); event.type= wt->event_type; @@ -935,19 +938,19 @@ void wm_window_process_events(const bContext *C) { int hasevent= GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */ - if(hasevent) + if (hasevent) GHOST_DispatchEvents(g_system); hasevent |= wm_window_timer(C); /* no event, we sleep 5 milliseconds */ - if(hasevent==0) + if (hasevent==0) PIL_sleep_ms(5); } void wm_window_process_events_nosleep(void) { - if(GHOST_ProcessEvents(g_system, 0)) + if (GHOST_ProcessEvents(g_system, 0)) GHOST_DispatchEvents(g_system); } @@ -963,7 +966,7 @@ void wm_window_testbreak(void) if ((curtime-ltime)>.05) { int hasevent= GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */ - if(hasevent) + if (hasevent) GHOST_DispatchEvents(g_system); ltime= curtime; @@ -984,7 +987,7 @@ void wm_ghost_init(bContext *C) void wm_ghost_exit(void) { - if(g_system) + if (g_system) GHOST_DisposeSystem(g_system); g_system= NULL; @@ -997,11 +1000,11 @@ void WM_event_timer_sleep(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *t { wmTimer *wt; - for(wt= wm->timers.first; wt; wt= wt->next) - if(wt==timer) + for (wt= wm->timers.first; wt; wt= wt->next) + if (wt==timer) break; - if(wt) + if (wt) wt->sleep= dosleep; } @@ -1026,15 +1029,15 @@ void WM_event_remove_timer(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer * wmTimer *wt; /* extra security check */ - for(wt= wm->timers.first; wt; wt= wt->next) - if(wt==timer) + for (wt= wm->timers.first; wt; wt= wt->next) + if (wt==timer) break; - if(wt) { - if(wm->reports.reporttimer == wt) + if (wt) { + if (wm->reports.reporttimer == wt) wm->reports.reporttimer= NULL; BLI_remlink(&wm->timers, wt); - if(wt->customdata) + if (wt->customdata) MEM_freeN(wt->customdata); MEM_freeN(wt); } @@ -1046,18 +1049,18 @@ char *WM_clipboard_text_get(int selection) { char *p, *p2, *buf, *newbuf; - if(G.background) + if (G.background) return NULL; buf= (char*)GHOST_getClipboard(selection); - if(!buf) + if (!buf) return NULL; /* always convert from \r\n to \n */ newbuf= MEM_callocN(strlen(buf)+1, "WM_clipboard_text_get"); - for(p= buf, p2= newbuf; *p; p++) { - if(*p != '\r') + for (p= buf, p2= newbuf; *p; p++) { + if (*p != '\r') *(p2++)= *p; } *p2= '\0'; @@ -1069,14 +1072,14 @@ char *WM_clipboard_text_get(int selection) void WM_clipboard_text_set(char *buf, int selection) { - if(!G.background) { + if (!G.background) { #ifdef _WIN32 /* do conversion from \n to \r\n on Windows */ char *p, *p2, *newbuf; int newlen= 0; - for(p= buf; *p; p++) { - if(*p == '\n') + for (p= buf; *p; p++) { + if (*p == '\n') newlen += 2; else newlen++; @@ -1084,8 +1087,8 @@ void WM_clipboard_text_set(char *buf, int selection) newbuf= MEM_callocN(newlen+1, "WM_clipboard_text_set"); - for(p= buf, p2= newbuf; *p; p++, p2++) { - if(*p == '\n') { + for (p= buf, p2= newbuf; *p; p++, p2++) { + if (*p == '\n') { *(p2++)= '\r'; *p2= '\n'; } else *p2= *p; -- cgit v1.2.3