diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/windowmanager/intern/wm.c | 100 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_apple.c | 32 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_cursors.c | 699 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_dragdrop.c | 144 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_draw.c | 272 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 1268 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 246 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_gesture.c | 150 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 48 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_jobs.c | 158 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_keymap.c | 272 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 1216 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_subwindow.c | 158 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 434 |
14 files changed, 2598 insertions, 2599 deletions
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 9fd9defc0ce..638dd4ca807 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -69,7 +69,7 @@ /* ****************************************************** */ -#define MAX_OP_REGISTERED 32 +#define MAX_OP_REGISTERED 32 void WM_operator_free(wmOperator *op) { @@ -83,7 +83,7 @@ void WM_operator_free(wmOperator *op) #endif if (op->ptr) { - op->properties= op->ptr->data; + op->properties = op->ptr->data; MEM_freeN(op->ptr); } @@ -99,7 +99,7 @@ void WM_operator_free(wmOperator *op) 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); } @@ -118,22 +118,22 @@ static void wm_reports_free(wmWindowManager *wm) /* called on event handling by event_system.c */ void wm_operator_register(bContext *C, wmOperator *op) { - wmWindowManager *wm= CTX_wm_manager(C); + wmWindowManager *wm = CTX_wm_manager(C); int tot; BLI_addtail(&wm->operators, op); - tot= BLI_countlist(&wm->operators); + tot = BLI_countlist(&wm->operators); - while (tot>MAX_OP_REGISTERED) { - wmOperator *opt= wm->operators.first; + while (tot > MAX_OP_REGISTERED) { + wmOperator *opt = wm->operators.first; BLI_remlink(&wm->operators, opt); WM_operator_free(opt); tot--; } /* so the console is redrawn */ - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_INFO_REPORT, NULL); - WM_event_add_notifier(C, NC_WM|ND_HISTORY, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO_REPORT, NULL); + WM_event_add_notifier(C, NC_WM | ND_HISTORY, NULL); } @@ -141,24 +141,24 @@ 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); } - WM_main_add_notifier(NC_WM|ND_HISTORY, NULL); + WM_main_add_notifier(NC_WM | ND_HISTORY, NULL); } /* ****************************************** */ -static GHash *menutypes_hash= NULL; +static GHash *menutypes_hash = NULL; MenuType *WM_menutype_find(const char *idname, int quiet) { - MenuType* mt; + MenuType *mt; if (idname[0]) { - mt= BLI_ghash_lookup(menutypes_hash, idname); + mt = BLI_ghash_lookup(menutypes_hash, idname); if (mt) return mt; } @@ -169,13 +169,13 @@ MenuType *WM_menutype_find(const char *idname, int quiet) return NULL; } -int WM_menutype_add(MenuType* mt) +int WM_menutype_add(MenuType *mt) { BLI_ghash_insert(menutypes_hash, (void *)mt->idname, mt); return 1; } -void WM_menutype_freelink(MenuType* mt) +void WM_menutype_freelink(MenuType *mt) { BLI_ghash_remove(menutypes_hash, mt->idname, NULL, (GHashValFreeFP)MEM_freeN); } @@ -183,15 +183,15 @@ void WM_menutype_freelink(MenuType* mt) /* called on initialize WM_init() */ void WM_menutype_init(void) { - menutypes_hash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "menutypes_hash gh"); + menutypes_hash = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "menutypes_hash gh"); } void WM_menutype_free(void) { - GHashIterator *iter= BLI_ghashIterator_new(menutypes_hash); + GHashIterator *iter = BLI_ghashIterator_new(menutypes_hash); - for ( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { - MenuType *mt= BLI_ghashIterator_getValue(iter); + for (; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { + MenuType *mt = BLI_ghashIterator_getValue(iter); if (mt->ext.free) { mt->ext.free(mt->ext.data); } @@ -199,22 +199,22 @@ void WM_menutype_free(void) BLI_ghashIterator_free(iter); BLI_ghash_free(menutypes_hash, NULL, (GHashValFreeFP)MEM_freeN); - menutypes_hash= NULL; + menutypes_hash = NULL; } /* ****************************************** */ void WM_keymap_init(bContext *C) { - wmWindowManager *wm= CTX_wm_manager(C); + wmWindowManager *wm = CTX_wm_manager(C); /* create standard key configs */ if (!wm->defaultconf) - wm->defaultconf= WM_keyconfig_new(wm, "Blender"); + wm->defaultconf = WM_keyconfig_new(wm, "Blender"); if (!wm->addonconf) - wm->addonconf= WM_keyconfig_new(wm, "Blender Addon"); + wm->addonconf = WM_keyconfig_new(wm, "Blender Addon"); if (!wm->userconf) - wm->userconf= WM_keyconfig_new(wm, "Blender User"); + wm->userconf = WM_keyconfig_new(wm, "Blender User"); /* initialize only after python init is done, for keymaps that * use python operators */ @@ -237,15 +237,15 @@ void WM_keymap_init(bContext *C) void WM_check(bContext *C) { - wmWindowManager *wm= CTX_wm_manager(C); + wmWindowManager *wm = CTX_wm_manager(C); /* wm context */ - if (wm==NULL) { - wm= CTX_data_main(C)->wm.first; + 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 */ @@ -268,18 +268,18 @@ void WM_check(bContext *C) void wm_clear_default_size(bContext *C) { - wmWindowManager *wm= CTX_wm_manager(C); + wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win; /* wm context */ - if (wm==NULL) { - wm= CTX_data_main(C)->wm.first; + 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; @@ -291,18 +291,18 @@ void wm_clear_default_size(bContext *C) /* on startup, it adds all data, for matching */ void wm_add_default(bContext *C) { - wmWindowManager *wm= alloc_libblock(&CTX_data_main(C)->wm, ID_WM, "WinMan"); + wmWindowManager *wm = alloc_libblock(&CTX_data_main(C)->wm, ID_WM, "WinMan"); wmWindow *win; - bScreen *screen= CTX_wm_screen(C); /* XXX from file read hrmf */ + bScreen *screen = CTX_wm_screen(C); /* XXX from file read hrmf */ CTX_wm_manager_set(C, wm); - win= wm_window_new(C); - win->screen= screen; - screen->winid= win->winid; - BLI_strncpy(win->screenname, screen->id.name+2, sizeof(win->screenname)); + win = wm_window_new(C); + win->screen = screen; + screen->winid = win->winid; + BLI_strncpy(win->screenname, screen->id.name + 2, sizeof(win->screenname)); - wm->winactive= win; - wm->file_saved= 1; + wm->winactive = win; + wm->file_saved = 1; wm_window_make_drawable(C, win); } @@ -317,19 +317,19 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm) 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 */ + 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); diff --git a/source/blender/windowmanager/intern/wm_apple.c b/source/blender/windowmanager/intern/wm_apple.c index a79d20ff8b6..161725386c5 100644 --- a/source/blender/windowmanager/intern/wm_apple.c +++ b/source/blender/windowmanager/intern/wm_apple.c @@ -62,23 +62,23 @@ static int checkAppleVideoCard(void) long value; long maxvram = 0; /* we get always more than 1 renderer, check one, at least, has 8 Mo */ - display_mask = CGDisplayIDToOpenGLDisplayMask (CGMainDisplayID() ); + display_mask = CGDisplayIDToOpenGLDisplayMask(CGMainDisplayID() ); - theErr = CGLQueryRendererInfo( display_mask, &rend, &nrend); + theErr = CGLQueryRendererInfo(display_mask, &rend, &nrend); if (theErr == 0) { - theErr = CGLDescribeRenderer (rend, 0, kCGLRPRendererCount, &nrend); + theErr = CGLDescribeRenderer(rend, 0, kCGLRPRendererCount, &nrend); if (theErr == 0) { for (j = 0; j < nrend; j++) { - theErr = CGLDescribeRenderer (rend, j, kCGLRPVideoMemory, &value); + theErr = CGLDescribeRenderer(rend, j, kCGLRPVideoMemory, &value); if (value > maxvram) maxvram = value; if ((theErr == 0) && (value >= 20000000)) { - theErr = CGLDescribeRenderer (rend, j, kCGLRPAccelerated, &value); + theErr = CGLDescribeRenderer(rend, j, kCGLRPAccelerated, &value); if ((theErr == 0) && (value != 0)) { - theErr = CGLDescribeRenderer (rend, j, kCGLRPCompliant, &value); + theErr = CGLDescribeRenderer(rend, j, kCGLRPCompliant, &value); if ((theErr == 0) && (value != 0)) { /*fprintf(stderr,"make it big\n");*/ - CGLDestroyRendererInfo (rend); + CGLDestroyRendererInfo(rend); macPrefState = 8; return 1; } @@ -87,18 +87,18 @@ static int checkAppleVideoCard(void) } } } - if (maxvram < 7500000 ) { /* put a standard alert and quit*/ + if (maxvram < 7500000) { /* put a standard alert and quit*/ SInt16 junkHit; - char inError[] = "* Not enough VRAM "; - char inText[] = "* blender needs at least 8Mb "; + char inError[] = "* Not enough VRAM "; + char inText[] = "* blender needs at least 8Mb "; inError[0] = 16; inText[0] = 28; fprintf(stderr, " vram is %li . not enough, aborting\n", maxvram); - StandardAlert ( kAlertStopAlert, (ConstStr255Param) &inError, (ConstStr255Param)&inText,NULL,&junkHit); + StandardAlert(kAlertStopAlert, (ConstStr255Param) & inError, (ConstStr255Param) & inText, NULL, &junkHit); abort(); } - CGLDestroyRendererInfo (rend); + CGLDestroyRendererInfo(rend); return 0; } @@ -106,7 +106,7 @@ static void getMacAvailableBounds(short *top, short *left, short *bottom, short { Rect outAvailableRect; - GetAvailableWindowPositioningBounds ( GetMainDevice(), &outAvailableRect); + GetAvailableWindowPositioningBounds(GetMainDevice(), &outAvailableRect); *top = outAvailableRect.top; *left = outAvailableRect.left; @@ -124,14 +124,14 @@ void wm_set_apple_prefsize(int scr_x, int scr_y) short top, left, bottom, right; getMacAvailableBounds(&top, &left, &bottom, &right); - WM_setprefsize(left +10,scr_y - bottom +10,right-left -20,bottom - 64); - G.windowstate= 0; + WM_setprefsize(left + 10, scr_y - bottom + 10, right - left - 20, bottom - 64); + G.windowstate = 0; } else { /* 40 + 684 + (headers) 22 + 22 = 768, the powerbook screen height */ WM_setprefsize(120, 40, 850, 684); - G.windowstate= 0; + G.windowstate = 0; } } diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index 2f0a118b54a..80a25913481 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -55,27 +55,27 @@ /* Some simple ghost <-> blender conversions */ static GHOST_TStandardCursor convert_cursor(int curs) { - switch(curs) { + switch (curs) { default: - case CURSOR_STD: return GHOST_kStandardCursorDefault; - case CURSOR_FACESEL: return GHOST_kStandardCursorRightArrow; - case CURSOR_WAIT: return GHOST_kStandardCursorWait; - case CURSOR_EDIT: return GHOST_kStandardCursorCrosshair; + case CURSOR_STD: return GHOST_kStandardCursorDefault; + case CURSOR_FACESEL: return GHOST_kStandardCursorRightArrow; + case CURSOR_WAIT: return GHOST_kStandardCursorWait; + case CURSOR_EDIT: return GHOST_kStandardCursorCrosshair; case CURSOR_HELP: #ifdef __APPLE__ return GHOST_kStandardCursorLeftRight; #else return GHOST_kStandardCursorHelp; #endif - case CURSOR_X_MOVE: return GHOST_kStandardCursorLeftRight; - case CURSOR_Y_MOVE: return GHOST_kStandardCursorUpDown; - case CURSOR_PENCIL: return GHOST_kStandardCursorPencil; - case CURSOR_COPY: return GHOST_kStandardCursorCopy; + case CURSOR_X_MOVE: return GHOST_kStandardCursorLeftRight; + case CURSOR_Y_MOVE: return GHOST_kStandardCursorUpDown; + case CURSOR_PENCIL: return GHOST_kStandardCursorPencil; + case CURSOR_COPY: return GHOST_kStandardCursorCopy; } } static void window_set_custom_cursor(wmWindow *win, unsigned char mask[16][2], - unsigned char bitmap[16][2], int hotx, int hoty) + unsigned char bitmap[16][2], int hotx, int hoty) { GHOST_SetCustomCursorShape(win->ghostwin, bitmap, mask, hotx, hoty); } @@ -84,17 +84,17 @@ static void window_set_custom_cursor_ex(wmWindow *win, BCursor *cursor, int useB { if (useBig) { GHOST_SetCustomCursorShapeEx(win->ghostwin, - (GHOST_TUns8 *)cursor->big_bm, (GHOST_TUns8 *)cursor->big_mask, - cursor->big_sizex,cursor->big_sizey, - cursor->big_hotx,cursor->big_hoty, - cursor->fg_color, cursor->bg_color); + (GHOST_TUns8 *)cursor->big_bm, (GHOST_TUns8 *)cursor->big_mask, + cursor->big_sizex, cursor->big_sizey, + cursor->big_hotx, cursor->big_hoty, + cursor->fg_color, cursor->bg_color); } else { GHOST_SetCustomCursorShapeEx(win->ghostwin, - (GHOST_TUns8 *)cursor->small_bm, (GHOST_TUns8 *)cursor->small_mask, - cursor->small_sizex,cursor->small_sizey, - cursor->small_hotx,cursor->small_hoty, - cursor->fg_color, cursor->bg_color); + (GHOST_TUns8 *)cursor->small_bm, (GHOST_TUns8 *)cursor->small_mask, + cursor->small_sizex, cursor->small_sizey, + cursor->small_hotx, cursor->small_hoty, + cursor->fg_color, cursor->bg_color); } } @@ -105,9 +105,9 @@ static BCursor *BlenderCursor[BC_NUMCURSORS]; /*Points to static BCursor Structs void WM_cursor_set(wmWindow *win, int curs) { - if (win==NULL) return; /* Can't set custom cursor before Window init */ + if (win == NULL) return; /* Can't set custom cursor before Window init */ - if (curs==CURSOR_NONE) { + if (curs == CURSOR_NONE) { GHOST_SetCursorVisibility(win->ghostwin, 0); return; } @@ -115,28 +115,28 @@ 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) - curs= BC_CROSSCURSOR; + if (curs == CURSOR_EDIT) + curs = BC_CROSSCURSOR; #endif GHOST_SetCursorVisibility(win->ghostwin, 1); if (curs == CURSOR_STD && win->modalcursor) - curs= win->modalcursor; + curs = win->modalcursor; - win->cursor= curs; + 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 { - if ((curs<SYSCURSOR) || (curs>=BC_NUMCURSORS)) return; + if ((curs < SYSCURSOR) || (curs >= BC_NUMCURSORS)) return; - if (curs==SYSCURSOR) { /* System default Cursor */ + if (curs == SYSCURSOR) { /* System default Cursor */ GHOST_SetCursorShape(win->ghostwin, convert_cursor(CURSOR_STD)); } - else if ( (U.curssize==0) || (BlenderCursor[curs]->big_bm == NULL) ) { + else if ( (U.curssize == 0) || (BlenderCursor[curs]->big_bm == NULL) ) { window_set_custom_cursor_ex(win, BlenderCursor[curs], 0); } else { @@ -165,10 +165,10 @@ void WM_cursor_restore(wmWindow *win) void WM_cursor_wait(int val) { if (!G.background) { - wmWindowManager *wm= G.main->wm.first; - wmWindow *win= wm?wm->windows.first:NULL; + wmWindowManager *wm = G.main->wm.first; + wmWindow *win = wm ? wm->windows.first : NULL; - for (; win; win= win->next) { + for (; win; win = win->next) { if (val) { WM_cursor_modal(win, BC_WAITCURSOR); } @@ -186,11 +186,11 @@ 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); + const GHOST_TabletData *tabletdata = GHOST_GetTabletData(win->ghostwin); // Note: There is no tabletdata on Windows if no tablet device is connected. if (!tabletdata) GHOST_SetCursorGrab(win->ghostwin, mode, bounds); @@ -215,22 +215,22 @@ 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) { - WM_cursor_warp(win, event->x, event->y+1); + if (event->type == UPARROWKEY) { + WM_cursor_warp(win, event->x, event->y + 1); return 1; } - else if (event->type==DOWNARROWKEY) { - WM_cursor_warp(win, event->x, event->y-1); + else if (event->type == DOWNARROWKEY) { + WM_cursor_warp(win, event->x, event->y - 1); return 1; } - else if (event->type==LEFTARROWKEY) { - WM_cursor_warp(win, event->x-1, event->y); + else if (event->type == LEFTARROWKEY) { + WM_cursor_warp(win, event->x - 1, event->y); return 1; } - else if (event->type==RIGHTARROWKEY) { - WM_cursor_warp(win, event->x+1, event->y); + else if (event->type == RIGHTARROWKEY) { + WM_cursor_warp(win, event->x + 1, event->y); return 1; } } @@ -242,36 +242,36 @@ int wm_cursor_arrow_move(wmWindow *win, wmEvent *event) void WM_timecursor(wmWindow *win, int nr) { /* 10 8x8 digits */ - static char number_bitmaps[10][8]= { - {0, 56, 68, 68, 68, 68, 68, 56}, - {0, 24, 16, 16, 16, 16, 16, 56}, - {0, 60, 66, 32, 16, 8, 4, 126}, - {0, 124, 32, 16, 56, 64, 66, 60}, - {0, 32, 48, 40, 36, 126, 32, 32}, - {0, 124, 4, 60, 64, 64, 68, 56}, - {0, 56, 4, 4, 60, 68, 68, 56}, - {0, 124, 64, 32, 16, 8, 8, 8}, - {0, 60, 66, 66, 60, 66, 66, 60}, - {0, 56, 68, 68, 120, 64, 68, 56} + static char number_bitmaps[10][8] = { + {0, 56, 68, 68, 68, 68, 68, 56}, + {0, 24, 16, 16, 16, 16, 16, 56}, + {0, 60, 66, 32, 16, 8, 4, 126}, + {0, 124, 32, 16, 56, 64, 66, 60}, + {0, 32, 48, 40, 36, 126, 32, 32}, + {0, 124, 4, 60, 64, 64, 68, 56}, + {0, 56, 4, 4, 60, 68, 68, 56}, + {0, 124, 64, 32, 16, 8, 8, 8}, + {0, 60, 66, 66, 60, 66, 66, 60}, + {0, 56, 68, 68, 120, 64, 68, 56} }; unsigned char mask[16][2]; - unsigned char bitmap[16][2]= {{0}}; + unsigned char bitmap[16][2] = {{0}}; int i, idx; if (win->lastcursor == 0) - win->lastcursor= win->cursor; + win->lastcursor = win->cursor; memset(&mask, 0xFF, sizeof(mask)); /* print number bottom right justified */ - for (idx= 3; nr && idx>=0; idx--) { - char *digit= number_bitmaps[nr%10]; - int x = idx%2; - int y = idx/2; - - for (i=0; i<8; i++) - bitmap[i + y*8][x]= digit[i]; - nr/= 10; + for (idx = 3; nr && idx >= 0; idx--) { + char *digit = number_bitmaps[nr % 10]; + int x = idx % 2; + int y = idx / 2; + + for (i = 0; i < 8; i++) + bitmap[i + y * 8][x] = digit[i]; + nr /= 10; } window_set_custom_cursor(win, mask, bitmap, 7, 7); @@ -324,78 +324,78 @@ void wm_init_cursor_data(void) { /********************** NW_ARROW Cursor **************************/ BEGIN_CURSOR_BLOCK - static char nw_sbm[]={ - 0x03, 0x00, 0x05, 0x00, 0x09, 0x00, 0x11, 0x00, - 0x21, 0x00, 0x41, 0x00, 0x81, 0x00, 0x01, 0x01, - 0x01, 0x02, 0xc1, 0x03, 0x49, 0x00, 0x8d, 0x00, - 0x8b, 0x00, 0x10, 0x01, 0x90, 0x01, 0x60, 0x00, - }; - - static char nw_smsk[]={ - 0x03, 0x00, 0x07, 0x00, 0x0f, 0x00, 0x1f, 0x00, - 0x3f, 0x00, 0x7f, 0x00, 0xff, 0x00, 0xff, 0x01, - 0xff, 0x03, 0xff, 0x03, 0x7f, 0x00, 0xff, 0x00, - 0xfb, 0x00, 0xf0, 0x01, 0xf0, 0x01, 0x60, 0x00, - }; - - static BCursor NWArrowCursor = { - /*small*/ - nw_sbm, nw_smsk, - 16, 16, - 6, 7, - /*big*/ - NULL, NULL, - 32,32, - 15, 15, - /*color*/ - BC_BLACK, BC_WHITE - }; - - BlenderCursor[BC_NW_ARROWCURSOR]=&NWArrowCursor; + static char nw_sbm[] = { + 0x03, 0x00, 0x05, 0x00, 0x09, 0x00, 0x11, 0x00, + 0x21, 0x00, 0x41, 0x00, 0x81, 0x00, 0x01, 0x01, + 0x01, 0x02, 0xc1, 0x03, 0x49, 0x00, 0x8d, 0x00, + 0x8b, 0x00, 0x10, 0x01, 0x90, 0x01, 0x60, 0x00, + }; + + static char nw_smsk[] = { + 0x03, 0x00, 0x07, 0x00, 0x0f, 0x00, 0x1f, 0x00, + 0x3f, 0x00, 0x7f, 0x00, 0xff, 0x00, 0xff, 0x01, + 0xff, 0x03, 0xff, 0x03, 0x7f, 0x00, 0xff, 0x00, + 0xfb, 0x00, 0xf0, 0x01, 0xf0, 0x01, 0x60, 0x00, + }; + + static BCursor NWArrowCursor = { + /*small*/ + nw_sbm, nw_smsk, + 16, 16, + 6, 7, + /*big*/ + NULL, NULL, + 32, 32, + 15, 15, + /*color*/ + BC_BLACK, BC_WHITE + }; + + BlenderCursor[BC_NW_ARROWCURSOR] = &NWArrowCursor; END_CURSOR_BLOCK ///********************** NS_ARROW Cursor *************************/ BEGIN_CURSOR_BLOCK - static char ns_sbm[]={ - 0x40, 0x01, 0x20, 0x02, 0x10, 0x04, 0x08, 0x08, - 0x04, 0x10, 0x3c, 0x1e, 0x20, 0x02, 0x20, 0x02, - 0x20, 0x02, 0x20, 0x02, 0x3c, 0x1e, 0x04, 0x10, - 0x08, 0x08, 0x10, 0x04, 0x20, 0x02, 0x40, 0x01 - }; - - static char ns_smsk[]={ - 0xc0, 0x01, 0xe0, 0x03, 0xf0, 0x07, 0xf8, 0x0f, - 0xfc, 0x1f, 0xfc, 0x1f, 0xe0, 0x03, 0xe0, 0x03, - 0xe0, 0x03, 0xe0, 0x03, 0xfc, 0x1f, 0xfc, 0x1f, - 0xf8, 0x0f, 0xf0, 0x07, 0xe0, 0x03, 0xc0, 0x01 - }; - - static BCursor NSArrowCursor = { - /*small*/ - ns_sbm, ns_smsk, - 16, 16, - 6, 7, - /*big*/ - NULL, NULL, - 32,32, - 15, 15, - /*color*/ - BC_BLACK, BC_WHITE - }; - - BlenderCursor[BC_NS_ARROWCURSOR]=&NSArrowCursor; + static char ns_sbm[] = { + 0x40, 0x01, 0x20, 0x02, 0x10, 0x04, 0x08, 0x08, + 0x04, 0x10, 0x3c, 0x1e, 0x20, 0x02, 0x20, 0x02, + 0x20, 0x02, 0x20, 0x02, 0x3c, 0x1e, 0x04, 0x10, + 0x08, 0x08, 0x10, 0x04, 0x20, 0x02, 0x40, 0x01 + }; + + static char ns_smsk[] = { + 0xc0, 0x01, 0xe0, 0x03, 0xf0, 0x07, 0xf8, 0x0f, + 0xfc, 0x1f, 0xfc, 0x1f, 0xe0, 0x03, 0xe0, 0x03, + 0xe0, 0x03, 0xe0, 0x03, 0xfc, 0x1f, 0xfc, 0x1f, + 0xf8, 0x0f, 0xf0, 0x07, 0xe0, 0x03, 0xc0, 0x01 + }; + + static BCursor NSArrowCursor = { + /*small*/ + ns_sbm, ns_smsk, + 16, 16, + 6, 7, + /*big*/ + NULL, NULL, + 32, 32, + 15, 15, + /*color*/ + BC_BLACK, BC_WHITE + }; + + BlenderCursor[BC_NS_ARROWCURSOR] = &NSArrowCursor; END_CURSOR_BLOCK /********************** EW_ARROW Cursor *************************/ BEGIN_CURSOR_BLOCK - static char ew_sbm[]={ + static char ew_sbm[] = { 0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0x38, 0x1c, 0x2c, 0x34, 0xe6, 0x67, 0x03, 0xc0, 0x01, 0x80, 0x03, 0xc0, 0xe6, 0x67, 0x2c, 0x34, 0x38, 0x1c, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; - static char ew_smsk[]={ + static char ew_smsk[] = { 0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0x38, 0x1c, 0x3c, 0x3c, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0x3c, 0x3c, 0x38, 0x1c, @@ -409,32 +409,32 @@ BEGIN_CURSOR_BLOCK 7, 6, /*big*/ NULL, NULL, - 32,32, + 32, 32, 15, 15, /*color*/ BC_BLACK, BC_WHITE }; - BlenderCursor[BC_EW_ARROWCURSOR]=&EWArrowCursor; + BlenderCursor[BC_EW_ARROWCURSOR] = &EWArrowCursor; END_CURSOR_BLOCK /********************** Wait Cursor *****************************/ BEGIN_CURSOR_BLOCK - static char wait_sbm[]={ + static char wait_sbm[] = { 0xfe, 0x7f, 0x02, 0x40, 0x02, 0x40, 0x84, 0x21, 0xc8, 0x13, 0xd0, 0x0b, 0xa0, 0x04, 0x20, 0x05, 0xa0, 0x04, 0x10, 0x09, 0x88, 0x11, 0xc4, 0x23, 0xe2, 0x47, 0xfa, 0x5f, 0x02, 0x40, 0xfe, 0x7f, }; - static char wait_smsk[]={ + static char wait_smsk[] = { 0xfe, 0x7f, 0xfe, 0x7f, 0x06, 0x60, 0x8c, 0x31, 0xd8, 0x1b, 0xf0, 0x0f, 0xe0, 0x06, 0x60, 0x07, 0xe0, 0x06, 0x30, 0x0d, 0x98, 0x19, 0xcc, 0x33, 0xe6, 0x67, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, }; - static char wait_lbm[]={ + static char wait_lbm[] = { 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0x0c, 0x00, 0x00, 0x30, 0x0c, 0x00, 0x00, 0x30, 0x0c, 0x00, 0x00, 0x30, 0x0c, 0x00, 0x00, 0x18, @@ -453,7 +453,7 @@ BEGIN_CURSOR_BLOCK 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, }; - static char wait_lmsk[]={ + static char wait_lmsk[] = { 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0x3c, 0x00, 0x00, 0x3c, 0x3c, 0x00, 0x00, 0x1e, @@ -474,36 +474,36 @@ BEGIN_CURSOR_BLOCK static BCursor WaitCursor = { /*small*/ - wait_sbm, wait_smsk, + wait_sbm, wait_smsk, 16, 16, 7, 7, /*big*/ wait_lbm, wait_lmsk, - 32,32, + 32, 32, 15, 15, /*color*/ BC_BLACK, BC_WHITE }; - BlenderCursor[BC_WAITCURSOR]=&WaitCursor; + BlenderCursor[BC_WAITCURSOR] = &WaitCursor; END_CURSOR_BLOCK /********************** Cross Cursor ***************************/ BEGIN_CURSOR_BLOCK - static char cross_sbm[]={ + static char cross_sbm[] = { 0x00, 0x00, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x7e, 0x7e, 0x7e, 0x7e, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x00, 0x00, }; - static char cross_smsk[]={ + static char cross_smsk[] = { 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xc0, 0x03, 0x7f, 0xfe, 0x7f, 0xfe, 0xc0, 0x03, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, }; - static char cross_lbm[]={ + static char cross_lbm[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, @@ -522,7 +522,7 @@ BEGIN_CURSOR_BLOCK 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; - static char cross_lmsk[]={ + static char cross_lmsk[] = { 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, @@ -548,25 +548,25 @@ BEGIN_CURSOR_BLOCK 7, 7, /*big*/ cross_lbm, cross_lmsk, - 32,32, + 32, 32, 15, 15, /*color*/ BC_BLACK, BC_WHITE }; - BlenderCursor[BC_CROSSCURSOR]=&CrossCursor; + BlenderCursor[BC_CROSSCURSOR] = &CrossCursor; END_CURSOR_BLOCK /********************** EditCross Cursor ***********************/ BEGIN_CURSOR_BLOCK - static char editcross_sbm[]={ + static char editcross_sbm[] = { 0x0e, 0x00, 0x11, 0x00, 0x1d, 0x00, 0x19, 0x03, 0x1d, 0x03, 0x11, 0x03, 0x0e, 0x03, 0x00, 0x03, 0xf8, 0x7c, 0xf8, 0x7c, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, }; - static char editcross_smsk[]={ + static char editcross_smsk[] = { 0x0e, 0x00, 0x1f, 0x00, 0x1f, 0x03, 0x1f, 0x03, 0x1f, 0x03, 0x1f, 0x03, 0x0e, 0x03, 0x80, 0x07, 0xfc, 0xfc, 0xfc, 0xfc, 0x80, 0x07, 0x00, 0x03, @@ -580,26 +580,26 @@ BEGIN_CURSOR_BLOCK 9, 8, /*big*/ NULL, NULL, - 32,32, + 32, 32, 15, 15, /*color*/ BC_BLACK, BC_WHITE }; - BlenderCursor[BC_EDITCROSSCURSOR]=&EditCrossCursor; + BlenderCursor[BC_EDITCROSSCURSOR] = &EditCrossCursor; END_CURSOR_BLOCK /********************** Box Select *************************/ BEGIN_CURSOR_BLOCK - static char box_sbm[32]={ - 0x7f, 0x00, 0x41, 0x00, 0x41, 0x00, 0x41, 0x06, + static char box_sbm[32] = { + 0x7f, 0x00, 0x41, 0x00, 0x41, 0x00, 0x41, 0x06, 0x41, 0x06, 0x41, 0x06, 0x7f, 0x06, 0x00, 0x06, 0xe0, 0x79, 0xe0, 0x79, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, }; - static char box_smsk[32]={ - 0x7f, 0x00, 0x7f, 0x00, 0x63, 0x06, 0x63, 0x06, + static char box_smsk[32] = { + 0x7f, 0x00, 0x7f, 0x00, 0x63, 0x06, 0x63, 0x06, 0x63, 0x06, 0x7f, 0x06, 0x7f, 0x06, 0x00, 0x0f, 0xf0, 0xf9, 0xf0, 0xf9, 0x00, 0x0f, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, @@ -613,32 +613,32 @@ BEGIN_CURSOR_BLOCK 9, 8, /*big*/ NULL, NULL, - 32,32, + 32, 32, 15, 15, /*color*/ BC_BLACK, BC_WHITE }; - BlenderCursor[BC_BOXSELCURSOR]=&BoxSelCursor; + BlenderCursor[BC_BOXSELCURSOR] = &BoxSelCursor; END_CURSOR_BLOCK /********************** Knife Cursor ***********************/ BEGIN_CURSOR_BLOCK - static char knife_sbm[]={ + static char knife_sbm[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x2c, 0x00, 0x5a, 0x00, 0x34, 0x00, 0x2a, 0x00, 0x17, 0x80, 0x06, 0x40, 0x03, 0xa0, 0x03, 0xd0, 0x01, 0x68, 0x00, 0x1c, 0x00, 0x06, 0x00, 0x00, 0x00 }; - static char knife_smsk[]={ + static char knife_smsk[] = { 0x00, 0x60, 0x00, 0xf0, 0x00, 0xfc, 0x00, 0xfe, 0x00, 0xfe, 0x00, 0x7e, 0x00, 0x7f, 0x80, 0x3f, 0xc0, 0x0e, 0x60, 0x07, 0xb0, 0x07, 0xd8, 0x03, 0xec, 0x01, 0x7e, 0x00, 0x1f, 0x00, 0x07, 0x00 }; - static char knife_lbm[]={ + static char knife_lbm[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x1c, @@ -658,7 +658,7 @@ BEGIN_CURSOR_BLOCK }; - static char knife_lmsk[]={ + static char knife_lmsk[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x7e, @@ -680,41 +680,41 @@ BEGIN_CURSOR_BLOCK static BCursor KnifeCursor = { /*small*/ - knife_sbm, knife_smsk, + knife_sbm, knife_smsk, 16, 16, 0, 15, /*big*/ knife_lbm, knife_lmsk, - 32,32, + 32, 32, 0, 31, /*color*/ BC_BLACK, BC_WHITE }; - BlenderCursor[BC_KNIFECURSOR]=&KnifeCursor; + BlenderCursor[BC_KNIFECURSOR] = &KnifeCursor; END_CURSOR_BLOCK /********************** Loop Select Cursor ***********************/ BEGIN_CURSOR_BLOCK -static char vloop_sbm[]={ + static char vloop_sbm[] = { 0x00, 0x00, 0x7e, 0x00, 0x3e, 0x00, 0x1e, 0x00, 0x0e, 0x00, 0x66, 0x60, 0x62, 0x6f, 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x60, 0x60, 0x60, 0x6f, 0x00, 0x00, -}; + }; -static char vloop_smsk[]={ + static char vloop_smsk[] = { 0xff, 0x01, 0xff, 0x00, 0x7f, 0x00, 0x3f, 0x00, 0xff, 0xf0, 0xff, 0xff, 0xf7, 0xff, 0xf3, 0xf0, 0x61, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0xf0, 0xf0, 0xf0, 0xff, 0xf0, 0xff, 0xf0, 0xf0, -}; + }; -static char vloop_lbm[]={ + static char vloop_lbm[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x3f, 0x00, 0x00, 0xfc, 0x3f, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, @@ -731,9 +731,9 @@ static char vloop_lbm[]={ 0x00, 0x3c, 0x00, 0x3c, 0x00, 0x3c, 0x00, 0x3c, 0x00, 0x3c, 0xff, 0x3c, 0x00, 0x3c, 0xff, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; + }; -static char vloop_lmsk[]={ + static char vloop_lmsk[] = { 0xff, 0xff, 0x03, 0x00, 0xff, 0xff, 0x03, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0x3f, 0x00, 0x00, 0xff, 0x3f, 0x00, 0x00, @@ -750,38 +750,38 @@ static char vloop_lmsk[]={ 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, -}; + }; static BCursor VLoopCursor = { /*small*/ - vloop_sbm, vloop_smsk, + vloop_sbm, vloop_smsk, 16, 16, 0, 0, /*big*/ vloop_lbm, vloop_lmsk, - 32,32, + 32, 32, 0, 0, /*color*/ BC_BLACK, BC_WHITE }; - BlenderCursor[BC_VLOOPCURSOR]=&VLoopCursor; + BlenderCursor[BC_VLOOPCURSOR] = &VLoopCursor; -END_CURSOR_BLOCK +END_CURSOR_BLOCK /********************** TextEdit Cursor ***********************/ BEGIN_CURSOR_BLOCK - static char textedit_sbm[]={ + static char textedit_sbm[] = { 0xe0, 0x03, 0x10, 0x04, 0x60, 0x03, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x60, 0x03, 0x10, 0x04, 0xe0, 0x03, }; - static char textedit_smsk[]={ + static char textedit_smsk[] = { 0xe0, 0x03, 0xf0, 0x07, 0xe0, 0x03, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, @@ -795,19 +795,19 @@ BEGIN_CURSOR_BLOCK 9, 8, /*big*/ NULL, NULL, - 32,32, + 32, 32, 15, 15, /*color*/ BC_BLACK, BC_WHITE }; - BlenderCursor[BC_TEXTEDITCURSOR]=&TextEditCursor; + BlenderCursor[BC_TEXTEDITCURSOR] = &TextEditCursor; END_CURSOR_BLOCK /********************** Paintbrush Cursor ***********************/ BEGIN_CURSOR_BLOCK - static char paintbrush_sbm[]={ + static char paintbrush_sbm[] = { 0x00, 0xe0, 0x00, 0x98, 0x00, 0x44, 0x00, 0x42, 0x00, 0x21, 0x80, 0x20, 0x40, 0x13, 0x40, 0x17, @@ -818,7 +818,7 @@ BEGIN_CURSOR_BLOCK }; - static char paintbrush_smsk[]={ + static char paintbrush_smsk[] = { 0x00, 0xe0, 0x00, 0xf8, 0x00, 0x7c, 0x00, 0x7e, 0x00, 0x3f, 0x80, 0x3f, 0xc0, 0x1f, 0xc0, 0x1f, 0xe0, 0x0f, 0xf8, 0x07, 0xfc, 0x03, 0xfe, 0x01, @@ -834,83 +834,83 @@ BEGIN_CURSOR_BLOCK 0, 15, /*big*/ NULL, NULL, - 32,32, + 32, 32, 15, 15, /*color*/ BC_BLACK, BC_WHITE }; - BlenderCursor[BC_PAINTBRUSHCURSOR]=&PaintBrushCursor; + BlenderCursor[BC_PAINTBRUSHCURSOR] = &PaintBrushCursor; END_CURSOR_BLOCK /********************** Hand Cursor ***********************/ BEGIN_CURSOR_BLOCK -static char hand_sbm[]={ - 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x80, 0x0d, - 0x98, 0x6d, 0x98, 0x6d, 0xb0, 0x6d, 0xb0, 0x6d, - 0xe0, 0x6f, 0xe6, 0x7f, 0xee, 0x7f, 0xfc, 0x3f, - 0xf8, 0x3f, 0xf0, 0x1f, 0xc0, 0x1f, 0xc0, 0x1f, -}; - -static char hand_smsk[]={ - 0x00, 0x00, 0x80, 0x01, 0xc0, 0x0f, 0xd8, 0x7f, - 0xfc, 0xff, 0xfc, 0xff, 0xf8, 0xff, 0xf8, 0xff, - 0xf6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, - 0xfc, 0x7f, 0xf8, 0x3f, 0xf0, 0x3f, 0xe0, 0x3f, -}; - - -static BCursor HandCursor = { - /*small*/ - hand_sbm, hand_smsk, - 16, 16, - 8, 8, - /*big*/ - NULL, NULL, - 32,32, - 15, 15, - /*color*/ - BC_BLACK, BC_WHITE -}; - -BlenderCursor[BC_HANDCURSOR]=&HandCursor; + static char hand_sbm[] = { + 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x80, 0x0d, + 0x98, 0x6d, 0x98, 0x6d, 0xb0, 0x6d, 0xb0, 0x6d, + 0xe0, 0x6f, 0xe6, 0x7f, 0xee, 0x7f, 0xfc, 0x3f, + 0xf8, 0x3f, 0xf0, 0x1f, 0xc0, 0x1f, 0xc0, 0x1f, + }; + + static char hand_smsk[] = { + 0x00, 0x00, 0x80, 0x01, 0xc0, 0x0f, 0xd8, 0x7f, + 0xfc, 0xff, 0xfc, 0xff, 0xf8, 0xff, 0xf8, 0xff, + 0xf6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, + 0xfc, 0x7f, 0xf8, 0x3f, 0xf0, 0x3f, 0xe0, 0x3f, + }; + + + static BCursor HandCursor = { + /*small*/ + hand_sbm, hand_smsk, + 16, 16, + 8, 8, + /*big*/ + NULL, NULL, + 32, 32, + 15, 15, + /*color*/ + BC_BLACK, BC_WHITE + }; + + BlenderCursor[BC_HANDCURSOR] = &HandCursor; END_CURSOR_BLOCK /********************** NSEW Scroll Cursor ***********************/ BEGIN_CURSOR_BLOCK -static char nsewscroll_sbm[]={ - 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xc0, 0x03, - 0x00, 0x00, 0x00, 0x00, 0x0c, 0x30, 0x0e, 0x70, - 0x0e, 0x70, 0x0c, 0x30, 0x00, 0x00, 0x00, 0x00, - 0xc0, 0x03, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00, -}; - -static char nsewscroll_smsk[]={ - 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xe0, 0x07, - 0xc0, 0x03, 0x0c, 0x30, 0x1e, 0x78, 0x1f, 0xf8, - 0x1f, 0xf8, 0x1e, 0x78, 0x0c, 0x30, 0xc0, 0x03, - 0xe0, 0x07, 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, -}; - - -static BCursor NSEWScrollCursor = { - /*small*/ - nsewscroll_sbm, nsewscroll_smsk, - 16, 16, - 8, 8, - /*big*/ - NULL, NULL, - 32,32, - 15, 15, - /*color*/ - BC_BLACK, BC_WHITE -}; - -BlenderCursor[BC_NSEW_SCROLLCURSOR]=&NSEWScrollCursor; + static char nsewscroll_sbm[] = { + 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xc0, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x0c, 0x30, 0x0e, 0x70, + 0x0e, 0x70, 0x0c, 0x30, 0x00, 0x00, 0x00, 0x00, + 0xc0, 0x03, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00, + }; + + static char nsewscroll_smsk[] = { + 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xe0, 0x07, + 0xc0, 0x03, 0x0c, 0x30, 0x1e, 0x78, 0x1f, 0xf8, + 0x1f, 0xf8, 0x1e, 0x78, 0x0c, 0x30, 0xc0, 0x03, + 0xe0, 0x07, 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, + }; + + + static BCursor NSEWScrollCursor = { + /*small*/ + nsewscroll_sbm, nsewscroll_smsk, + 16, 16, + 8, 8, + /*big*/ + NULL, NULL, + 32, 32, + 15, 15, + /*color*/ + BC_BLACK, BC_WHITE + }; + + BlenderCursor[BC_NSEW_SCROLLCURSOR] = &NSEWScrollCursor; END_CURSOR_BLOCK @@ -918,35 +918,35 @@ END_CURSOR_BLOCK /********************** NS Scroll Cursor ***********************/ BEGIN_CURSOR_BLOCK -static char nsscroll_sbm[]={ - 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xc0, 0x03, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xc0, 0x03, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00, -}; - -static char nsscroll_smsk[]={ - 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xe0, 0x07, - 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, - 0xe0, 0x07, 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, -}; - - -static BCursor NSScrollCursor = { - /*small*/ - nsscroll_sbm, nsscroll_smsk, - 16, 16, - 8, 8, - /*big*/ - NULL, NULL, - 32,32, - 15, 15, - /*color*/ - BC_BLACK, BC_WHITE -}; - -BlenderCursor[BC_NS_SCROLLCURSOR]=&NSScrollCursor; + static char nsscroll_sbm[] = { + 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xc0, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xc0, 0x03, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00, + }; + + static char nsscroll_smsk[] = { + 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xe0, 0x07, + 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, + 0xe0, 0x07, 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, + }; + + + static BCursor NSScrollCursor = { + /*small*/ + nsscroll_sbm, nsscroll_smsk, + 16, 16, + 8, 8, + /*big*/ + NULL, NULL, + 32, 32, + 15, 15, + /*color*/ + BC_BLACK, BC_WHITE + }; + + BlenderCursor[BC_NS_SCROLLCURSOR] = &NSScrollCursor; END_CURSOR_BLOCK @@ -954,110 +954,105 @@ END_CURSOR_BLOCK /********************** EW Scroll Cursor ***********************/ BEGIN_CURSOR_BLOCK -static char ewscroll_sbm[]={ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0c, 0x30, 0x0e, 0x70, - 0x0e, 0x70, 0x0c, 0x30, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -static char ewscroll_smsk[]={ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x0c, 0x30, 0x1e, 0x78, 0x1f, 0xf8, - 0x1f, 0xf8, 0x1e, 0x78, 0x0c, 0x30, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - - -static BCursor EWScrollCursor = { - /*small*/ - ewscroll_sbm, ewscroll_smsk, - 16, 16, - 8, 8, - /*big*/ - NULL, NULL, - 32,32, - 15, 15, - /*color*/ - BC_BLACK, BC_WHITE -}; - -BlenderCursor[BC_EW_SCROLLCURSOR]=&EWScrollCursor; + static char ewscroll_sbm[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0c, 0x30, 0x0e, 0x70, + 0x0e, 0x70, 0x0c, 0x30, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + + static char ewscroll_smsk[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0c, 0x30, 0x1e, 0x78, 0x1f, 0xf8, + 0x1f, 0xf8, 0x1e, 0x78, 0x0c, 0x30, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + + + static BCursor EWScrollCursor = { + /*small*/ + ewscroll_sbm, ewscroll_smsk, + 16, 16, + 8, 8, + /*big*/ + NULL, NULL, + 32, 32, + 15, 15, + /*color*/ + BC_BLACK, BC_WHITE + }; + + BlenderCursor[BC_EW_SCROLLCURSOR] = &EWScrollCursor; END_CURSOR_BLOCK /********************** Eyedropper Cursor ***********************/ BEGIN_CURSOR_BLOCK -static char eyedropper_sbm[]={ - 0x00, 0x30, 0x00, 0x48, 0x00, 0x85, 0x80, 0x82, - 0x40, 0x40, 0x80, 0x20, 0x40, 0x11, 0xa0, 0x23, - 0xd0, 0x15, 0xe8, 0x0a, 0x74, 0x01, 0xb4, 0x00, - 0x4a, 0x00, 0x35, 0x00, 0x08, 0x00, 0x04, 0x00, -}; - -static char eyedropper_smsk[]={ - 0x00, 0x30, 0x00, 0x78, 0x00, 0xfd, 0x80, 0xff, - 0xc0, 0x7f, 0x80, 0x3f, 0xc0, 0x1f, 0xe0, 0x3f, - 0xf0, 0x1f, 0xf8, 0x0b, 0xfc, 0x01, 0xfc, 0x00, - 0x7e, 0x00, 0x3f, 0x00, 0x0c, 0x00, 0x04, 0x00, -}; - - -static BCursor EyedropperCursor = { - /*small*/ - eyedropper_sbm, eyedropper_smsk, - 16, 16, - 1, 15, - /*big*/ - NULL, NULL, - 32,32, - 15, 15, - /*color*/ - BC_BLACK, BC_WHITE -}; - -BlenderCursor[BC_EYEDROPPER_CURSOR]=&EyedropperCursor; + static char eyedropper_sbm[] = { + 0x00, 0x30, 0x00, 0x48, 0x00, 0x85, 0x80, 0x82, + 0x40, 0x40, 0x80, 0x20, 0x40, 0x11, 0xa0, 0x23, + 0xd0, 0x15, 0xe8, 0x0a, 0x74, 0x01, 0xb4, 0x00, + 0x4a, 0x00, 0x35, 0x00, 0x08, 0x00, 0x04, 0x00, + }; + + static char eyedropper_smsk[] = { + 0x00, 0x30, 0x00, 0x78, 0x00, 0xfd, 0x80, 0xff, + 0xc0, 0x7f, 0x80, 0x3f, 0xc0, 0x1f, 0xe0, 0x3f, + 0xf0, 0x1f, 0xf8, 0x0b, 0xfc, 0x01, 0xfc, 0x00, + 0x7e, 0x00, 0x3f, 0x00, 0x0c, 0x00, 0x04, 0x00, + }; + + + static BCursor EyedropperCursor = { + /*small*/ + eyedropper_sbm, eyedropper_smsk, + 16, 16, + 1, 15, + /*big*/ + NULL, NULL, + 32, 32, + 15, 15, + /*color*/ + BC_BLACK, BC_WHITE + }; + + BlenderCursor[BC_EYEDROPPER_CURSOR] = &EyedropperCursor; END_CURSOR_BLOCK /********************** Swap Area Cursor ***********************/ BEGIN_CURSOR_BLOCK -static char swap_sbm[]={ - 0xc0, 0xff, 0x40, 0x80, 0x40, 0x80, 0x40, 0x9c, - 0x40, 0x98, 0x40, 0x94, 0x00, 0x82, 0xfe, 0x80, - 0x7e, 0xfd, 0xbe, 0x01, 0xda, 0x01, 0xe2, 0x01, - 0xe2, 0x01, 0xc2, 0x01, 0xfe, 0x01, 0x00, 0x00, -}; - -static char swap_smsk[]={ - 0xc0, 0xff, 0xc0, 0xff, 0xc0, 0xff, 0xc0, 0xff, - 0xc0, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x03, 0xff, 0x03, 0xff, 0x03, - 0xff, 0x03, 0xff, 0x03, 0xff, 0x03, 0xff, 0x03, -}; - -static BCursor SwapCursor = { - /*small*/ - swap_sbm, swap_smsk, - 16, 16, - 8, 8, - /*big*/ - NULL, NULL, - 32,32, - 15, 15, - /*color*/ - BC_YELLOW, BC_BLUE -}; - -BlenderCursor[BC_SWAPAREA_CURSOR]=&SwapCursor; - -END_CURSOR_BLOCK -/********************** Put the cursors in the array ***********************/ - + static char swap_sbm[] = { + 0xc0, 0xff, 0x40, 0x80, 0x40, 0x80, 0x40, 0x9c, + 0x40, 0x98, 0x40, 0x94, 0x00, 0x82, 0xfe, 0x80, + 0x7e, 0xfd, 0xbe, 0x01, 0xda, 0x01, 0xe2, 0x01, + 0xe2, 0x01, 0xc2, 0x01, 0xfe, 0x01, 0x00, 0x00, + }; + static char swap_smsk[] = { + 0xc0, 0xff, 0xc0, 0xff, 0xc0, 0xff, 0xc0, 0xff, + 0xc0, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x03, 0xff, 0x03, 0xff, 0x03, + 0xff, 0x03, 0xff, 0x03, 0xff, 0x03, 0xff, 0x03, + }; -} + static BCursor SwapCursor = { + /*small*/ + swap_sbm, swap_smsk, + 16, 16, + 8, 8, + /*big*/ + NULL, NULL, + 32, 32, + 15, 15, + /*color*/ + BC_YELLOW, BC_BLUE + }; + BlenderCursor[BC_SWAPAREA_CURSOR] = &SwapCursor; +END_CURSOR_BLOCK +/********************** Put the cursors in the array ***********************/ +} diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index d60a97ad9bc..5283bc0a7a5 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -63,7 +63,7 @@ /* ****************************************************** */ -static ListBase dropboxes= {NULL, NULL}; +static ListBase dropboxes = {NULL, NULL}; /* drop box maps are stored global for now */ /* these are part of blender's UI/space specs, and not like keymaps */ @@ -83,15 +83,15 @@ 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"); + dm = MEM_callocN(sizeof(struct wmDropBoxMap), "dropmap list"); BLI_strncpy(dm->idname, idname, KMAP_MAX_NAME); - dm->spaceid= spaceid; - dm->regionid= regionid; + dm->spaceid = spaceid; + dm->regionid = regionid; BLI_addtail(&dropboxes, dm); return &dm->dropboxes; @@ -100,16 +100,16 @@ ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid) wmDropBox *WM_dropbox_add(ListBase *lb, const char *idname, int (*poll)(bContext *, wmDrag *, wmEvent *), - void (*copy)(wmDrag *, wmDropBox *)) + void (*copy)(wmDrag *, wmDropBox *)) { - wmDropBox *drop= MEM_callocN(sizeof(wmDropBox), "wmDropBox"); + wmDropBox *drop = MEM_callocN(sizeof(wmDropBox), "wmDropBox"); - drop->poll= poll; - drop->copy= copy; - drop->ot= WM_operatortype_find(idname, 0); - drop->opcontext= WM_OP_INVOKE_DEFAULT; + drop->poll = poll; + drop->copy = copy; + 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,10 +125,10 @@ 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) { + for (drop = dm->dropboxes.first; drop; drop = drop->next) { if (drop->ptr) { WM_operator_properties_free(drop->ptr); MEM_freeN(drop->ptr); @@ -145,40 +145,40 @@ void wm_dropbox_free(void) /* note that the pointer should be valid allocated and not on stack */ wmDrag *WM_event_start_drag(struct bContext *C, int icon, int type, void *poin, double value) { - wmWindowManager *wm= CTX_wm_manager(C); - wmDrag *drag= MEM_callocN(sizeof(struct wmDrag), "new drag"); + wmWindowManager *wm = CTX_wm_manager(C); + wmDrag *drag = MEM_callocN(sizeof(struct wmDrag), "new drag"); /* keep track of future multitouch drag too, add a mousepointer id or so */ /* if multiple drags are added, they're drawn as list */ BLI_addtail(&wm->drags, drag); - drag->icon= icon; - drag->type= type; - if (type==WM_DRAG_PATH) + drag->icon = icon; + drag->type = type; + if (type == WM_DRAG_PATH) BLI_strncpy(drag->path, poin, FILE_MAX); else - drag->poin= poin; - drag->value= value; + drag->poin = poin; + drag->value = value; return drag; } void WM_event_drag_image(wmDrag *drag, ImBuf *imb, float scale, int sx, int sy) { - drag->imb= imb; - drag->scale= scale; - drag->sx= sx; - drag->sy= sy; + drag->imb = imb; + drag->scale = scale; + drag->sx = sx; + drag->sy = sy; } static const char *dropbox_active(bContext *C, ListBase *handlers, wmDrag *drag, wmEvent *event) { - wmEventHandler *handler= handlers->first; - for (; handler; handler= handler->next) { + wmEventHandler *handler = handlers->first; + for (; handler; handler = handler->next) { if (handler->dropboxes) { - wmDropBox *drop= handler->dropboxes->first; - for (; drop; drop= drop->next) { + wmDropBox *drop = handler->dropboxes->first; + for (; drop; drop = drop->next) { if (drop->poll(C, drag, event)) return drop->ot->name; } @@ -190,18 +190,18 @@ static const char *dropbox_active(bContext *C, ListBase *handlers, wmDrag *drag, /* return active operator name when mouse is in box */ static const char *wm_dropbox_active(bContext *C, wmDrag *drag, wmEvent *event) { - wmWindow *win= CTX_wm_window(C); - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= CTX_wm_region(C); + wmWindow *win = CTX_wm_window(C); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); const char *name; - name= dropbox_active(C, &win->handlers, drag, event); + name = dropbox_active(C, &win->handlers, drag, event); if (name) return name; - name= dropbox_active(C, &sa->handlers, drag, event); + name = dropbox_active(C, &sa->handlers, drag, event); if (name) return name; - name= dropbox_active(C, &ar->handlers, drag, event); + name = dropbox_active(C, &ar->handlers, drag, event); if (name) return name; return NULL; @@ -210,20 +210,20 @@ static const char *wm_dropbox_active(bContext *C, wmDrag *drag, wmEvent *event) static void wm_drop_operator_options(bContext *C, wmDrag *drag, wmEvent *event) { - wmWindow *win= CTX_wm_window(C); + 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; + 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); + const char *opname = wm_dropbox_active(C, drag, event); if (opname) { BLI_strncpy(drag->opname, opname, FILE_MAX); @@ -238,10 +238,10 @@ static void wm_drop_operator_options(bContext *C, wmDrag *drag, wmEvent *event) /* called in inner handler loop, region context */ void wm_drags_check_ops(bContext *C, wmEvent *event) { - wmWindowManager *wm= CTX_wm_manager(C); + 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); } } @@ -250,7 +250,7 @@ void wm_drags_check_ops(bContext *C, wmEvent *event) static void wm_drop_operator_draw(const char *name, int x, int y) { - int width= UI_GetStringWidth(name); + int width = UI_GetStringWidth(name); glColor4ub(0, 0, 0, 50); @@ -258,16 +258,16 @@ static void wm_drop_operator_draw(const char *name, int x, int y) uiRoundBox(x, y, x + width + 8, y + 15, 4); glColor4ub(255, 255, 255, 255); - UI_DrawString(x+4, y+4, name); + UI_DrawString(x + 4, y + 4, name); } static const char *wm_drag_name(wmDrag *drag) { - switch(drag->type) { + switch (drag->type) { case WM_DRAG_ID: { - ID *id= (ID *)drag->poin; - return id->name+2; + ID *id = (ID *)drag->poin; + return id->name + 2; } case WM_DRAG_PATH: return drag->path; @@ -293,12 +293,12 @@ static void drag_rect_minmax(rcti *rect, int x1, int y1, int x2, int y2) /* if rect set, do not draw */ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) { - wmWindowManager *wm= CTX_wm_manager(C); + wmWindowManager *wm = CTX_wm_manager(C); wmDrag *drag; int cursorx, cursory, x, y; - cursorx= win->eventstate->x; - cursory= win->eventstate->y; + cursorx = win->eventstate->x; + cursory = win->eventstate->y; if (rect) { rect->xmin = rect->xmax = cursorx; rect->ymin = rect->ymax = cursory; @@ -306,44 +306,44 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) /* 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) { - x= cursorx - drag->sx/2; - y= cursory - drag->sy/2; + x = cursorx - drag->sx / 2; + y = cursory - drag->sy / 2; if (rect) - drag_rect_minmax(rect, x, y, x+drag->sx, y+drag->sy); + 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 */ + glColor4f(1.0, 1.0, 1.0, 0.65); /* this blends texture */ glaDrawPixelsTexScaled(x, y, drag->imb->x, drag->imb->y, GL_UNSIGNED_BYTE, drag->imb->rect, drag->scale, drag->scale); } } else { - x= cursorx - 8; - y= cursory - 2; + x = cursorx - 8; + y = cursory - 2; /* icons assumed to be 16 pixels */ if (rect) - drag_rect_minmax(rect, x, y, x+16, y+16); + 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) { - x= cursorx - drag->sx/2; - y= cursory - drag->sy/2 - 16; + x = cursorx - drag->sx / 2; + y = cursory - drag->sy / 2 - 16; } else { - x= cursorx + 10; - y= cursory + 1; + x = cursorx + 10; + y = cursory + 1; } if (rect) { - int w= UI_GetStringWidth(wm_drag_name(drag)); - drag_rect_minmax(rect, x, y, x+w, y+16); + int w = UI_GetStringWidth(wm_drag_name(drag)); + drag_rect_minmax(rect, x, y, x + w, y + 16); } else { glColor4ub(255, 255, 255, 255); @@ -353,17 +353,17 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) /* operator name with roundbox */ if (drag->opname[0]) { if (drag->imb) { - x= cursorx - drag->sx/2; - y= cursory + drag->sy/2 + 4; + x = cursorx - drag->sx / 2; + y = cursory + drag->sy / 2 + 4; } else { - x= cursorx - 8; - y= cursory + 16; + x = cursorx - 8; + y = cursory + 16; } if (rect) { - int w= UI_GetStringWidth(wm_drag_name(drag)); - drag_rect_minmax(rect, x, y, x+w, y+16); + int w = UI_GetStringWidth(wm_drag_name(drag)); + drag_rect_minmax(rect, x, y, x + w, y + 16); } else wm_drop_operator_draw(drag->opname, x, y); diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 588839ad18f..66cadf1e76a 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -66,27 +66,27 @@ #include "wm_event_system.h" /* swap */ -#define WIN_NONE_OK 0 +#define WIN_NONE_OK 0 #define WIN_BACK_OK 1 #define WIN_FRONT_OK 2 -#define WIN_BOTH_OK 3 +#define WIN_BOTH_OK 3 /* ******************* drawing, overlays *************** */ static void wm_paintcursor_draw(bContext *C, ARegion *ar) { - wmWindowManager *wm= CTX_wm_manager(C); + wmWindowManager *wm = CTX_wm_manager(C); if (wm->paintcursors.first) { - wmWindow *win= CTX_wm_window(C); - bScreen *screen= win->screen; + 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) { + for (pc = wm->paintcursors.first; pc; pc = pc->next) { if (pc->poll == NULL || pc->poll(C)) { - ARegion *ar_other= CTX_wm_region(C); + ARegion *ar_other = CTX_wm_region(C); if (ELEM(win->grabcursor, GHOST_kGrabWrap, GHOST_kGrabHide)) { int x = 0, y = 0; wm_get_cursor_position(win, &x, &y); @@ -112,13 +112,13 @@ static void wm_paintcursor_draw(bContext *C, ARegion *ar) static void wm_area_mark_invalid_backbuf(ScrArea *sa) { if (sa->spacetype == SPACE_VIEW3D) - ((View3D*)sa->spacedata.first)->flag |= V3D_INVALID_BACKBUF; + ((View3D *)sa->spacedata.first)->flag |= V3D_INVALID_BACKBUF; } static int wm_area_test_invalid_backbuf(ScrArea *sa) { if (sa->spacetype == SPACE_VIEW3D) - return (((View3D*)sa->spacedata.first)->flag & V3D_INVALID_BACKBUF); + return (((View3D *)sa->spacedata.first)->flag & V3D_INVALID_BACKBUF); else return 1; } @@ -127,7 +127,7 @@ static void wm_region_test_render_do_draw(ScrArea *sa, ARegion *ar) { if (sa->spacetype == SPACE_VIEW3D) { RegionView3D *rv3d = ar->regiondata; - RenderEngine *engine = (rv3d)? rv3d->render_engine: NULL; + RenderEngine *engine = (rv3d) ? rv3d->render_engine : NULL; if (engine && (engine->flag & RE_ENGINE_DO_DRAW)) { ar->do_draw = 1; @@ -141,15 +141,15 @@ static void wm_region_test_render_do_draw(ScrArea *sa, ARegion *ar) static void wm_method_draw_full(bContext *C, wmWindow *win) { - bScreen *screen= win->screen; + bScreen *screen = win->screen; ScrArea *sa; 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) { + for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->swinid) { CTX_wm_region_set(C, ar); ED_region_do_draw(C, ar); @@ -167,7 +167,7 @@ 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) { + for (ar = screen->regionbase.first; ar; ar = ar->next) { if (ar->swinid) { CTX_wm_menu_set(C, ar); ED_region_do_draw(C, ar); @@ -191,12 +191,12 @@ 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) { + 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; + ar->do_draw = RGN_DRAW; memset(&ar->drawrct, 0, sizeof(ar->drawrct)); - ar->swap= WIN_NONE_OK; + ar->swap = WIN_NONE_OK; } } } @@ -207,50 +207,50 @@ static void wm_flush_regions_up(bScreen *screen, rcti *dirty) { ARegion *ar; - for (ar= screen->regionbase.first; ar; ar= ar->next) { + for (ar = screen->regionbase.first; ar; ar = ar->next) { if (BLI_isect_rcti(dirty, &ar->winrct, NULL)) { - ar->do_draw= RGN_DRAW; + ar->do_draw = RGN_DRAW; memset(&ar->drawrct, 0, sizeof(ar->drawrct)); - ar->swap= WIN_NONE_OK; + ar->swap = WIN_NONE_OK; } } } static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange) { - wmWindowManager *wm= CTX_wm_manager(C); - bScreen *screen= win->screen; + wmWindowManager *wm = CTX_wm_manager(C); + bScreen *screen = win->screen; ScrArea *sa; ARegion *ar; - static rcti rect= {0, 0, 0, 0}; + 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) + for (sa = screen->areabase.first; sa; sa = sa->next) + for (ar = sa->regionbase.first; ar; ar = ar->next) if (ar->swinid && !wm_area_test_invalid_backbuf(sa)) ED_region_tag_redraw(ar); /* flush overlapping regions */ if (screen->regionbase.first) { /* flush redraws of area regions up to overlapping regions */ - for (sa= screen->areabase.first; sa; sa= sa->next) - for (ar= sa->regionbase.first; ar; ar= ar->next) + 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) + 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) + 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; } @@ -260,10 +260,10 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange) } /* 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) { + for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->swinid) { if (ar->do_draw) { CTX_wm_region_set(C, ar); @@ -273,7 +273,7 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange) CTX_wm_region_set(C, NULL); if (exchange) - ar->swap= WIN_FRONT_OK; + ar->swap = WIN_FRONT_OK; } else if (exchange) { if (ar->swap == WIN_FRONT_OK) { @@ -283,12 +283,12 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange) ED_area_overdraw_flush(sa, ar); CTX_wm_region_set(C, NULL); - ar->swap= WIN_BOTH_OK; + ar->swap = WIN_BOTH_OK; } else if (ar->swap == WIN_BACK_OK) - ar->swap= WIN_FRONT_OK; + ar->swap = WIN_FRONT_OK; else if (ar->swap == WIN_BOTH_OK) - ar->swap= WIN_BOTH_OK; + ar->swap = WIN_BOTH_OK; } } } @@ -302,23 +302,23 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange) ED_screen_draw(win); if (exchange) - screen->swap= WIN_FRONT_OK; + screen->swap = WIN_FRONT_OK; } else if (exchange) { - if (screen->swap==WIN_FRONT_OK) { + if (screen->swap == WIN_FRONT_OK) { ED_screen_draw(win); - screen->swap= WIN_BOTH_OK; + screen->swap = WIN_BOTH_OK; } - else if (screen->swap==WIN_BACK_OK) - screen->swap= WIN_FRONT_OK; - else if (screen->swap==WIN_BOTH_OK) - screen->swap= WIN_BOTH_OK; + else if (screen->swap == WIN_BACK_OK) + screen->swap = WIN_FRONT_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) { + 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); @@ -357,7 +357,7 @@ static void wm_method_draw_damage(bContext *C, wmWindow *win) #define MAX_N_TEX 3 typedef struct wmDrawTriple { - GLuint bind[MAX_N_TEX*MAX_N_TEX]; + GLuint bind[MAX_N_TEX * MAX_N_TEX]; int x[MAX_N_TEX], y[MAX_N_TEX]; int nx, ny; GLenum target; @@ -369,46 +369,46 @@ static void split_width(int x, int n, int *splitx, int *nx) /* if already power of two just use it */ if (is_power_of_2_i(x)) { - splitx[0]= x; + splitx[0] = x; (*nx)++; return; } if (n == 1) { /* last part, we have to go larger */ - splitx[0]= power_of_2_max_i(x); + splitx[0] = power_of_2_max_i(x); (*nx)++; } else { /* two or more parts to go, use smaller part */ - splitx[0]= power_of_2_min_i(x); - newnx= ++(*nx); - split_width(x-splitx[0], n-1, splitx+1, &newnx); + splitx[0] = power_of_2_min_i(x); + newnx = ++(*nx); + split_width(x - splitx[0], n - 1, splitx + 1, &newnx); - for (waste=0, a=0; a<n; a++) + for (waste = 0, a = 0; a < n; a++) waste += splitx[a]; /* if we waste more space or use the same amount, * revert deeper splits and just use larger */ if (waste >= power_of_2_max_i(x)) { - splitx[0]= power_of_2_max_i(x); - memset(splitx+1, 0, sizeof(int)*(n-1)); + splitx[0] = power_of_2_max_i(x); + memset(splitx + 1, 0, sizeof(int) * (n - 1)); } else - *nx= newnx; + *nx = newnx; } } static void wm_draw_triple_free(wmWindow *win) { if (win->drawdata) { - wmDrawTriple *triple= win->drawdata; + wmDrawTriple *triple = win->drawdata; - glDeleteTextures(triple->nx*triple->ny, triple->bind); + glDeleteTextures(triple->nx * triple->ny, triple->bind); MEM_freeN(triple); - win->drawdata= NULL; + win->drawdata = NULL; } } @@ -416,7 +416,7 @@ static void wm_draw_triple_fail(bContext *C, wmWindow *win) { wm_draw_window_clear(win); - win->drawfail= 1; + win->drawfail = 1; wm_method_draw_overlap_all(C, win, 0); } @@ -427,29 +427,29 @@ static int wm_triple_gen_textures(wmWindow *win, wmDrawTriple *triple) /* compute texture sizes */ 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; + 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()) { - triple->target= GL_TEXTURE_2D; - triple->nx= 1; - triple->ny= 1; - triple->x[0]= win->sizex; - triple->y[0]= win->sizey; + triple->target = GL_TEXTURE_2D; + triple->nx = 1; + triple->ny = 1; + triple->x[0] = win->sizex; + triple->y[0] = win->sizey; } else { - triple->target= GL_TEXTURE_2D; - triple->nx= 0; - triple->ny= 0; + triple->target = GL_TEXTURE_2D; + triple->nx = 0; + triple->ny = 0; split_width(win->sizex, MAX_N_TEX, triple->x, &triple->nx); split_width(win->sizey, MAX_N_TEX, triple->y, &triple->ny); } /* generate texture names */ - glGenTextures(triple->nx*triple->ny, triple->bind); + glGenTextures(triple->nx * triple->ny, triple->bind); if (!triple->bind[0]) { /* not the typical failure case but we handle it anyway */ @@ -457,8 +457,8 @@ static int wm_triple_gen_textures(wmWindow *win, wmDrawTriple *triple) return 0; } - for (y=0; y<triple->ny; y++) { - for (x=0; x<triple->nx; x++) { + for (y = 0; y < triple->ny; y++) { + for (x = 0; x < triple->nx; 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); @@ -471,7 +471,7 @@ static int wm_triple_gen_textures(wmWindow *win, wmDrawTriple *triple) } /* setup actual texture */ - glBindTexture(triple->target, triple->bind[x + y*triple->nx]); + glBindTexture(triple->target, triple->bind[x + y * triple->nx]); glTexImage2D(triple->target, 0, GL_RGB8, triple->x[x], triple->y[y], 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); glTexParameteri(triple->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(triple->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -497,16 +497,16 @@ static void wm_triple_draw_textures(wmWindow *win, wmDrawTriple *triple) glEnable(triple->target); - for (y=0, offy=0; y<triple->ny; offy+=triple->y[y], y++) { - for (x=0, offx=0; x<triple->nx; 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]; + for (y = 0, offy = 0; y < triple->ny; offy += triple->y[y], y++) { + for (x = 0, offx = 0; x < triple->nx; 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]; /* wmOrtho for the screen has this same offset */ - ratiox= sizex; - ratioy= sizey; - halfx= 0.375f; - halfy= 0.375f; + ratiox = sizex; + ratioy = sizey; + halfx = 0.375f; + halfy = 0.375f; /* texture rectangle has unnormalized coordinates */ if (triple->target == GL_TEXTURE_2D) { @@ -516,21 +516,21 @@ static void wm_triple_draw_textures(wmWindow *win, wmDrawTriple *triple) halfy /= triple->y[y]; } - glBindTexture(triple->target, triple->bind[x + y*triple->nx]); + glBindTexture(triple->target, triple->bind[x + y * triple->nx]); glColor3f(1.0f, 1.0f, 1.0f); glBegin(GL_QUADS); - glTexCoord2f(halfx, halfy); - glVertex2f(offx, offy); + glTexCoord2f(halfx, halfy); + glVertex2f(offx, offy); - glTexCoord2f(ratiox+halfx, halfy); - glVertex2f(offx+sizex, offy); + glTexCoord2f(ratiox + halfx, halfy); + glVertex2f(offx + sizex, offy); - glTexCoord2f(ratiox+halfx, ratioy+halfy); - glVertex2f(offx+sizex, offy+sizey); + glTexCoord2f(ratiox + halfx, ratioy + halfy); + glVertex2f(offx + sizex, offy + sizey); - glTexCoord2f(halfx, ratioy+halfy); - glVertex2f(offx, offy+sizey); + glTexCoord2f(halfx, ratioy + halfy); + glVertex2f(offx, offy + sizey); glEnd(); } } @@ -543,12 +543,12 @@ static void wm_triple_copy_textures(wmWindow *win, wmDrawTriple *triple) { int x, y, sizex, sizey, offx, offy; - for (y=0, offy=0; y<triple->ny; offy+=triple->y[y], y++) { - for (x=0, offx=0; x<triple->nx; 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]; + for (y = 0, offy = 0; y < triple->ny; offy += triple->y[y], y++) { + for (x = 0, offx = 0; x < triple->nx; 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]; - glBindTexture(triple->target, triple->bind[x + y*triple->nx]); + glBindTexture(triple->target, triple->bind[x + y * triple->nx]); glCopyTexSubImage2D(triple->target, 0, 0, 0, offx, offy, sizex, sizey); } } @@ -558,23 +558,23 @@ static void wm_triple_copy_textures(wmWindow *win, wmDrawTriple *triple) static void wm_method_draw_triple(bContext *C, wmWindow *win) { - wmWindowManager *wm= CTX_wm_manager(C); + wmWindowManager *wm = CTX_wm_manager(C); wmDrawTriple *triple; - bScreen *screen= win->screen; + bScreen *screen = win->screen; ScrArea *sa; ARegion *ar; - int copytex= 0, paintcursor= 1; + int copytex = 0, paintcursor = 1; if (win->drawdata) { glClearColor(0, 0, 0, 0); - glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); wmSubWindowSet(win, screen->mainwin); wm_triple_draw_textures(win, win->drawdata); } else { - win->drawdata= MEM_callocN(sizeof(wmDrawTriple), "wmDrawTriple"); + win->drawdata = MEM_callocN(sizeof(wmDrawTriple), "wmDrawTriple"); if (!wm_triple_gen_textures(win, win->drawdata)) { wm_draw_triple_fail(C, win); @@ -582,19 +582,19 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win) } } - triple= win->drawdata; + 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) { + 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); CTX_wm_region_set(C, NULL); - copytex= 1; + copytex = 1; } } @@ -613,13 +613,13 @@ 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) { + 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); /* when a menu is being drawn, don't do the paint cursors */ - paintcursor= 0; + paintcursor = 0; } } @@ -628,8 +628,8 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win) 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) { + 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); @@ -661,19 +661,19 @@ static int wm_draw_update_test_window(wmWindow *win) { ScrArea *sa; ARegion *ar; - int do_draw= 0; + int do_draw = 0; - for (ar= win->screen->regionbase.first; ar; ar= ar->next) { + 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; + ar->do_draw_overlay = 0; } if (ar->swinid && ar->do_draw) - do_draw= 1; + 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) @@ -737,22 +737,22 @@ void wm_tag_redraw_overlay(wmWindow *win, ARegion *ar) if (ar && win) { if (wm_automatic_draw_method(win) != USER_DRAW_TRIPLE) ED_region_tag_redraw(ar); - win->screen->do_draw_paintcursor= 1; + win->screen->do_draw_paintcursor = 1; } } void wm_draw_update(bContext *C) { - wmWindowManager *wm= CTX_wm_manager(C); + wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win; int drawmethod; GPU_free_unused_buffers(); - for (win= wm->windows.first; win; win= win->next) { + for (win = wm->windows.first; win; win = win->next) { if (win->drawmethod != U.wmdrawmethod) { wm_draw_window_clear(win); - win->drawmethod= U.wmdrawmethod; + win->drawmethod = U.wmdrawmethod; } if (wm_draw_update_test_window(win)) { @@ -765,7 +765,7 @@ void wm_draw_update(bContext *C) if (win->screen->do_refresh) ED_screen_refresh(wm, win); - drawmethod= wm_automatic_draw_method(win); + drawmethod = wm_automatic_draw_method(win); if (win->drawfail) wm_method_draw_overlap_all(C, win, 0); @@ -778,9 +778,9 @@ void wm_draw_update(bContext *C) else // if (drawmethod == USER_DRAW_TRIPLE) wm_method_draw_triple(C, win); - win->screen->do_draw_gesture= 0; - win->screen->do_draw_paintcursor= 0; - win->screen->do_draw_drag= 0; + win->screen->do_draw_gesture = 0; + win->screen->do_draw_paintcursor = 0; + win->screen->do_draw_drag = 0; wm_window_swap_buffers(win); @@ -791,39 +791,39 @@ void wm_draw_update(bContext *C) void wm_draw_window_clear(wmWindow *win) { - bScreen *screen= win->screen; + bScreen *screen = win->screen; ScrArea *sa; ARegion *ar; - int drawmethod= wm_automatic_draw_method(win); + int drawmethod = wm_automatic_draw_method(win); 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) - ar->swap= WIN_NONE_OK; + 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; + screen->swap = WIN_NONE_OK; } } void wm_draw_region_clear(wmWindow *win, ARegion *ar) { - int drawmethod= wm_automatic_draw_method(win); + int drawmethod = wm_automatic_draw_method(win); if (ELEM(drawmethod, USER_DRAW_OVERLAP, USER_DRAW_OVERLAP_FLIP)) wm_flush_regions_down(win->screen, &ar->winrct); - win->screen->do_draw= 1; + win->screen->do_draw = 1; } void WM_redraw_windows(bContext *C) { - wmWindow *win_prev= CTX_wm_window(C); - ScrArea *area_prev= CTX_wm_area(C); - ARegion *ar_prev= CTX_wm_region(C); + wmWindow *win_prev = CTX_wm_window(C); + ScrArea *area_prev = CTX_wm_area(C); + ARegion *ar_prev = CTX_wm_region(C); wm_draw_update(C); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index fb5a531cc38..2327ca46862 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -89,9 +89,9 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA void wm_event_add(wmWindow *win, wmEvent *event_to_add) { - wmEvent *event= MEM_callocN(sizeof(wmEvent), "wmEvent"); + wmEvent *event = MEM_callocN(sizeof(wmEvent), "wmEvent"); - *event= *event_to_add; + *event = *event_to_add; BLI_addtail(&win->queue, event); } @@ -100,7 +100,7 @@ void wm_event_free(wmEvent *event) 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; @@ -135,47 +135,47 @@ static int wm_test_duplicate_notifier(wmWindowManager *wm, unsigned int type, vo /* XXX: in future, which notifiers to send to other windows? */ void WM_event_add_notifier(const bContext *C, unsigned int type, void *reference) { - wmNotifier *note= MEM_callocN(sizeof(wmNotifier), "notifier"); + wmNotifier *note = MEM_callocN(sizeof(wmNotifier), "notifier"); - note->wm= CTX_wm_manager(C); + note->wm = CTX_wm_manager(C); BLI_addtail(¬e->wm->queue, note); - note->window= CTX_wm_window(C); + note->window = CTX_wm_window(C); if (CTX_wm_region(C)) - note->swinid= CTX_wm_region(C)->swinid; + note->swinid = CTX_wm_region(C)->swinid; - note->category= type & NOTE_CATEGORY; - note->data= type & NOTE_DATA; - note->subtype= type & NOTE_SUBTYPE; - note->action= type & NOTE_ACTION; + note->category = type & NOTE_CATEGORY; + note->data = type & NOTE_DATA; + note->subtype = type & NOTE_SUBTYPE; + note->action = type & NOTE_ACTION; - note->reference= reference; + note->reference = reference; } void WM_main_add_notifier(unsigned int type, void *reference) { - Main *bmain= G.main; - wmWindowManager *wm= bmain->wm.first; + Main *bmain = G.main; + wmWindowManager *wm = bmain->wm.first; if (wm && !wm_test_duplicate_notifier(wm, type, reference)) { - wmNotifier *note= MEM_callocN(sizeof(wmNotifier), "notifier"); + wmNotifier *note = MEM_callocN(sizeof(wmNotifier), "notifier"); - note->wm= wm; + note->wm = wm; BLI_addtail(¬e->wm->queue, note); - note->category= type & NOTE_CATEGORY; - note->data= type & NOTE_DATA; - note->subtype= type & NOTE_SUBTYPE; - note->action= type & NOTE_ACTION; + note->category = type & NOTE_CATEGORY; + note->data = type & NOTE_DATA; + note->subtype = type & NOTE_SUBTYPE; + note->action = type & NOTE_ACTION; - note->reference= reference; + note->reference = reference; } } static wmNotifier *wm_notifier_next(wmWindowManager *wm) { - wmNotifier *note= wm->queue.first; + wmNotifier *note = wm->queue.first; if (note) BLI_remlink(&wm->queue, note); return note; @@ -184,40 +184,40 @@ static wmNotifier *wm_notifier_next(wmWindowManager *wm) /* called in mainloop */ void wm_event_do_notifiers(bContext *C) { - wmWindowManager *wm= CTX_wm_manager(C); + wmWindowManager *wm = CTX_wm_manager(C); wmNotifier *note, *next; wmWindow *win; - uint64_t win_combine_v3d_datamask= 0; + 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) { - int do_anim= 0; + 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) { - next= 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)) { - wm->file_saved= 1; + 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) { - ED_screen_set(C, note->reference); // XXX hrms, think this over! + 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) printf("screen set %p\n", note->reference); } - else if (note->data==ND_SCREENDELETE) { - ED_screen_delete(C, note->reference); // XXX hrms, think this over! + else if (note->data == ND_SCREENDELETE) { + ED_screen_delete(C, note->reference); // XXX hrms, think this over! if (G.f & G_DEBUG) printf("screen delete %p\n", note->reference); } @@ -225,16 +225,16 @@ void wm_event_do_notifiers(bContext *C) } if (note->window == win || - (note->window == NULL && (note->reference == NULL || note->reference == CTX_data_scene(C)))) + (note->window == NULL && (note->reference == NULL || note->reference == CTX_data_scene(C)))) { - if (note->category==NC_SCENE) { - if (note->data==ND_FRAME) - do_anim= 1; + 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)) { ED_info_stats_clear(CTX_data_scene(C)); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_INFO, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO, NULL); } } if (do_anim) { @@ -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,16 +284,16 @@ 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) { + 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); @@ -306,7 +306,7 @@ void wm_event_do_notifiers(bContext *C) Main *bmain = CTX_data_main(C); /* copied to set's in scene_update_tagged_recursive() */ - win->screen->scene->customdata_mask= win_combine_v3d_datamask; + win->screen->scene->customdata_mask = win_combine_v3d_datamask; /* XXX, hack so operators can enforce datamasks [#26482], gl render */ win->screen->scene->customdata_mask |= win->screen->scene->customdata_mask_modal; @@ -328,20 +328,20 @@ static int wm_event_always_pass(wmEvent *event) static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, wmEvent *event, int always_pass) { - ScrArea *area= CTX_wm_area(C); - ARegion *region= CTX_wm_region(C); - ARegion *menu= CTX_wm_menu(C); - static int do_wheel_ui= 1; - int is_wheel= ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE); + ScrArea *area = CTX_wm_area(C); + ARegion *region = CTX_wm_region(C); + ARegion *menu = CTX_wm_menu(C); + static int do_wheel_ui = 1; + int is_wheel = ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE); int retval; /* 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 (do_wheel_ui == 0) { if (is_wheel) return WM_HANDLER_CONTINUE; - else if (wm_event_always_pass(event)==0) - do_wheel_ui= 1; + else if (wm_event_always_pass(event) == 0) + do_wheel_ui = 1; } /* we set context to where ui handler came from */ @@ -349,7 +349,7 @@ static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, wmEvent *eve 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); + retval = handler->ui_handle(C, event, handler->ui_userdata); /* putting back screen context */ if ((retval != WM_UI_HANDLER_BREAK) || always_pass) { @@ -369,26 +369,26 @@ static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, wmEvent *eve /* event not handled in UI, if wheel then we temporarily disable it */ if (is_wheel) - do_wheel_ui= 0; + do_wheel_ui = 0; return WM_HANDLER_CONTINUE; } static void wm_handler_ui_cancel(bContext *C) { - wmWindow *win= CTX_wm_window(C); - ARegion *ar= CTX_wm_region(C); + wmWindow *win = CTX_wm_window(C); + ARegion *ar = CTX_wm_region(C); wmEventHandler *handler, *nexthandler; if (!ar) return; - for (handler= ar->handlers.first; handler; handler= nexthandler) { - nexthandler= handler->next; + for (handler = ar->handlers.first; handler; handler = nexthandler) { + nexthandler = handler->next; if (handler->ui_handle) { - wmEvent event= *(win->eventstate); - event.type= EVT_BUT_CANCEL; + wmEvent event = *(win->eventstate); + event.type = EVT_BUT_CANCEL; handler->ui_handle(C, &event, handler->ui_userdata); } } @@ -400,10 +400,10 @@ int WM_operator_poll(bContext *C, wmOperatorType *ot) { wmOperatorTypeMacro *otmacro; - for (otmacro= ot->macro.first; otmacro; otmacro= otmacro->next) { - wmOperatorType *ot_macro= WM_operatortype_find(otmacro->idname, 0); + 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; } @@ -436,9 +436,9 @@ static void wm_operator_print(bContext *C, wmOperator *op) void WM_event_print(wmEvent *event) { if (event) { - const char *unknown= "UNKNOWN"; - const char *type_id= unknown; - const char *val_id= unknown; + const char *unknown = "UNKNOWN"; + const char *type_id = unknown; + const char *val_id = unknown; RNA_enum_identifier(event_type_items, event->type, &type_id); RNA_enum_identifier(event_value_items, event->val, &val_id); @@ -466,11 +466,11 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int cal if (caller_owns_reports == FALSE) { /* popup */ 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); + 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); @@ -505,7 +505,7 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int cal if (op->reports->list.first && (op->reports->flag & RPT_OP_HOLD) == 0) { wmWindowManager *wm = CTX_wm_manager(C); - ReportList *wm_reports= CTX_wm_reports(C); + ReportList *wm_reports = CTX_wm_reports(C); ReportTimerInfo *rti; /* add reports to the global list, otherwise they are not seen */ @@ -515,7 +515,7 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int cal WM_event_remove_timer(wm, NULL, wm_reports->reporttimer); /* Records time since last report was added */ - wm_reports->reporttimer= WM_event_add_timer(wm, CTX_wm_window(C), TIMERREPORT, 0.05); + wm_reports->reporttimer = WM_event_add_timer(wm, CTX_wm_window(C), TIMERREPORT, 0.05); rti = MEM_callocN(sizeof(ReportTimerInfo), "ReportTimerInfo"); wm_reports->reporttimer->customdata = rti; @@ -532,9 +532,9 @@ static int wm_operator_register_check(wmWindowManager *wm, wmOperatorType *ot) static void wm_operator_finished(bContext *C, wmOperator *op, int repeat) { - wmWindowManager *wm= CTX_wm_manager(C); + wmWindowManager *wm = CTX_wm_manager(C); - op->customdata= NULL; + op->customdata = NULL; /* we don't want to do undo pushes for operators that are being * called from operators that already do an undo push. usually @@ -543,7 +543,7 @@ static void wm_operator_finished(bContext *C, wmOperator *op, int repeat) if (op->type->flag & OPTYPE_UNDO) ED_undo_push_op(C, op); - if (repeat==0) { + 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); @@ -560,29 +560,29 @@ static void wm_operator_finished(bContext *C, wmOperator *op, int repeat) /* if repeat is true, it doesn't register again, nor does it free */ static int wm_operator_exec(bContext *C, wmOperator *op, int repeat) { - wmWindowManager *wm= CTX_wm_manager(C); - int retval= OPERATOR_CANCELLED; + wmWindowManager *wm = CTX_wm_manager(C); + int retval = OPERATOR_CANCELLED; 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) wm->op_undo_depth++; - retval= op->type->exec(C, op); + retval = op->type->exec(C, op); OPERATOR_RETVAL_CHECK(retval); if (op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm) wm->op_undo_depth--; } - if (retval & (OPERATOR_FINISHED|OPERATOR_CANCELLED) && repeat == 0) + if (retval & (OPERATOR_FINISHED | OPERATOR_CANCELLED) && repeat == 0) wm_operator_reports(C, op, retval, FALSE); if (retval & OPERATOR_FINISHED) { @@ -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); } @@ -604,12 +604,12 @@ static int wm_operator_exec(bContext *C, wmOperator *op, int repeat) /* simply calls exec with basic checks */ static int wm_operator_exec_notest(bContext *C, wmOperator *op) { - int retval= OPERATOR_CANCELLED; + 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); + retval = op->type->exec(C, op); OPERATOR_RETVAL_CHECK(retval); return retval; @@ -648,40 +648,40 @@ int WM_operator_repeat_check(const bContext *UNUSED(C), wmOperator *op) static wmOperator *wm_operator_create(wmWindowManager *wm, wmOperatorType *ot, PointerRNA *properties, ReportList *reports) { /* XXX operatortype names are static still. for debug */ - wmOperator *op= MEM_callocN(sizeof(wmOperator), ot->idname); + wmOperator *op = MEM_callocN(sizeof(wmOperator), ot->idname); /* XXX adding new operator could be function, only happens here now */ - op->type= ot; + op->type = ot; BLI_strncpy(op->idname, ot->idname, OP_MAX_TYPENAME); /* initialize properties, either copy or create */ - op->ptr= MEM_callocN(sizeof(PointerRNA), "wmOperatorPtrRNA"); + op->ptr = MEM_callocN(sizeof(PointerRNA), "wmOperatorPtrRNA"); if (properties && properties->data) { - op->properties= IDP_CopyProperty(properties->data); + op->properties = IDP_CopyProperty(properties->data); } else { IDPropertyTemplate val = {0}; - op->properties= IDP_New(IDP_GROUP, &val, "wmOperatorProperties"); + op->properties = IDP_New(IDP_GROUP, &val, "wmOperatorProperties"); } RNA_pointer_create(&wm->id, ot->srna, op->properties, op->ptr); /* initialize error reports */ if (reports) { - op->reports= reports; /* must be initialized already */ + op->reports = reports; /* must be initialized already */ } else { - op->reports= MEM_mallocN(sizeof(ReportList), "wmOperatorReportList"); - BKE_reports_init(op->reports, RPT_STORE|RPT_FREE); + op->reports = MEM_mallocN(sizeof(ReportList), "wmOperatorReportList"); + BKE_reports_init(op->reports, RPT_STORE | RPT_FREE); } /* recursive filling of operator macro list */ if (ot->macro.first) { - static wmOperator *motherop= NULL; + 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; } @@ -689,41 +689,42 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, wmOperatorType *ot, P /* if properties exist, it will contain everything needed */ if (properties) { - otmacro= ot->macro.first; + otmacro = ot->macro.first; - RNA_STRUCT_BEGIN(properties, prop) { + RNA_STRUCT_BEGIN(properties, prop) + { if (otmacro == NULL) break; /* skip invalid properties */ if (strcmp(RNA_property_identifier(prop), otmacro->idname) == 0) { - wmOperatorType *otm= WM_operatortype_find(otmacro->idname, 0); + wmOperatorType *otm = WM_operatortype_find(otmacro->idname, 0); PointerRNA someptr = RNA_property_pointer_get(properties, prop); - wmOperator *opm= wm_operator_create(wm, otm, &someptr, NULL); + wmOperator *opm = wm_operator_create(wm, otm, &someptr, NULL); IDP_ReplaceGroupInGroup(opm->properties, otmacro->properties); BLI_addtail(&motherop->macro, opm); - opm->opm= motherop; /* pointer to mom, for modal() */ + opm->opm = motherop; /* pointer to mom, for modal() */ - otmacro= otmacro->next; + otmacro = otmacro->next; } } RNA_STRUCT_END; } 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); + wmOperatorType *otm = WM_operatortype_find(otmacro->idname, 0); + wmOperator *opm = wm_operator_create(wm, otm, otmacro->ptr, NULL); BLI_addtail(&motherop->macro, opm); - opm->opm= motherop; /* pointer to mom, for modal() */ + opm->opm = motherop; /* pointer to mom, for modal() */ } } if (root) - motherop= NULL; + motherop = NULL; } WM_operator_properties_sanitize(op->ptr, 0); @@ -733,22 +734,22 @@ 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); + ARegion *ar = CTX_wm_region(C); if (ar) { /* compatibility convention */ - event->mval[0]= event->x - ar->winrct.xmin; - event->mval[1]= event->y - ar->winrct.ymin; + event->mval[0] = event->x - ar->winrct.xmin; + event->mval[1] = event->y - ar->winrct.ymin; } else { /* these values are invalid (avoid odd behavior by relying on old mval values) */ - event->mval[0]= -1; - event->mval[1]= -1; + event->mval[0] = -1; + event->mval[1] = -1; } } int WM_operator_last_properties_init(wmOperator *op) { - int change= FALSE; + int change = FALSE; if (op->type->last_properties) { PropertyRNA *iterprop; @@ -758,11 +759,11 @@ int WM_operator_last_properties_init(wmOperator *op) iterprop = RNA_struct_iterator_property(op->type->srna); RNA_PROP_BEGIN(op->ptr, itemptr, iterprop) { - PropertyRNA *prop= itemptr.data; + PropertyRNA *prop = itemptr.data; 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); + const char *identifier = RNA_property_identifier(prop); + IDProperty *idp_src = IDP_GetPropertyFromGroup(op->type->last_properties, identifier); if (idp_src) { IDProperty *idp_dst = IDP_CopyProperty(idp_src); @@ -771,7 +772,7 @@ int WM_operator_last_properties_init(wmOperator *op) idp_dst->flag |= IDP_FLAG_GHOST; IDP_ReplaceInGroup(op->properties, idp_dst); - change= TRUE; + change = TRUE; } } } @@ -802,15 +803,15 @@ int WM_operator_last_properties_store(wmOperator *op) static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, PointerRNA *properties, ReportList *reports, short poll_only) { - wmWindowManager *wm= CTX_wm_manager(C); - int retval= OPERATOR_PASS_THROUGH; + wmWindowManager *wm = CTX_wm_manager(C); + 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) return 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 */ + 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 */ @@ -818,8 +819,8 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P WM_operator_last_properties_init(op); } - 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 ((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) { wm_region_mouse_co(C, event); @@ -827,7 +828,7 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P if (op->type->flag & OPTYPE_UNDO) wm->op_undo_depth++; - retval= op->type->invoke(C, op, event); + retval = op->type->invoke(C, op, event); OPERATOR_RETVAL_CHECK(retval); if (op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm) @@ -837,7 +838,7 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P if (op->type->flag & OPTYPE_UNDO) wm->op_undo_depth++; - retval= op->type->exec(C, op); + retval = op->type->exec(C, op); OPERATOR_RETVAL_CHECK(retval); if (op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm) @@ -850,13 +851,13 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P /* Note, if the report is given as an argument then assume the caller will deal with displaying them * currently python only uses this */ - if (!(retval & OPERATOR_HANDLED) && (retval & (OPERATOR_FINISHED|OPERATOR_CANCELLED))) { + if (!(retval & OPERATOR_HANDLED) && (retval & (OPERATOR_FINISHED | OPERATOR_CANCELLED))) { /* only show the report if the report list was not given in the function */ wm_operator_reports(C, op, retval, (reports != NULL)); } if (retval & OPERATOR_HANDLED) - ; /* do nothing, wm_operator_exec() has been called somewhere */ + ; /* do nothing, wm_operator_exec() has been called somewhere */ else if (retval & OPERATOR_FINISHED) { if (!is_nested_call) { /* not called by py script */ WM_operator_last_properties_store(op); @@ -868,7 +869,7 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P * Also check for macro */ if (ot->flag & OPTYPE_BLOCKING || (op->opm && op->opm->type->flag & OPTYPE_BLOCKING)) { - int bounds[4] = {-1,-1,-1,-1}; + int bounds[4] = {-1, -1, -1, -1}; int wrap; if (op->opm) { @@ -882,31 +883,31 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P /* exception, cont. grab in header is annoying */ if (wrap) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); if (ar && ar->regiontype == RGN_TYPE_HEADER) { - wrap= FALSE; + wrap = FALSE; } } if (wrap) { - rcti *winrect= NULL; - ARegion *ar= CTX_wm_region(C); - ScrArea *sa= CTX_wm_area(C); + rcti *winrect = NULL; + ARegion *ar = CTX_wm_region(C); + ScrArea *sa = CTX_wm_area(C); if (ar && ar->regiontype == RGN_TYPE_WINDOW && event && BLI_in_rcti(&ar->winrct, event->x, event->y)) { - winrect= &ar->winrct; + winrect = &ar->winrct; } else if (sa) { - winrect= &sa->totrct; + winrect = &sa->totrct; } if (winrect) { - bounds[0]= winrect->xmin; - bounds[1]= winrect->ymax; - bounds[2]= winrect->xmax; - bounds[3]= winrect->ymin; + bounds[0] = winrect->xmin; + bounds[1] = winrect->ymax; + bounds[2] = winrect->xmax; + bounds[3] = winrect->ymin; } } @@ -919,8 +920,9 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P * none to the UI handler */ wm_handler_ui_cancel(C); } - else + else { WM_operator_free(op); + } } return retval; @@ -933,7 +935,7 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA *properties, ReportList *reports, short context, short poll_only) { - wmWindow *window= CTX_wm_window(C); + wmWindow *window = CTX_wm_window(C); wmEvent *event; int retval; @@ -942,7 +944,7 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA /* dummie test */ if (ot && C) { - switch(context) { + switch (context) { case WM_OP_INVOKE_DEFAULT: case WM_OP_INVOKE_REGION_WIN: case WM_OP_INVOKE_AREA: @@ -951,13 +953,13 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA if (window == NULL) return 0; else - event= window->eventstate; + event = window->eventstate; break; default: event = NULL; } - switch(context) { + switch (context) { case WM_OP_EXEC_REGION_WIN: case WM_OP_INVOKE_REGION_WIN: @@ -969,8 +971,8 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA /* forces operator to go to the region window/channels/preview, for header menus * but we stay in the same region if we are already in one */ - ARegion *ar= CTX_wm_region(C); - ScrArea *area= CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + ScrArea *area = CTX_wm_area(C); int type = RGN_TYPE_WINDOW; switch (context) { @@ -992,12 +994,12 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA } if (!(ar && ar->regiontype == type) && area) { - ARegion *ar1= BKE_area_find_region_type(area, type); + ARegion *ar1 = BKE_area_find_region_type(area, type); if (ar1) CTX_wm_region_set(C, ar1); } - retval= wm_operator_invoke(C, ot, event, properties, reports, poll_only); + retval = wm_operator_invoke(C, ot, event, properties, reports, poll_only); /* set region back */ CTX_wm_region_set(C, ar); @@ -1007,11 +1009,11 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA case WM_OP_EXEC_AREA: case WM_OP_INVOKE_AREA: { - /* remove region from context */ - ARegion *ar= CTX_wm_region(C); + /* remove region from context */ + ARegion *ar = CTX_wm_region(C); CTX_wm_region_set(C, NULL); - retval= wm_operator_invoke(C, ot, event, properties, reports, poll_only); + retval = wm_operator_invoke(C, ot, event, properties, reports, poll_only); CTX_wm_region_set(C, ar); return retval; @@ -1020,12 +1022,12 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA case WM_OP_INVOKE_SCREEN: { /* remove region + area from context */ - ARegion *ar= CTX_wm_region(C); - ScrArea *area= CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + ScrArea *area = CTX_wm_area(C); CTX_wm_region_set(C, NULL); CTX_wm_area_set(C, NULL); - retval= wm_operator_invoke(C, ot, event, properties, reports, poll_only); + retval = wm_operator_invoke(C, ot, event, properties, reports, poll_only); CTX_wm_area_set(C, area); CTX_wm_region_set(C, ar); @@ -1044,7 +1046,7 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA /* invokes operator in context */ int WM_operator_name_call(bContext *C, const char *opstring, int context, PointerRNA *properties) { - wmOperatorType *ot= WM_operatortype_find(opstring, 0); + wmOperatorType *ot = WM_operatortype_find(opstring, 0); if (ot) return wm_operator_call_internal(C, ot, properties, NULL, context, FALSE); @@ -1058,17 +1060,17 @@ int WM_operator_name_call(bContext *C, const char *opstring, int context, Pointe */ int WM_operator_call_py(bContext *C, wmOperatorType *ot, int context, PointerRNA *properties, ReportList *reports) { - int retval= OPERATOR_CANCELLED; + int retval = OPERATOR_CANCELLED; #if 0 wmOperator *op; - op= wm_operator_create(wm, ot, properties, reports); + op = wm_operator_create(wm, ot, properties, reports); if (op->type->exec) { if (op->type->flag & OPTYPE_UNDO) wm->op_undo_depth++; - retval= op->type->exec(C, op); + retval = op->type->exec(C, op); OPERATOR_RETVAL_CHECK(retval); if (op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm) @@ -1091,9 +1093,9 @@ int WM_operator_call_py(bContext *C, wmOperatorType *ot, int context, PointerRNA if (wm && (wm == CTX_wm_manager(C))) wm->op_undo_depth--; /* keep the reports around if needed later */ - if ( (retval & OPERATOR_RUNNING_MODAL) || - ((retval & OPERATOR_FINISHED) && wm_operator_register_check(CTX_wm_manager(C), ot)) - ) { + if ((retval & OPERATOR_RUNNING_MODAL) || + ((retval & OPERATOR_FINISHED) && wm_operator_register_check(CTX_wm_manager(C), ot))) + { reports->flag |= RPT_FREE; /* let blender manage freeing */ } @@ -1112,28 +1114,28 @@ void wm_event_free_handler(wmEventHandler *handler) /* only set context when area/region is part of screen */ static void wm_handler_op_context(bContext *C, wmEventHandler *handler) { - bScreen *screen= CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); if (screen && handler->op) { - if (handler->op_area==NULL) + 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) @@ -1147,16 +1149,16 @@ static void wm_handler_op_context(bContext *C, wmEventHandler *handler) void WM_event_remove_handlers(bContext *C, ListBase *handlers) { wmEventHandler *handler; - wmWindowManager *wm= CTX_wm_manager(C); + 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) { - ScrArea *area= CTX_wm_area(C); - ARegion *region= CTX_wm_region(C); + ScrArea *area = CTX_wm_area(C); + ARegion *region = CTX_wm_region(C); wm_handler_op_context(C, handler); @@ -1176,9 +1178,9 @@ void WM_event_remove_handlers(bContext *C, ListBase *handlers) WM_operator_free(handler->op); } else if (handler->ui_remove) { - ScrArea *area= CTX_wm_area(C); - ARegion *region= CTX_wm_region(C); - ARegion *menu= CTX_wm_menu(C); + 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); @@ -1198,7 +1200,7 @@ void WM_event_remove_handlers(bContext *C, ListBase *handlers) /* do userdef mappings */ int WM_userdef_event_map(int kmitype) { - switch(kmitype) { + switch (kmitype) { case SELECTMOUSE: if (U.flag & USER_LMOUSESELECT) return LEFTMOUSE; @@ -1265,7 +1267,7 @@ static void wm_eventemulation(wmEvent *event) /* numpad emulation */ if (U.flag & USER_NONUMPAD) { - switch(event->type) { + switch (event->type) { case ZEROKEY: event->type = PAD0; break; case ONEKEY: event->type = PAD1; break; case TWOKEY: event->type = PAD2; break; @@ -1285,37 +1287,37 @@ static void wm_eventemulation(wmEvent *event) static int wm_eventmatch(wmEvent *winevent, wmKeyMapItem *kmi) { - int kmitype= WM_userdef_event_map(kmi->type); + int kmitype = WM_userdef_event_map(kmi->type); if (kmi->flag & KMI_INACTIVE) return 0; /* the matching rules */ - if (kmitype==KM_TEXTINPUT) + 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_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 (kmi->shift != KM_ANY) if (winevent->shift != kmi->shift && !(winevent->shift & kmi->shift)) return 0; - if (kmi->ctrl!=KM_ANY) + if (kmi->ctrl != KM_ANY) if (winevent->ctrl != kmi->ctrl && !(winevent->ctrl & kmi->ctrl)) return 0; - if (kmi->alt!=KM_ANY) + if (kmi->alt != KM_ANY) if (winevent->alt != kmi->alt && !(winevent->alt & kmi->alt)) return 0; - if (kmi->oskey!=KM_ANY) + 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 (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 != kmi->keymodifier) return 0; return 1; } @@ -1329,14 +1331,14 @@ static void wm_event_modalkeymap(const bContext *C, wmOperator *op, wmEvent *eve op = op->opm; if (op->type->modalkeymap) { - wmKeyMap *keymap= WM_keymap_active(CTX_wm_manager(C), 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)) { - event->type= EVT_MODAL_MAP; - event->val= kmi->propvalue; + event->type = EVT_MODAL_MAP; + event->val = kmi->propvalue; } } } @@ -1346,18 +1348,18 @@ static void wm_event_modalkeymap(const bContext *C, wmOperator *op, wmEvent *eve static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHandler *handler, wmEvent *event, PointerRNA *properties) { - int retval= OPERATOR_PASS_THROUGH; + int retval = OPERATOR_PASS_THROUGH; /* derived, modal or blocking operator */ if (handler->op) { - wmOperator *op= handler->op; - wmOperatorType *ot= op->type; + wmOperator *op = handler->op; + wmOperatorType *ot = op->type; if (ot->modal) { /* we set context to where modal handler came from */ - wmWindowManager *wm= CTX_wm_manager(C); - ScrArea *area= CTX_wm_area(C); - ARegion *region= CTX_wm_region(C); + wmWindowManager *wm = CTX_wm_manager(C); + ScrArea *area = CTX_wm_area(C); + ARegion *region = CTX_wm_region(C); wm_handler_op_context(C, handler); wm_region_mouse_co(C, event); @@ -1366,7 +1368,7 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand if (ot->flag & OPTYPE_UNDO) wm->op_undo_depth++; - retval= ot->modal(C, op, event); + retval = ot->modal(C, op, event); OPERATOR_RETVAL_CHECK(retval); /* when this is _not_ the case the modal modifier may have loaded @@ -1388,20 +1390,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) { wm_operator_finished(C, op, 0); - handler->op= NULL; + handler->op = NULL; } - else if (retval & (OPERATOR_CANCELLED|OPERATOR_FINISHED)) { + else if (retval & (OPERATOR_CANCELLED | OPERATOR_FINISHED)) { WM_operator_free(op); - handler->op= NULL; + 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); @@ -1417,20 +1419,20 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand printf("wm_handler_operator_call error\n"); } else { - wmOperatorType *ot= WM_operatortype_find(event->keymap_idname, 0); + wmOperatorType *ot = WM_operatortype_find(event->keymap_idname, 0); if (ot) - retval= wm_operator_invoke(C, ot, event, properties, NULL, FALSE); + 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)) - return (WM_HANDLER_BREAK|WM_HANDLER_MODAL); + if (retval == (OPERATOR_PASS_THROUGH | OPERATOR_RUNNING_MODAL)) + return (WM_HANDLER_BREAK | WM_HANDLER_MODAL); if (retval & OPERATOR_PASS_THROUGH) return WM_HANDLER_CONTINUE; @@ -1441,163 +1443,163 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand /* fileselect handlers are only in the window queue, so it's save to switch screens or area types */ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHandler *handler, wmEvent *event) { - wmWindowManager *wm= CTX_wm_manager(C); + wmWindowManager *wm = CTX_wm_manager(C); SpaceFile *sfile; - int action= WM_HANDLER_CONTINUE; + int action = WM_HANDLER_CONTINUE; if (event->type != EVT_FILESELECT) return action; if (handler->op != (wmOperator *)event->customdata) return action; - switch(event->val) { + switch (event->val) { case EVT_FILESELECT_OPEN: case EVT_FILESELECT_FULL_OPEN: - { - ScrArea *sa; + { + ScrArea *sa; - /* sa can be null when window A is active, but mouse is over window B */ - /* in this case, open file select in original window A */ - if (handler->op_area == NULL) { - bScreen *screen = CTX_wm_screen(C); - sa = (ScrArea *)screen->areabase.first; - } - else { - sa = handler->op_area; - } + /* sa can be null when window A is active, but mouse is over window B */ + /* in this case, open file select in original window A */ + if (handler->op_area == NULL) { + bScreen *screen = CTX_wm_screen(C); + sa = (ScrArea *)screen->areabase.first; + } + else { + sa = handler->op_area; + } - if (event->val==EVT_FILESELECT_OPEN) { - ED_area_newspace(C, sa, SPACE_FILE); /* 'sa' is modified in-place */ - } - else { - sa= ED_screen_full_newspace(C, sa, SPACE_FILE); /* sets context */ - } + if (event->val == EVT_FILESELECT_OPEN) { + ED_area_newspace(C, sa, SPACE_FILE); /* 'sa' is modified in-place */ + } + else { + sa = ED_screen_full_newspace(C, sa, SPACE_FILE); /* sets context */ + } - /* note, getting the 'sa' back from the context causes a nasty bug where the newly created - * 'sa' != CTX_wm_area(C). removed the line below and set 'sa' in the 'if' above */ - /* sa = CTX_wm_area(C); */ + /* note, getting the 'sa' back from the context causes a nasty bug where the newly created + * 'sa' != CTX_wm_area(C). removed the line below and set 'sa' in the 'if' above */ + /* sa = CTX_wm_area(C); */ - /* settings for filebrowser, sfile is not operator owner but sends events */ - sfile= (SpaceFile*)sa->spacedata.first; - sfile->op= handler->op; + /* settings for filebrowser, sfile is not operator owner but sends events */ + sfile = (SpaceFile *)sa->spacedata.first; + sfile->op = handler->op; - ED_fileselect_set_params(sfile); + ED_fileselect_set_params(sfile); - action= WM_HANDLER_BREAK; - } - break; + action = WM_HANDLER_BREAK; + } + break; case EVT_FILESELECT_EXEC: case EVT_FILESELECT_CANCEL: case EVT_FILESELECT_EXTERNAL_CANCEL: - { - /* XXX validate area and region? */ - bScreen *screen= CTX_wm_screen(C); + { + /* XXX validate area and region? */ + bScreen *screen = CTX_wm_screen(C); - /* remlink now, for load file case before removing*/ - BLI_remlink(handlers, handler); + /* remlink now, for load file case before removing*/ + BLI_remlink(handlers, handler); - if (event->val!=EVT_FILESELECT_EXTERNAL_CANCEL) { - if (screen != handler->filescreen) { - ED_screen_full_prevspace(C, CTX_wm_area(C)); - } - else { - ED_area_prevspace(C, CTX_wm_area(C)); - } + if (event->val != EVT_FILESELECT_EXTERNAL_CANCEL) { + if (screen != handler->filescreen) { + ED_screen_full_prevspace(C, CTX_wm_area(C)); + } + else { + ED_area_prevspace(C, CTX_wm_area(C)); } + } - wm_handler_op_context(C, handler); + wm_handler_op_context(C, handler); - /* needed for uiPupMenuReports */ + /* needed for uiPupMenuReports */ - if (event->val==EVT_FILESELECT_EXEC) { -#if 0 // use REDALERT now + if (event->val == EVT_FILESELECT_EXEC) { +#if 0 // use REDALERT now - /* a bit weak, might become arg for WM_event_fileselect? */ - /* XXX also extension code in image-save doesnt work for this yet */ - if (RNA_struct_find_property(handler->op->ptr, "check_existing") && - RNA_boolean_get(handler->op->ptr, "check_existing")) { - 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) - MEM_freeN(path); - } - else + /* a bit weak, might become arg for WM_event_fileselect? */ + /* XXX also extension code in image-save doesnt work for this yet */ + if (RNA_struct_find_property(handler->op->ptr, "check_existing") && + RNA_boolean_get(handler->op->ptr, "check_existing")) { + 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) + MEM_freeN(path); + } + else #endif - { - int retval; + { + int retval; - 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) - wm->op_undo_depth--; + if (handler->op->type->flag & OPTYPE_UNDO) + wm->op_undo_depth++; - if (retval & OPERATOR_FINISHED) - 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) - ED_undo_push_op(C, handler->op); + retval = handler->op->type->exec(C, handler->op); - if (handler->op->reports->list.first) { + /* 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) + wm->op_undo_depth--; - /* FIXME, temp setting window, this is really bad! - * only have because lib linking errors need to be seen by users :( - * it can be removed without breaking anything but then no linking errors - campbell */ - wmWindow *win_prev= CTX_wm_window(C); - ScrArea *area_prev= CTX_wm_area(C); - ARegion *ar_prev= CTX_wm_region(C); + if (retval & OPERATOR_FINISHED) + if (G.f & G_DEBUG) + wm_operator_print(C, handler->op); - if (win_prev==NULL) - CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first); + /* 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) + ED_undo_push_op(C, handler->op); - handler->op->reports->printlevel = RPT_WARNING; - uiPupMenuReports(C, handler->op->reports); + if (handler->op->reports->list.first) { - /* XXX - copied from 'wm_operator_finished()' */ - /* add reports to the global list, otherwise they are not seen */ - BLI_movelisttolist(&CTX_wm_reports(C)->list, &handler->op->reports->list); + /* FIXME, temp setting window, this is really bad! + * only have because lib linking errors need to be seen by users :( + * it can be removed without breaking anything but then no linking errors - campbell */ + wmWindow *win_prev = CTX_wm_window(C); + ScrArea *area_prev = CTX_wm_area(C); + ARegion *ar_prev = CTX_wm_region(C); - CTX_wm_window_set(C, win_prev); - CTX_wm_area_set(C, area_prev); - CTX_wm_region_set(C, ar_prev); - } + if (win_prev == NULL) + CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first); - if (retval & OPERATOR_FINISHED) { - WM_operator_last_properties_store(handler->op); - } + handler->op->reports->printlevel = RPT_WARNING; + uiPupMenuReports(C, handler->op->reports); - WM_operator_free(handler->op); - } - } - else { - if (handler->op->type->cancel) { - if (handler->op->type->flag & OPTYPE_UNDO) - wm->op_undo_depth++; + /* XXX - copied from 'wm_operator_finished()' */ + /* add reports to the global list, otherwise they are not seen */ + BLI_movelisttolist(&CTX_wm_reports(C)->list, &handler->op->reports->list); - handler->op->type->cancel(C, handler->op); + CTX_wm_window_set(C, win_prev); + CTX_wm_area_set(C, area_prev); + CTX_wm_region_set(C, ar_prev); + } - if (handler->op->type->flag & OPTYPE_UNDO) - wm->op_undo_depth--; + if (retval & OPERATOR_FINISHED) { + WM_operator_last_properties_store(handler->op); } WM_operator_free(handler->op); } + } + else { + if (handler->op->type->cancel) { + if (handler->op->type->flag & OPTYPE_UNDO) + wm->op_undo_depth++; - CTX_wm_area_set(C, NULL); + handler->op->type->cancel(C, handler->op); - wm_event_free_handler(handler); + if (handler->op->type->flag & OPTYPE_UNDO) + wm->op_undo_depth--; + } - action= WM_HANDLER_BREAK; + WM_operator_free(handler->op); } - break; + + CTX_wm_area_set(C, NULL); + + wm_event_free_handler(handler); + + action = WM_HANDLER_BREAK; + } + break; } return action; @@ -1607,12 +1609,12 @@ static int handler_boundbox_test(wmEventHandler *handler, wmEvent *event) { if (handler->bbwin) { if (handler->bblocal) { - rcti rect= *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)) 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; @@ -1620,7 +1622,7 @@ static int handler_boundbox_test(wmEventHandler *handler, wmEvent *event) else { 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; @@ -1631,36 +1633,36 @@ static int handler_boundbox_test(wmEventHandler *handler, wmEvent *event) static int wm_action_not_handled(int action) { - return action == WM_HANDLER_CONTINUE || action == (WM_HANDLER_BREAK|WM_HANDLER_MODAL); + return action == WM_HANDLER_CONTINUE || action == (WM_HANDLER_BREAK | WM_HANDLER_MODAL); } static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) { - wmWindowManager *wm= CTX_wm_manager(C); + wmWindowManager *wm = CTX_wm_manager(C); wmEventHandler *handler, *nexthandler; - int action= WM_HANDLER_CONTINUE; + 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; + nexthandler = handler->next; /* during this loop, ui handlers for nested menus can tag multiple handlers free */ - if (handler->flag & WM_HANDLER_DO_FREE); - /* optional boundbox */ + if (handler->flag & WM_HANDLER_DO_FREE) ; + /* optional boundbox */ 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); + always_pass = wm_event_always_pass(event); /* modal+blocking handler */ if (handler->flag & WM_HANDLER_BLOCKING) action |= WM_HANDLER_BREAK; if (handler->keymap) { - wmKeyMap *keymap= WM_keymap_active(wm, handler->keymap); + wmKeyMap *keymap = WM_keymap_active(wm, handler->keymap); wmKeyMapItem *kmi; if (!keymap->poll || keymap->poll(C)) { @@ -1680,34 +1682,34 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) 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) { - wmDropBox *drop= handler->dropboxes->first; - for (; drop; drop= drop->next) { + if (event->type == EVT_DROP) { + wmDropBox *drop = handler->dropboxes->first; + for (; drop; drop = drop->next) { /* other drop custom types allowed */ - if (event->custom==EVT_DATA_LISTBASE) { - ListBase *lb= (ListBase *)event->customdata; + if (event->custom == EVT_DATA_LISTBASE) { + ListBase *lb = (ListBase *)event->customdata; wmDrag *drag; - for (drag= lb->first; drag; drag= drag->next) { + for (drag = lb->first; drag; drag = drag->next) { if (drop->poll(C, drag, event)) { drop->copy(drag, drop); /* free the drags before calling operator */ BLI_freelistN(event->customdata); - event->customdata= NULL; - event->custom= 0; + event->customdata = NULL; + event->custom = 0; WM_operator_name_call(C, drop->ot->idname, drop->opcontext, drop->ptr); 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 */ @@ -1733,7 +1735,7 @@ 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; } @@ -1762,10 +1764,10 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) * If no double click events are found it will fallback to a single click. * So a double click event can result in 2 successive single click calls * if its not handled by the keymap - campbell */ - if ( (ABS(event->x - win->eventstate->prevclickx)) <= 2 && - (ABS(event->y - win->eventstate->prevclicky)) <= 2 && - ((PIL_check_seconds_timer() - win->eventstate->prevclicktime) * 1000 < U.dbl_click_time) - ) { + if ((ABS(event->x - win->eventstate->prevclickx)) <= 2 && + (ABS(event->y - win->eventstate->prevclicky)) <= 2 && + ((PIL_check_seconds_timer() - win->eventstate->prevclicktime) * 1000 < U.dbl_click_time)) + { event->val = KM_DBL_CLICK; /* removed this because in cases where we're this is used as a single click * event, this will give old coords, @@ -1788,7 +1790,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; @@ -1800,8 +1802,8 @@ static int wm_event_inside_i(wmEvent *event, rcti *rect) return 1; 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; @@ -1811,11 +1813,11 @@ static int wm_event_inside_i(wmEvent *event, rcti *rect) static ScrArea *area_event_inside(bContext *C, int x, int y) { - bScreen *screen= CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); ScrArea *sa; if (screen) - for (sa= screen->areabase.first; sa; sa= sa->next) + for (sa = screen->areabase.first; sa; sa = sa->next) if (BLI_in_rcti(&sa->totrct, x, y)) return sa; return NULL; @@ -1823,12 +1825,12 @@ static ScrArea *area_event_inside(bContext *C, int x, int y) static ARegion *region_event_inside(bContext *C, int x, int y) { - bScreen *screen= CTX_wm_screen(C); - ScrArea *area= CTX_wm_area(C); + bScreen *screen = CTX_wm_screen(C); + ScrArea *area = CTX_wm_area(C); ARegion *ar; if (screen && area) - for (ar= area->regionbase.first; ar; ar= ar->next) + for (ar = area->regionbase.first; ar; ar = ar->next) if (BLI_in_rcti(&ar->winrct, x, y)) return ar; return NULL; @@ -1837,10 +1839,10 @@ static ARegion *region_event_inside(bContext *C, int x, int y) static void wm_paintcursor_tag(bContext *C, wmPaintCursor *pc, ARegion *ar) { if (ar) { - for (; pc; pc= pc->next) { + for (; pc; pc = pc->next) { if (pc->poll == NULL || pc->poll(C)) { - wmWindow *win= CTX_wm_window(C); - win->screen->do_draw_paintcursor= 1; + wmWindow *win = CTX_wm_window(C); + win->screen->do_draw_paintcursor = 1; wm_tag_redraw_overlay(win, ar); } } @@ -1851,17 +1853,17 @@ static void wm_paintcursor_tag(bContext *C, wmPaintCursor *pc, ARegion *ar) /* context was set on active area and region */ static void wm_paintcursor_test(bContext *C, wmEvent *event) { - wmWindowManager *wm= CTX_wm_manager(C); + wmWindowManager *wm = CTX_wm_manager(C); if (wm->paintcursors.first) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); 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)) { - ScrArea *sa= CTX_wm_area(C); + 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)); CTX_wm_region_set(C, region_event_inside(C, event->prevx, event->prevy)); @@ -1876,16 +1878,16 @@ 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) - win->screen->do_draw_drag= 1; - else if (event->type==ESCKEY) { + if (event->type == MOUSEMOVE) + win->screen->do_draw_drag = 1; + else if (event->type == ESCKEY) { BLI_freelistN(&wm->drags); - win->screen->do_draw_drag= 1; + win->screen->do_draw_drag = 1; } - else if (event->type==LEFTMOUSE && event->val==KM_RELEASE) { - event->type= EVT_DROP; + else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { + event->type = EVT_DROP; /* create customdata, first free existing */ if (event->customdata) { @@ -1893,12 +1895,12 @@ static void wm_event_drag_test(wmWindowManager *wm, wmWindow *win, wmEvent *even MEM_freeN(event->customdata); } - event->custom= EVT_DATA_LISTBASE; - event->customdata= &wm->drags; - event->customdatafree= 1; + event->custom = EVT_DATA_LISTBASE; + event->customdata = &wm->drags; + event->customdatafree = 1; /* clear drop icon */ - win->screen->do_draw_drag= 1; + win->screen->do_draw_drag = 1; /* restore cursor (disabled, see wm_dragdrop.c) */ // WM_cursor_restore(win); @@ -1907,7 +1909,7 @@ 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) - win->screen->do_draw= 1; + win->screen->do_draw = 1; } @@ -1915,19 +1917,19 @@ static void wm_event_drag_test(wmWindowManager *wm, wmWindow *win, wmEvent *even /* goes over entire hierarchy: events -> window -> screen -> area -> region */ void wm_event_do_handlers(bContext *C) { - wmWindowManager *wm= CTX_wm_manager(C); + wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win; /* 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; + Scene *scene = win->screen->scene; if (scene) { int playing = sound_scene_playing(win->screen->scene); @@ -1945,7 +1947,7 @@ void wm_event_do_handlers(bContext *C) float time = sound_sync_scene(scene); 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); @@ -1960,7 +1962,7 @@ 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)) @@ -1983,7 +1985,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 */ @@ -1995,25 +1997,25 @@ void wm_event_do_handlers(bContext *C) if ((action & WM_HANDLER_BREAK) == 0) { ScrArea *sa; ARegion *ar; - int doit= 0; + 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 */ wm_paintcursor_test(C, event); } - else if (event->type==NDOF_MOTION) { + else if (event->type == NDOF_MOTION) { win->addmousemove = TRUE; } - for (sa= win->screen->areabase.first; sa; sa= sa->next) { + 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) { + for (ar = sa->regionbase.first; ar; ar = ar->next) { if (wm_event_inside_i(event, &ar->winrct)) { CTX_wm_region_set(C, ar); @@ -2029,7 +2031,7 @@ void wm_event_do_handlers(bContext *C) 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)); @@ -2062,15 +2064,15 @@ 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) { - win->eventstate->prevx= event->x; - win->eventstate->prevy= event->y; + win->eventstate->prevx = event->x; + win->eventstate->prevy = event->y; //printf("win->eventstate->prev = %d %d\n", event->x, event->y); } else { @@ -2120,13 +2122,13 @@ void wm_event_do_handlers(bContext *C) /* only add mousemove when queue was read entirely */ if (win->addmousemove && win->eventstate) { - wmEvent tevent= *(win->eventstate); + wmEvent tevent = *(win->eventstate); //printf("adding MOUSEMOVE %d %d\n", tevent.x, tevent.y); - tevent.type= MOUSEMOVE; - tevent.prevx= tevent.x; - tevent.prevy= tevent.y; + tevent.type = MOUSEMOVE; + tevent.prevx = tevent.x; + tevent.prevy = tevent.y; wm_event_add(win, &tevent); - win->addmousemove= 0; + win->addmousemove = 0; } CTX_wm_window_set(C, NULL); @@ -2143,12 +2145,12 @@ 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) { - wmEvent event= *win->eventstate; + for (win = CTX_wm_manager(C)->windows.first; win; win = win->next) { + wmEvent event = *win->eventstate; - event.type= EVT_FILESELECT; - event.val= eventval; - event.customdata= ophandle; // only as void pointer type check + event.type = EVT_FILESELECT; + event.val = eventval; + event.customdata = ophandle; // only as void pointer type check wm_event_add(win, &event); } @@ -2165,12 +2167,12 @@ void WM_event_fileselect_event(bContext *C, void *ophandle, int eventval) void WM_event_add_fileselect(bContext *C, wmOperator *op) { wmEventHandler *handler, *handlernext; - wmWindow *win= CTX_wm_window(C); - int full= 1; // XXX preset? + wmWindow *win = CTX_wm_window(C); + int full = 1; // XXX preset? /* only allow 1 file selector open per window */ - for (handler= win->modalhandlers.first; handler; handler=handlernext) { - handlernext= handler->next; + for (handler = win->modalhandlers.first; handler; handler = handlernext) { + handlernext = handler->next; if (handler->type == WM_HANDLER_FILESELECT) { if (handler->op) @@ -2182,11 +2184,11 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op) handler = MEM_callocN(sizeof(wmEventHandler), "fileselect handler"); - handler->type= WM_HANDLER_FILESELECT; - handler->op= op; - handler->op_area= CTX_wm_area(C); - handler->op_region= CTX_wm_region(C); - handler->filescreen= CTX_wm_screen(C); + handler->type = WM_HANDLER_FILESELECT; + handler->op = op; + handler->op_area = CTX_wm_area(C); + handler->op_region = CTX_wm_region(C); + handler->filescreen = CTX_wm_screen(C); BLI_addhead(&win->modalhandlers, handler); @@ -2196,34 +2198,34 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op) op->type->check(C, op); /* ignore return value */ } - WM_event_fileselect_event(C, op, full?EVT_FILESELECT_FULL_OPEN:EVT_FILESELECT_OPEN); + WM_event_fileselect_event(C, op, full ? EVT_FILESELECT_FULL_OPEN : EVT_FILESELECT_OPEN); } #if 0 /* lets not expose struct outside wm? */ static void WM_event_set_handler_flag(wmEventHandler *handler, int flag) { - handler->flag= flag; + handler->flag = flag; } #endif wmEventHandler *WM_event_add_modal_handler(bContext *C, wmOperator *op) { - wmEventHandler *handler= MEM_callocN(sizeof(wmEventHandler), "event modal handler"); - wmWindow *win= CTX_wm_window(C); + wmEventHandler *handler = MEM_callocN(sizeof(wmEventHandler), "event modal handler"); + wmWindow *win = CTX_wm_window(C); /* operator was part of macro */ if (op->opm) { /* give the mother macro to the handler */ - handler->op= op->opm; + handler->op = op->opm; /* mother macro opm becomes the macro element */ - handler->op->opm= op; + handler->op->opm = op; } else - handler->op= op; + handler->op = op; - handler->op_area= CTX_wm_area(C); /* means frozen screen context for modal handlers! */ - handler->op_region= CTX_wm_region(C); + handler->op_area = CTX_wm_area(C); /* means frozen screen context for modal handlers! */ + handler->op_region = CTX_wm_region(C); BLI_addhead(&win->modalhandlers, handler); @@ -2240,13 +2242,13 @@ wmEventHandler *WM_event_add_keymap_handler(ListBase *handlers, wmKeyMap *keymap } /* 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"); + handler = MEM_callocN(sizeof(wmEventHandler), "event keymap handler"); BLI_addtail(handlers, handler); - handler->keymap= keymap; + handler->keymap = keymap; return handler; } @@ -2258,20 +2260,20 @@ wmEventHandler *WM_event_add_keymap_handler_priority(ListBase *handlers, wmKeyMa WM_event_remove_keymap_handler(handlers, keymap); - handler= MEM_callocN(sizeof(wmEventHandler), "event keymap handler"); + handler = MEM_callocN(sizeof(wmEventHandler), "event keymap handler"); BLI_addhead(handlers, handler); - handler->keymap= keymap; + handler->keymap = keymap; return handler; } wmEventHandler *WM_event_add_keymap_handler_bb(ListBase *handlers, wmKeyMap *keymap, rcti *bblocal, rcti *bbwin) { - wmEventHandler *handler= WM_event_add_keymap_handler(handlers, keymap); + wmEventHandler *handler = WM_event_add_keymap_handler(handlers, keymap); if (handler) { - handler->bblocal= bblocal; - handler->bbwin= bbwin; + handler->bblocal = bblocal; + handler->bbwin = bbwin; } return handler; } @@ -2280,8 +2282,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; @@ -2292,13 +2294,13 @@ void WM_event_remove_keymap_handler(ListBase *handlers, wmKeyMap *keymap) wmEventHandler *WM_event_add_ui_handler(const bContext *C, ListBase *handlers, wmUIHandlerFunc func, wmUIHandlerRemoveFunc remove, void *userdata) { - wmEventHandler *handler= MEM_callocN(sizeof(wmEventHandler), "event ui handler"); - handler->ui_handle= func; - handler->ui_remove= remove; - handler->ui_userdata= userdata; - handler->ui_area= (C)? CTX_wm_area(C): NULL; - handler->ui_region= (C)? CTX_wm_region(C): NULL; - handler->ui_menu= (C)? CTX_wm_menu(C): NULL; + wmEventHandler *handler = MEM_callocN(sizeof(wmEventHandler), "event ui handler"); + handler->ui_handle = func; + handler->ui_remove = remove; + handler->ui_userdata = userdata; + handler->ui_area = (C) ? CTX_wm_area(C) : NULL; + handler->ui_region = (C) ? CTX_wm_region(C) : NULL; + handler->ui_menu = (C) ? CTX_wm_menu(C) : NULL; BLI_addhead(handlers, handler); @@ -2311,7 +2313,7 @@ void WM_event_remove_ui_handler(ListBase *handlers, { wmEventHandler *handler; - for (handler= handlers->first; handler; handler= handler->next) { + 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) { @@ -2331,14 +2333,14 @@ 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"); + handler = MEM_callocN(sizeof(wmEventHandler), "dropbox handler"); /* dropbox stored static, no free or copy */ - handler->dropboxes= dropboxes; + handler->dropboxes = dropboxes; BLI_addhead(handlers, handler); return handler; @@ -2349,7 +2351,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) { @@ -2370,9 +2372,9 @@ static void WM_event_remove_handler(ListBase *handlers, wmEventHandler *handler) void WM_event_add_mousemove(bContext *C) { - wmWindow *window= CTX_wm_window(C); + wmWindow *window = CTX_wm_window(C); - window->addmousemove= 1; + window->addmousemove = 1; } /* for modal callbacks, check configuration for how to interpret exit with tweaks */ @@ -2415,85 +2417,85 @@ int WM_modal_tweak_exit(wmEvent *evt, int tweak_event) static int convert_key(GHOST_TKey key) { - if (key>=GHOST_kKeyA && key<=GHOST_kKeyZ) { + 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 { switch (key) { - case GHOST_kKeyBackSpace: return BACKSPACEKEY; - case GHOST_kKeyTab: return TABKEY; - case GHOST_kKeyLinefeed: return LINEFEEDKEY; - case GHOST_kKeyClear: return 0; - case GHOST_kKeyEnter: return RETKEY; - - case GHOST_kKeyEsc: return ESCKEY; - case GHOST_kKeySpace: return SPACEKEY; - case GHOST_kKeyQuote: return QUOTEKEY; - case GHOST_kKeyComma: return COMMAKEY; - case GHOST_kKeyMinus: return MINUSKEY; - case GHOST_kKeyPeriod: return PERIODKEY; - case GHOST_kKeySlash: return SLASHKEY; - - case GHOST_kKeySemicolon: return SEMICOLONKEY; - case GHOST_kKeyEqual: return EQUALKEY; - - case GHOST_kKeyLeftBracket: return LEFTBRACKETKEY; - case GHOST_kKeyRightBracket: return RIGHTBRACKETKEY; - case GHOST_kKeyBackslash: return BACKSLASHKEY; - case GHOST_kKeyAccentGrave: return ACCENTGRAVEKEY; - - case GHOST_kKeyLeftShift: return LEFTSHIFTKEY; - case GHOST_kKeyRightShift: return RIGHTSHIFTKEY; - case GHOST_kKeyLeftControl: return LEFTCTRLKEY; - case GHOST_kKeyRightControl: return RIGHTCTRLKEY; - case GHOST_kKeyOS: return OSKEY; - case GHOST_kKeyLeftAlt: return LEFTALTKEY; - case GHOST_kKeyRightAlt: return RIGHTALTKEY; - - case GHOST_kKeyCapsLock: return CAPSLOCKKEY; - case GHOST_kKeyNumLock: return 0; - case GHOST_kKeyScrollLock: return 0; - - case GHOST_kKeyLeftArrow: return LEFTARROWKEY; - case GHOST_kKeyRightArrow: return RIGHTARROWKEY; - case GHOST_kKeyUpArrow: return UPARROWKEY; - case GHOST_kKeyDownArrow: return DOWNARROWKEY; - - case GHOST_kKeyPrintScreen: return 0; - case GHOST_kKeyPause: return PAUSEKEY; - - case GHOST_kKeyInsert: return INSERTKEY; - case GHOST_kKeyDelete: return DELKEY; - case GHOST_kKeyHome: return HOMEKEY; - case GHOST_kKeyEnd: return ENDKEY; - case GHOST_kKeyUpPage: return PAGEUPKEY; - case GHOST_kKeyDownPage: return PAGEDOWNKEY; - - case GHOST_kKeyNumpadPeriod: return PADPERIOD; - case GHOST_kKeyNumpadEnter: return PADENTER; - case GHOST_kKeyNumpadPlus: return PADPLUSKEY; - case GHOST_kKeyNumpadMinus: return PADMINUS; - case GHOST_kKeyNumpadAsterisk: return PADASTERKEY; - case GHOST_kKeyNumpadSlash: return PADSLASHKEY; - - case GHOST_kKeyGrLess: return GRLESSKEY; - - case GHOST_kKeyMediaPlay: return MEDIAPLAY; - case GHOST_kKeyMediaStop: return MEDIASTOP; - case GHOST_kKeyMediaFirst: return MEDIAFIRST; - case GHOST_kKeyMediaLast: return MEDIALAST; + case GHOST_kKeyBackSpace: return BACKSPACEKEY; + case GHOST_kKeyTab: return TABKEY; + case GHOST_kKeyLinefeed: return LINEFEEDKEY; + case GHOST_kKeyClear: return 0; + case GHOST_kKeyEnter: return RETKEY; + + case GHOST_kKeyEsc: return ESCKEY; + case GHOST_kKeySpace: return SPACEKEY; + case GHOST_kKeyQuote: return QUOTEKEY; + case GHOST_kKeyComma: return COMMAKEY; + case GHOST_kKeyMinus: return MINUSKEY; + case GHOST_kKeyPeriod: return PERIODKEY; + case GHOST_kKeySlash: return SLASHKEY; + + case GHOST_kKeySemicolon: return SEMICOLONKEY; + case GHOST_kKeyEqual: return EQUALKEY; + + case GHOST_kKeyLeftBracket: return LEFTBRACKETKEY; + case GHOST_kKeyRightBracket: return RIGHTBRACKETKEY; + case GHOST_kKeyBackslash: return BACKSLASHKEY; + case GHOST_kKeyAccentGrave: return ACCENTGRAVEKEY; + + case GHOST_kKeyLeftShift: return LEFTSHIFTKEY; + case GHOST_kKeyRightShift: return RIGHTSHIFTKEY; + case GHOST_kKeyLeftControl: return LEFTCTRLKEY; + case GHOST_kKeyRightControl: return RIGHTCTRLKEY; + case GHOST_kKeyOS: return OSKEY; + case GHOST_kKeyLeftAlt: return LEFTALTKEY; + case GHOST_kKeyRightAlt: return RIGHTALTKEY; + + case GHOST_kKeyCapsLock: return CAPSLOCKKEY; + case GHOST_kKeyNumLock: return 0; + case GHOST_kKeyScrollLock: return 0; + + case GHOST_kKeyLeftArrow: return LEFTARROWKEY; + case GHOST_kKeyRightArrow: return RIGHTARROWKEY; + case GHOST_kKeyUpArrow: return UPARROWKEY; + case GHOST_kKeyDownArrow: return DOWNARROWKEY; + + case GHOST_kKeyPrintScreen: return 0; + case GHOST_kKeyPause: return PAUSEKEY; + + case GHOST_kKeyInsert: return INSERTKEY; + case GHOST_kKeyDelete: return DELKEY; + case GHOST_kKeyHome: return HOMEKEY; + case GHOST_kKeyEnd: return ENDKEY; + case GHOST_kKeyUpPage: return PAGEUPKEY; + case GHOST_kKeyDownPage: return PAGEDOWNKEY; + + case GHOST_kKeyNumpadPeriod: return PADPERIOD; + case GHOST_kKeyNumpadEnter: return PADENTER; + case GHOST_kKeyNumpadPlus: return PADPLUSKEY; + case GHOST_kKeyNumpadMinus: return PADMINUS; + case GHOST_kKeyNumpadAsterisk: return PADASTERKEY; + case GHOST_kKeyNumpadSlash: return PADSLASHKEY; + + case GHOST_kKeyGrLess: return GRLESSKEY; + + case GHOST_kKeyMediaPlay: return MEDIAPLAY; + case GHOST_kKeyMediaStop: return MEDIASTOP; + case GHOST_kKeyMediaFirst: return MEDIAFIRST; + case GHOST_kKeyMediaLast: return MEDIALAST; default: - return UNKNOWNKEY; /* GHOST_kKeyUnknown */ + return UNKNOWNKEY; /* GHOST_kKeyUnknown */ } } } @@ -2501,27 +2503,27 @@ static int convert_key(GHOST_TKey key) /* adds customdata to event */ static void update_tablet_data(wmWindow *win, wmEvent *event) { - const GHOST_TabletData *td= GHOST_GetTabletData(win->ghostwin); + const GHOST_TabletData *td = GHOST_GetTabletData(win->ghostwin); /* if there's tablet data from an active tablet device then add it */ if ((td != NULL) && td->Active != GHOST_kTabletModeNone) { - struct wmTabletData *wmtab= MEM_mallocN(sizeof(wmTabletData), "customdata tablet"); + struct wmTabletData *wmtab = MEM_mallocN(sizeof(wmTabletData), "customdata tablet"); wmtab->Active = (int)td->Active; wmtab->Pressure = td->Pressure; wmtab->Xtilt = td->Xtilt; wmtab->Ytilt = td->Ytilt; - event->custom= EVT_DATA_TABLET; - event->customdata= wmtab; - event->customdatafree= 1; + event->custom = EVT_DATA_TABLET; + event->customdata = wmtab; + event->customdatafree = 1; } } /* adds customdata to event */ -static void attach_ndof_data(wmEvent* event, const GHOST_TEventNDOFMotionData* ghost) +static void attach_ndof_data(wmEvent *event, const GHOST_TEventNDOFMotionData *ghost) { - wmNDOFMotionData* data = MEM_mallocN(sizeof(wmNDOFMotionData), "customdata NDOF"); + wmNDOFMotionData *data = MEM_mallocN(sizeof(wmNDOFMotionData), "customdata NDOF"); const float s = U.ndof_sensitivity; @@ -2545,11 +2547,11 @@ static void attach_ndof_data(wmEvent* event, const GHOST_TEventNDOFMotionData* g data->ry = s * ghost->rz; data->rz = s * ghost->ry; #endif - } + } else { data->ty = s * ghost->ty; data->tz = s * ghost->tz; - } + } data->dt = ghost->dt; @@ -2563,19 +2565,19 @@ static void attach_ndof_data(wmEvent* event, const GHOST_TEventNDOFMotionData* g /* imperfect but probably usable... draw/enable drags to other windows */ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *win, wmEvent *evt) { - int mx= evt->x, my= evt->y; + 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) + for (handler = win->modalhandlers.first; handler; handler = handler->next) if (handler->ui_handle || handler->op) return NULL; @@ -2584,13 +2586,13 @@ 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 && - mx-owin->posx <= owin->sizex && my-owin->posy <= owin->sizey) { - evt->x= mx - (int)owin->posx; - evt->y= my - (int)owin->posy; + 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; return owin; } @@ -2605,27 +2607,27 @@ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *wi void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int UNUSED(time), void *customdata) { wmWindow *owin; - wmEvent event, *evt= win->eventstate; + wmEvent event, *evt = win->eventstate; /* initialize and copy state (only mouse x y and modifiers) */ - event= *evt; + event = *evt; switch (type) { /* mouse move */ case GHOST_kEventCursorMove: { if (win->active) { - GHOST_TEventCursorData *cd= customdata; - wmEvent *lastevent= win->queue.last; + GHOST_TEventCursorData *cd = customdata; + wmEvent *lastevent = win->queue.last; int cx, cy; GHOST_ScreenToClient(win->ghostwin, cd->x, cd->y, &cx, &cy); - evt->x= cx; - evt->y= (win->sizey-1) - cy; + evt->x = cx; + evt->y = (win->sizey - 1) - cy; - event.x= evt->x; - event.y= evt->y; + event.x = evt->x; + event.y = evt->y; - event.type= MOUSEMOVE; + event.type = MOUSEMOVE; /* some painting operators want accurate mouse events, they can * handle in between mouse move moves, others can happily ignore @@ -2640,13 +2642,13 @@ 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); + owin = wm_event_cursor_other_windows(wm, win, &event); if (owin) { - wmEvent oevent= *(owin->eventstate); + wmEvent oevent = *(owin->eventstate); - oevent.x=owin->eventstate->x= event.x; - oevent.y=owin->eventstate->y= event.y; - oevent.type= MOUSEMOVE; + oevent.x = owin->eventstate->x = event.x; + oevent.y = owin->eventstate->y = event.y; + oevent.type = MOUSEMOVE; update_tablet_data(owin, &oevent); wm_event_add(owin, &oevent); @@ -2656,7 +2658,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U break; } case GHOST_kEventTrackpad: { - GHOST_TEventTrackpadData * pd = customdata; + GHOST_TEventTrackpadData *pd = customdata; switch (pd->subtype) { case GHOST_kTrackpadEventMagnify: event.type = MOUSEZOOM; @@ -2666,20 +2668,20 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U break; case GHOST_kTrackpadEventScroll: default: - event.type= MOUSEPAN; + event.type = MOUSEPAN; break; } { int cx, cy; GHOST_ScreenToClient(win->ghostwin, pd->x, pd->y, &cx, &cy); - event.x= evt->x= cx; - event.y= evt->y= (win->sizey-1) - cy; + event.x = evt->x = cx; + event.y = evt->y = (win->sizey - 1) - cy; } // Use prevx/prevy so we can calculate the delta later - event.prevx= event.x - pd->deltaX; - event.prevy= event.y - (-pd->deltaY); + event.prevx = event.x - pd->deltaX; + event.prevy = event.y - (-pd->deltaY); update_tablet_data(win, &event); wm_event_add(win, &event); @@ -2688,41 +2690,41 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U /* mouse button */ case GHOST_kEventButtonDown: case GHOST_kEventButtonUp: { - GHOST_TEventButtonData *bd= customdata; + GHOST_TEventButtonData *bd = customdata; /* Note!, this starts as 0/1 but later is converted to KM_PRESS/KM_RELEASE by tweak */ - event.val= (type==GHOST_kEventButtonDown) ? KM_PRESS:KM_RELEASE; + event.val = (type == GHOST_kEventButtonDown) ? KM_PRESS : KM_RELEASE; if (bd->button == GHOST_kButtonMaskLeft) - event.type= LEFTMOUSE; + event.type = LEFTMOUSE; else if (bd->button == GHOST_kButtonMaskRight) - event.type= RIGHTMOUSE; + event.type = RIGHTMOUSE; else if (bd->button == GHOST_kButtonMaskButton4) - event.type= BUTTON4MOUSE; + event.type = BUTTON4MOUSE; else if (bd->button == GHOST_kButtonMaskButton5) - event.type= BUTTON5MOUSE; + event.type = BUTTON5MOUSE; else - event.type= MIDDLEMOUSE; + 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!) */ wm_get_cursor_position(win, &cx, &cy); - event.x= evt->x= cx; - event.y= evt->y= cy; + event.x = evt->x = cx; + event.y = evt->y = cy; } /* add to other window if event is there (not to both!) */ - owin= wm_event_cursor_other_windows(wm, win, &event); + owin = wm_event_cursor_other_windows(wm, win, &event); if (owin) { - wmEvent oevent= *(owin->eventstate); + wmEvent oevent = *(owin->eventstate); - oevent.x= event.x; - oevent.y= event.y; - oevent.type= event.type; - oevent.val= event.val; + oevent.x = event.x; + oevent.y = event.y; + oevent.type = event.type; + oevent.val = event.val; update_tablet_data(owin, &oevent); wm_event_add(owin, &oevent); @@ -2737,66 +2739,66 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U /* keyboard */ case GHOST_kEventKeyDown: case GHOST_kEventKeyUp: { - GHOST_TEventKeyData *kd= customdata; - event.type= convert_key(kd->key); - event.ascii= kd->ascii; - memcpy(event.utf8_buf, kd->utf8_buf,sizeof(event.utf8_buf));/* might be not null terminated*/ - event.val= (type==GHOST_kEventKeyDown)?KM_PRESS:KM_RELEASE; + GHOST_TEventKeyData *kd = customdata; + event.type = convert_key(kd->key); + event.ascii = kd->ascii; + memcpy(event.utf8_buf, kd->utf8_buf, sizeof(event.utf8_buf)); /* might be not null terminated*/ + event.val = (type == GHOST_kEventKeyDown) ? KM_PRESS : KM_RELEASE; /* exclude arrow keys, esc, etc from text input */ - if (type==GHOST_kEventKeyUp) { - event.ascii= '\0'; + if (type == GHOST_kEventKeyUp) { + event.ascii = '\0'; /* ghost should do this already for key up */ if (event.utf8_buf[0]) { printf("%s: ghost on your platform is misbehaving, utf8 events on key up!\n", __func__); } - event.utf8_buf[0]= '\0'; + event.utf8_buf[0] = '\0'; } else { - if (event.ascii<32 && event.ascii > 0) - event.ascii= '\0'; - if (event.utf8_buf[0]<32 && event.utf8_buf[0] > 0) - event.utf8_buf[0]= '\0'; + if (event.ascii < 32 && event.ascii > 0) + event.ascii = '\0'; + if (event.utf8_buf[0] < 32 && event.utf8_buf[0] > 0) + event.utf8_buf[0] = '\0'; } if (event.utf8_buf[0]) { if (BLI_str_utf8_size(event.utf8_buf) == -1) { printf("%s: ghost detected an invalid unicode character '%d'!\n", __func__, (int)(unsigned char)event.utf8_buf[0]); - event.utf8_buf[0]= '\0'; + event.utf8_buf[0] = '\0'; } } /* modifiers */ /* assigning both first and second is strange - campbell */ - switch(event.type) { - case LEFTSHIFTKEY: case RIGHTSHIFTKEY: - event.shift = evt->shift = (event.val == KM_PRESS) ? - ((evt->ctrl || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : - FALSE; - break; - case LEFTCTRLKEY: case RIGHTCTRLKEY: - event.ctrl = evt->ctrl = (event.val == KM_PRESS) ? - ((evt->shift || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : - FALSE; - break; - case LEFTALTKEY: case RIGHTALTKEY: - event.alt = evt->alt = (event.val == KM_PRESS) ? - ((evt->ctrl || evt->shift || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : - FALSE; - break; - case OSKEY: - event.oskey = evt->oskey = (event.val == KM_PRESS) ? - ((evt->ctrl || evt->alt || evt->shift) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : - FALSE; - break; - default: - 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) - event.keymodifier= evt->keymodifier= 0; - break; + switch (event.type) { + case LEFTSHIFTKEY: case RIGHTSHIFTKEY: + event.shift = evt->shift = (event.val == KM_PRESS) ? + ((evt->ctrl || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : + FALSE; + break; + case LEFTCTRLKEY: case RIGHTCTRLKEY: + event.ctrl = evt->ctrl = (event.val == KM_PRESS) ? + ((evt->shift || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : + FALSE; + break; + case LEFTALTKEY: case RIGHTALTKEY: + event.alt = evt->alt = (event.val == KM_PRESS) ? + ((evt->ctrl || evt->shift || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : + FALSE; + break; + case OSKEY: + event.oskey = evt->oskey = (event.val == KM_PRESS) ? + ((evt->ctrl || evt->alt || evt->shift) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : + FALSE; + break; + default: + 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) + event.keymodifier = evt->keymodifier = 0; + break; } /* this case happens on some systems that on holding a key pressed, @@ -2804,39 +2806,39 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U * 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) - event.keymodifier= 0; + 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) - event.keymodifier= 0; + event.keymodifier = 0; /* if test_break set, it catches this. XXX Keep global for now? */ - if (event.type==ESCKEY) - G.afbreek= 1; + if (event.type == ESCKEY) + G.afbreek = 1; wm_event_add(win, &event); break; } - case GHOST_kEventWheel: { - GHOST_TEventWheelData* wheelData = customdata; + case GHOST_kEventWheel: { + GHOST_TEventWheelData *wheelData = customdata; if (wheelData->z > 0) - event.type= WHEELUPMOUSE; + event.type = WHEELUPMOUSE; else - event.type= WHEELDOWNMOUSE; + event.type = WHEELDOWNMOUSE; - event.val= KM_PRESS; + event.val = KM_PRESS; wm_event_add(win, &event); break; } case GHOST_kEventTimer: { - event.type= TIMER; - event.custom= EVT_DATA_TIMER; - event.customdata= customdata; + event.type = TIMER; + event.custom = EVT_DATA_TIMER; + event.customdata = customdata; wm_event_add(win, &event); break; @@ -2853,7 +2855,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U } case GHOST_kEventNDOFButton: { - GHOST_TEventNDOFButtonData* e = customdata; + GHOST_TEventNDOFButtonData *e = customdata; event.type = NDOF_BUTTON_NONE + e->button; @@ -2864,7 +2866,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U case GHOST_kRelease: event.val = KM_RELEASE; break; - } + } event.custom = 0; event.customdata = NULL; @@ -2879,7 +2881,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U break; case GHOST_kEventWindowDeactivate: { - event.type= WINDEACTIVATE; + event.type = WINDEACTIVATE; wm_event_add(win, &event); break; diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index db75c789b06..763f1e3b11b 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -28,9 +28,9 @@ */ - /* placed up here because of crappy - * winsock stuff. - */ +/* placed up here because of crappy + * winsock stuff. + */ #include <stddef.h> #include <string.h> #include <errno.h> @@ -131,20 +131,20 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist) wmWindowManager *wm; wmWindow *win, *active_win; - *wmlist= G.main->wm; - G.main->wm.first= G.main->wm.last= NULL; + *wmlist = G.main->wm; + G.main->wm.first = G.main->wm.last = NULL; active_win = CTX_wm_window(C); /* 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 */ + CTX_wm_window_set(C, win); /* needed by operator close callbacks */ WM_event_remove_handlers(C, &win->handlers); WM_event_remove_handlers(C, &win->modalhandlers); ED_screen_exit(C, win, win->screen); @@ -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 (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,29 +194,29 @@ 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) { - bScreen *screen= 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) - win->screen= screen; + if (screen->winid == 0) + win->screen = screen; else - win->screen= ED_screen_duplicate(win, screen); + win->screen = ED_screen_duplicate(win, screen); - BLI_strncpy(win->screenname, win->screen->id.name+2, sizeof(win->screenname)); - win->screen->winid= win->winid; + BLI_strncpy(win->screenname, win->screen->id.name + 2, sizeof(win->screenname)); + win->screen->winid = win->winid; } } } - G.main->wm= *oldwmlist; + G.main->wm = *oldwmlist; /* screens were read from file! */ ED_screens_initialize(G.main->wm.first); @@ -224,47 +224,47 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist) else { /* what if old was 3, and loaded 1? */ /* this code could move to setup_appdata */ - oldwm= oldwmlist->first; - wm= G.main->wm.first; + oldwm = oldwmlist->first; + wm = G.main->wm.first; /* preserve key configurations in new wm, to preserve their keymaps */ - wm->keyconfigs= oldwm->keyconfigs; - wm->addonconf= oldwm->addonconf; - wm->defaultconf= oldwm->defaultconf; - wm->userconf= oldwm->userconf; + wm->keyconfigs = oldwm->keyconfigs; + wm->addonconf = oldwm->addonconf; + wm->defaultconf = oldwm->defaultconf; + wm->userconf = oldwm->userconf; - oldwm->keyconfigs.first= oldwm->keyconfigs.last= NULL; - oldwm->addonconf= NULL; - oldwm->defaultconf= NULL; - oldwm->userconf= NULL; + oldwm->keyconfigs.first = oldwm->keyconfigs.last = NULL; + oldwm->addonconf = NULL; + oldwm->defaultconf = NULL; + oldwm->userconf = NULL; /* ensure making new keymaps and set space types */ - wm->initialized= 0; - wm->winactive= NULL; + wm->initialized = 0; + 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 ) { - win->ghostwin= oldwin->ghostwin; - win->active= oldwin->active; + if (oldwin->winid == win->winid) { + win->ghostwin = oldwin->ghostwin; + win->active = oldwin->active; if (win->active) - wm->winactive= win; + wm->winactive = win; if (!G.background) /* file loading in background mode still calls this */ - GHOST_SetWindowUserData(win->ghostwin, win); /* pointer back */ + GHOST_SetWindowUserData(win->ghostwin, win); /* pointer back */ - oldwin->ghostwin= NULL; + oldwin->ghostwin = NULL; - win->eventstate= oldwin->eventstate; - oldwin->eventstate= NULL; + win->eventstate = oldwin->eventstate; + oldwin->eventstate = NULL; /* ensure proper screen rescaling */ - win->sizex= oldwin->sizex; - win->sizey= oldwin->sizey; - win->posx= oldwin->posx; - win->posy= oldwin->posy; + win->sizex = oldwin->sizex; + win->sizey = oldwin->sizey; + win->posx = oldwin->posx; + win->posy = oldwin->posy; } } } @@ -281,14 +281,14 @@ 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; - else 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 ((U.flag & USER_SCRIPT_AUTOEXEC_DISABLE) == 0) G.f |= G_SCRIPT_AUTOEXEC; - else G.f &= ~G_SCRIPT_AUTOEXEC; + else G.f &= ~G_SCRIPT_AUTOEXEC; } /* update tempdir from user preferences */ @@ -298,11 +298,11 @@ static void wm_init_userdef(bContext *C) /* return codes */ -#define BKE_READ_EXOTIC_FAIL_PATH -3 /* file format is not supported */ -#define BKE_READ_EXOTIC_FAIL_FORMAT -2 /* file format is not supported */ -#define BKE_READ_EXOTIC_FAIL_OPEN -1 /* Can't open the file */ -#define BKE_READ_EXOTIC_OK_BLEND 0 /* .blend file */ -#define BKE_READ_EXOTIC_OK_OTHER 1 /* other supported formats */ +#define BKE_READ_EXOTIC_FAIL_PATH -3 /* file format is not supported */ +#define BKE_READ_EXOTIC_FAIL_FORMAT -2 /* file format is not supported */ +#define BKE_READ_EXOTIC_FAIL_OPEN -1 /* Can't open the file */ +#define BKE_READ_EXOTIC_OK_BLEND 0 /* .blend file */ +#define BKE_READ_EXOTIC_OK_OTHER 1 /* other supported formats */ /* intended to check for non-blender formats but for now it only reads blends */ @@ -315,32 +315,32 @@ static int wm_read_exotic(Scene *UNUSED(scene), const char *name) // make sure we're not trying to read a directory.... - len= strlen(name); - if (ELEM(name[len-1], '/', '\\')) { - retval= BKE_READ_EXOTIC_FAIL_PATH; + len = strlen(name); + if (ELEM(name[len - 1], '/', '\\')) { + retval = BKE_READ_EXOTIC_FAIL_PATH; } else { - gzfile = BLI_gzopen(name,"rb"); + gzfile = BLI_gzopen(name, "rb"); if (gzfile == NULL) { - retval= BKE_READ_EXOTIC_FAIL_OPEN; + retval = BKE_READ_EXOTIC_FAIL_OPEN; } else { - len= gzread(gzfile, header, sizeof(header)); + len = gzread(gzfile, header, sizeof(header)); gzclose(gzfile); if (len == sizeof(header) && strncmp(header, "BLENDER", 7) == 0) { - retval= BKE_READ_EXOTIC_OK_BLEND; + retval = BKE_READ_EXOTIC_OK_BLEND; } else { //XXX waitcursor(1); -#if 0 /* historic stuff - no longer used */ +#if 0 /* historic stuff - no longer used */ if (is_foo_format(name)) { read_foo(name); - retval= BKE_READ_EXOTIC_OK_OTHER; + retval = BKE_READ_EXOTIC_OK_OTHER; } else #endif { - retval= BKE_READ_EXOTIC_FAIL_FORMAT; + retval = BKE_READ_EXOTIC_FAIL_FORMAT; } //XXX waitcursor(0); } @@ -364,25 +364,25 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports) /* first try to append data from exotic file formats... */ /* it throws error box when file doesn't exist and returns -1 */ /* note; it should set some error message somewhere... (ton) */ - retval= wm_read_exotic(CTX_data_scene(C), filepath); + retval = wm_read_exotic(CTX_data_scene(C), filepath); /* we didn't succeed, now try to read Blender file */ if (retval == BKE_READ_EXOTIC_OK_BLEND) { - int G_f= G.f; + int G_f = G.f; ListBase wmbase; /* put aside screens to match with persistent windows later */ /* also exit screens and editors */ wm_window_match_init(C, &wmbase); - retval= BKE_read_file(C, filepath, reports); + retval = BKE_read_file(C, filepath, reports); G.save_over = 1; /* 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) { - const int flags_keep= (G_SCRIPT_AUTOEXEC | G_SCRIPT_OVERRIDE_PREF); - G.f= (G.f & ~flags_keep) | (G_f & flags_keep); + const int flags_keep = (G_SCRIPT_AUTOEXEC | G_SCRIPT_OVERRIDE_PREF); + G.f = (G.f & ~flags_keep) | (G_f & flags_keep); } /* match the read WM with current WM */ @@ -403,7 +403,7 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports) } - WM_event_add_notifier(C, NC_WM|ND_FILEREAD, NULL); + WM_event_add_notifier(C, NC_WM | ND_FILEREAD, NULL); // refresh_interface_font(); CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first); @@ -434,14 +434,14 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports) /* TODO, make this show in header info window */ { Scene *sce; - for (sce= G.main->scene.first; sce; sce= sce->id.next) { + for (sce = G.main->scene.first; sce; sce = sce->id.next) { if (sce->r.engine[0] && BLI_findstring(&R_engines, sce->r.engine, offsetof(RenderEngineType, idname)) == NULL) { BKE_reportf(reports, RPT_WARNING, "Engine not available: '%s' for scene: %s, " "an addon may need to be installed or enabled", - sce->r.engine, sce->id.name+2); + sce->r.engine, sce->id.name + 2); } } } @@ -449,13 +449,13 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports) // XXX undo_editmode_clear(); BKE_reset_undo(); - BKE_write_undo(C, "original"); /* save current state */ + BKE_write_undo(C, "original"); /* save current state */ } else if (retval == BKE_READ_EXOTIC_OK_OTHER) BKE_write_undo(C, "Import file"); 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")); + errno ? strerror(errno) : IFACE_("Unable to open the file")); } else if (retval == BKE_READ_EXOTIC_FAIL_FORMAT) { BKE_reportf(reports, RPT_ERROR, IFACE_("File format is not supported in file: \"%s\"."), filepath); @@ -480,7 +480,7 @@ int WM_read_homefile(bContext *C, ReportList *UNUSED(reports), short from_memory { ListBase wmbase; char tstr[FILE_MAX]; - int success= 0; + int success = 0; free_ttfont(); /* still weird... what does it here? */ @@ -505,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) { - printf("\nError: No valid "STRINGIFY(BLENDER_STARTUP_FILE)", fall back to built-in default.\n\n"); + 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); @@ -532,21 +532,21 @@ int WM_read_homefile(bContext *C, ReportList *UNUSED(reports), short from_memory wm_window_match_do(C, &wmbase); WM_check(C); /* opens window(s), checks keymaps */ - G.main->name[0]= '\0'; + G.main->name[0] = '\0'; /* When loading factory settings, the reset solid OpenGL lights need to be applied. */ if (!G.background) GPU_default_lights(); /* XXX */ - G.save_over = 0; // start with save preference untitled.blend - G.fileflags &= ~G_FILE_AUTOPLAY; /* disable autoplay in startup.blend... */ + G.save_over = 0; // start with save preference untitled.blend + G.fileflags &= ~G_FILE_AUTOPLAY; /* disable autoplay in startup.blend... */ // mainwindow_set_filename_to_title(""); // empty string re-initializes title to "Blender" // refresh_interface_font(); // undo_editmode_clear(); BKE_reset_undo(); - BKE_write_undo(C, "original"); /* save current state */ + BKE_write_undo(C, "original"); /* save current state */ ED_editors_init(C); DAG_on_visible_update(CTX_data_main(C), TRUE); @@ -562,7 +562,7 @@ int WM_read_homefile(bContext *C, ReportList *UNUSED(reports), short from_memory } #endif - WM_event_add_notifier(C, NC_WM|ND_FILEREAD, NULL); + WM_event_add_notifier(C, NC_WM | ND_FILEREAD, NULL); /* in background mode the scene will stay NULL */ if (!G.background) { @@ -574,7 +574,7 @@ int WM_read_homefile(bContext *C, ReportList *UNUSED(reports), short from_memory int WM_read_homefile_exec(bContext *C, wmOperator *op) { - int from_memory= strcmp(op->type->idname, "WM_OT_read_factory_settings") == 0; + int from_memory = strcmp(op->type->idname, "WM_OT_read_factory_settings") == 0; return WM_read_homefile(C, op->reports, from_memory) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } @@ -591,15 +591,15 @@ void WM_read_history(void) BLI_make_file_string("/", name, cfgdir, BLENDER_HISTORY_FILE); - lines= BLI_file_read_as_lines(name); + lines = BLI_file_read_as_lines(name); G.recent_files.first = G.recent_files.last = NULL; /* read list of recent opened files from recent-files.txt to memory */ - for (l= lines, num= 0; l && (num<U.recent_files); l= l->next) { + for (l = lines, num = 0; l && (num < U.recent_files); l = l->next) { line = l->link; if (line[0] && BLI_exists(line)) { - recent = (RecentFile*)MEM_mallocN(sizeof(RecentFile),"RecentFile"); + recent = (RecentFile *)MEM_mallocN(sizeof(RecentFile), "RecentFile"); BLI_addtail(&(G.recent_files), recent); recent->filepath = BLI_strdup(line); num++; @@ -627,21 +627,21 @@ static void write_history(void) 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)) { - fp= BLI_fopen(name, "w"); + 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 */ - recent = (RecentFile*)MEM_mallocN(sizeof(RecentFile),"RecentFile"); + recent = (RecentFile *)MEM_mallocN(sizeof(RecentFile), "RecentFile"); recent->filepath = BLI_strdup(G.main->name); BLI_addhead(&(G.recent_files), recent); /* write current file to recent-files.txt */ fprintf(fp, "%s\n", recent->filepath); recent = recent->next; - i=1; + i = 1; /* write rest of recent opened files to recent-files.txt */ - while ((i<U.recent_files) && (recent)) { + while ((i < U.recent_files) && (recent)) { /* this prevents to have duplicities in list */ - if (BLI_path_cmp(recent->filepath, G.main->name)!=0) { + if (BLI_path_cmp(recent->filepath, G.main->name) != 0) { fprintf(fp, "%s\n", recent->filepath); recent = recent->next; } @@ -666,21 +666,21 @@ static ImBuf *blend_file_thumb(Scene *scene, int **thumb_pt) /* will be scaled down, but gives some nice oversampling */ ImBuf *ibuf; int *thumb; - char err_out[256]= "unknown"; + char err_out[256] = "unknown"; - *thumb_pt= NULL; + *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 */ - ibuf= ED_view3d_draw_offscreen_imbuf_simple(scene, scene->camera, - BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2, - IB_rect, OB_SOLID, FALSE, err_out); + ibuf = ED_view3d_draw_offscreen_imbuf_simple(scene, scene->camera, + BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2, + IB_rect, OB_SOLID, FALSE, err_out); if (ibuf) { - float aspect= (scene->r.xsch*scene->r.xasp) / (scene->r.ysch*scene->r.yasp); + float aspect = (scene->r.xsch * scene->r.xasp) / (scene->r.ysch * scene->r.yasp); /* dirty oversampling */ IMB_scaleImBuf(ibuf, BLEN_THUMB_SIZE, BLEN_THUMB_SIZE); @@ -689,7 +689,7 @@ static ImBuf *blend_file_thumb(Scene *scene, int **thumb_pt) IMB_overlayblend_thumb(ibuf->rect, ibuf->x, ibuf->y, aspect); /* first write into thumb buffer */ - thumb= MEM_mallocN(((2 + (BLEN_THUMB_SIZE * BLEN_THUMB_SIZE))) * sizeof(int), "write_file thumb"); + thumb = MEM_mallocN(((2 + (BLEN_THUMB_SIZE * BLEN_THUMB_SIZE))) * sizeof(int), "write_file thumb"); thumb[0] = BLEN_THUMB_SIZE; thumb[1] = BLEN_THUMB_SIZE; @@ -699,11 +699,11 @@ static ImBuf *blend_file_thumb(Scene *scene, int **thumb_pt) else { /* '*thumb_pt' needs to stay NULL to prevent a bad thumbnail from being handled */ fprintf(stderr, "blend_file_thumb failed to create thumbnail: %s\n", err_out); - thumb= NULL; + thumb = NULL; } /* must be freed by caller */ - *thumb_pt= thumb; + *thumb_pt = thumb; return ibuf; } @@ -732,8 +732,8 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re int len; char filepath[FILE_MAX]; - int *thumb= NULL; - ImBuf *ibuf_thumb= NULL; + int *thumb = NULL; + ImBuf *ibuf_thumb = NULL; len = strlen(target); @@ -752,7 +752,7 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re /* don't use 'target' anymore */ /* send the OnSave event */ - for (li= G.main->library.first; li; li= li->id.next) { + for (li = G.main->library.first; li; li = li->id.next) { if (BLI_path_cmp(li->filepath, filepath) == 0) { BKE_reportf(reports, RPT_ERROR, "Can't overwrite used library '%.240s'", filepath); return -1; @@ -762,7 +762,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) { - ibuf_thumb= blend_file_thumb(CTX_data_scene(C), &thumb); + ibuf_thumb = blend_file_thumb(CTX_data_scene(C), &thumb); } BLI_exec_cb(G.main, NULL, BLI_CB_EVT_SAVE_PRE); @@ -784,7 +784,7 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re if (BLO_write_file(CTX_data_main(C), filepath, fileflags, reports, thumb)) { if (!copy) { G.relbase_valid = 1; - BLI_strncpy(G.main->name, filepath, sizeof(G.main->name)); /* is guaranteed current file */ + BLI_strncpy(G.main->name, filepath, sizeof(G.main->name)); /* is guaranteed current file */ G.save_over = 1; /* disable untitled.blend convention */ } @@ -804,7 +804,7 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re /* run this function after because the file cant be written before the blend is */ if (ibuf_thumb) { - ibuf_thumb= IMB_thumb_create(filepath, THB_NORMAL, THB_SOURCE_BLEND, ibuf_thumb); + ibuf_thumb = IMB_thumb_create(filepath, THB_NORMAL, THB_SOURCE_BLEND, ibuf_thumb); IMB_freeImBuf(ibuf_thumb); } @@ -826,8 +826,8 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re /* operator entry */ int WM_write_homefile(bContext *C, wmOperator *op) { - wmWindowManager *wm= CTX_wm_manager(C); - wmWindow *win= CTX_wm_window(C); + wmWindowManager *wm = CTX_wm_manager(C); + wmWindow *win = CTX_wm_window(C); char filepath[FILE_MAX]; int fileflags; @@ -851,7 +851,7 @@ int WM_write_homefile(bContext *C, wmOperator *op) printf("ok\n"); - G.save_over= 0; + G.save_over = 0; return OPERATOR_FINISHED; } @@ -891,7 +891,7 @@ void WM_autosave_init(wmWindowManager *wm) wm_autosave_timer_ended(wm); if (U.flag & USER_AUTOSAVE) - wm->autosavetimer= WM_event_add_timer(wm, NULL, TIMERAUTOSAVE, U.savetime*60.0); + wm->autosavetimer = WM_event_add_timer(wm, NULL, TIMERAUTOSAVE, U.savetime * 60.0); } void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(wt)) @@ -904,10 +904,10 @@ 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) { + 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); + wm->autosavetimer = WM_event_add_timer(wm, NULL, TIMERAUTOSAVE, 10.0); return; } } @@ -916,20 +916,20 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w wm_autosave_location(filepath); /* force save as regular blend file */ - fileflags = G.fileflags & ~(G_FILE_COMPRESS|G_FILE_AUTOPLAY |G_FILE_LOCK|G_FILE_SIGN|G_FILE_HISTORY); + fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_AUTOPLAY | G_FILE_LOCK | G_FILE_SIGN | G_FILE_HISTORY); /* no error reporting to console */ BLO_write_file(CTX_data_main(C), filepath, fileflags, NULL, NULL); /* do timer after file write, just in case file write takes a long time */ - wm->autosavetimer= WM_event_add_timer(wm, NULL, TIMERAUTOSAVE, U.savetime*60.0); + wm->autosavetimer = WM_event_add_timer(wm, NULL, TIMERAUTOSAVE, U.savetime * 60.0); } void wm_autosave_timer_ended(wmWindowManager *wm) { if (wm->autosavetimer) { WM_event_remove_timer(wm, NULL, wm->autosavetimer); - wm->autosavetimer= NULL; + wm->autosavetimer = NULL; } } diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index a2630b5c6e1..593d1b35abe 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -38,7 +38,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" -#include "BLI_scanfill.h" /* lasso tessellation */ +#include "BLI_scanfill.h" /* lasso tessellation */ #include "BLI_utildefines.h" #include "BKE_context.h" @@ -60,32 +60,32 @@ /* context checked on having screen, window and area */ wmGesture *WM_gesture_new(bContext *C, wmEvent *event, int type) { - wmGesture *gesture= MEM_callocN(sizeof(wmGesture), "new gesture"); - wmWindow *window= CTX_wm_window(C); - ARegion *ar= CTX_wm_region(C); + wmGesture *gesture = MEM_callocN(sizeof(wmGesture), "new gesture"); + wmWindow *window = CTX_wm_window(C); + ARegion *ar = CTX_wm_region(C); int sx, sy; BLI_addtail(&window->gesture, gesture); - gesture->type= type; - gesture->event_type= event->type; - gesture->swinid= ar->swinid; /* means only in area-region context! */ + gesture->type = type; + gesture->event_type = event->type; + gesture->swinid = ar->swinid; /* means only in area-region context! */ wm_subwindow_getorigin(window, gesture->swinid, &sx, &sy); if (ELEM5(type, WM_GESTURE_RECT, WM_GESTURE_CROSS_RECT, WM_GESTURE_TWEAK, - WM_GESTURE_CIRCLE, WM_GESTURE_STRAIGHTLINE)) + WM_GESTURE_CIRCLE, WM_GESTURE_STRAIGHTLINE)) { - rcti *rect= MEM_callocN(sizeof(rcti), "gesture rect new"); + rcti *rect = MEM_callocN(sizeof(rcti), "gesture rect new"); - gesture->customdata= rect; + 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 + rect->xmax = 25; // XXX temp #endif } else { @@ -95,10 +95,10 @@ wmGesture *WM_gesture_new(bContext *C, wmEvent *event, int type) } else if (ELEM(type, WM_GESTURE_LINES, WM_GESTURE_LASSO)) { short *lasso; - gesture->customdata= lasso= MEM_callocN(2*sizeof(short)*WM_LASSO_MIN_POINTS, "lasso points"); + gesture->customdata = lasso = MEM_callocN(2 * sizeof(short) * WM_LASSO_MIN_POINTS, "lasso points"); lasso[0] = event->x - sx; lasso[1] = event->y - sy; - gesture->points= 1; + gesture->points = 1; gesture->size = WM_LASSO_MIN_POINTS; } @@ -107,10 +107,10 @@ wmGesture *WM_gesture_new(bContext *C, wmEvent *event, int type) void WM_gesture_end(bContext *C, wmGesture *gesture) { - wmWindow *win= CTX_wm_window(C); + wmWindow *win = CTX_wm_window(C); - if (win->tweak==gesture) - win->tweak= NULL; + if (win->tweak == gesture) + win->tweak = NULL; BLI_remlink(&win->gesture, gesture); MEM_freeN(gesture->customdata); MEM_freeN(gesture); @@ -118,7 +118,7 @@ void WM_gesture_end(bContext *C, wmGesture *gesture) void WM_gestures_remove(bContext *C) { - wmWindow *win= CTX_wm_window(C); + wmWindow *win = CTX_wm_window(C); while (win->gesture.first) WM_gesture_end(C, win->gesture.first); @@ -128,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) { - rcti *rect= gesture->customdata; - int dx= rect->xmax - rect->xmin; - int dy= rect->ymax - rect->ymin; - 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 (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) { + 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 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; } @@ -166,7 +166,7 @@ int wm_gesture_evaluate(wmGesture *gesture) static void wm_gesture_draw_rect(wmGesture *gt) { - rcti *rect= (rcti *)gt->customdata; + rcti *rect = (rcti *)gt->customdata; glEnable(GL_BLEND); glColor4f(1.0, 1.0, 1.0, 0.05); @@ -190,7 +190,7 @@ static void wm_gesture_draw_rect(wmGesture *gt) static void wm_gesture_draw_line(wmGesture *gt) { - rcti *rect= (rcti *)gt->customdata; + rcti *rect = (rcti *)gt->customdata; glEnable(GL_LINE_STIPPLE); glColor3ub(96, 96, 96); @@ -206,22 +206,22 @@ static void wm_gesture_draw_line(wmGesture *gt) static void wm_gesture_draw_circle(wmGesture *gt) { - rcti *rect= (rcti *)gt->customdata; + rcti *rect = (rcti *)gt->customdata; glTranslatef((float)rect->xmin, (float)rect->ymin, 0.0f); glEnable(GL_BLEND); glColor4f(1.0, 1.0, 1.0, 0.05); - glutil_draw_filled_arc(0.0, M_PI*2.0, rect->xmax, 40); + glutil_draw_filled_arc(0.0, M_PI * 2.0, rect->xmax, 40); glDisable(GL_BLEND); glEnable(GL_LINE_STIPPLE); glColor3ub(96, 96, 96); glLineStipple(1, 0xAAAA); - glutil_draw_lined_arc(0.0, M_PI*2.0, rect->xmax, 40); + glutil_draw_lined_arc(0.0, M_PI * 2.0, rect->xmax, 40); glColor3ub(255, 255, 255); glLineStipple(1, 0x5555); - glutil_draw_lined_arc(0.0, M_PI*2.0, rect->xmax, 40); + glutil_draw_lined_arc(0.0, M_PI * 2.0, rect->xmax, 40); glDisable(GL_LINE_STIPPLE); glTranslatef((float)-rect->xmin, (float)-rect->ymin, 0.0f); @@ -230,24 +230,24 @@ static void wm_gesture_draw_circle(wmGesture *gt) static void draw_filled_lasso(wmGesture *gt) { - ScanFillVert *v=NULL, *lastv=NULL, *firstv=NULL; + ScanFillVert *v = NULL, *lastv = NULL, *firstv = NULL; ScanFillFace *efa; - short *lasso= (short *)gt->customdata; + short *lasso = (short *)gt->customdata; int i; BLI_begin_edgefill(); - for (i=0; i<gt->points; i++, lasso+=2) { + for (i = 0; i < gt->points; i++, lasso += 2) { float co[3]; - co[0]= (float)lasso[0]; - co[1]= (float)lasso[1]; - co[2]= 0.0f; + co[0] = (float)lasso[0]; + co[1] = (float)lasso[1]; + co[2] = 0.0f; v = BLI_addfillvert(co); if (lastv) /* e = */ /* UNUSED */ BLI_addfilledge(lastv, v); lastv = v; - if (firstv==NULL) firstv = v; + if (firstv == NULL) firstv = v; } /* highly unlikely this will fail, but could crash if (gt->points == 0) */ @@ -258,7 +258,7 @@ static void draw_filled_lasso(wmGesture *gt) glEnable(GL_BLEND); glColor4f(1.0, 1.0, 1.0, 0.05); glBegin(GL_TRIANGLES); - for (efa = fillfacebase.first; efa; efa=efa->next) { + for (efa = fillfacebase.first; efa; efa = efa->next) { glVertex2fv(efa->v1->co); glVertex2fv(efa->v2->co); glVertex2fv(efa->v3->co); @@ -272,7 +272,7 @@ static void draw_filled_lasso(wmGesture *gt) static void wm_gesture_draw_lasso(wmGesture *gt) { - short *lasso= (short *)gt->customdata; + short *lasso = (short *)gt->customdata; int i; draw_filled_lasso(gt); @@ -281,19 +281,19 @@ static void wm_gesture_draw_lasso(wmGesture *gt) glColor3ub(96, 96, 96); glLineStipple(1, 0xAAAA); glBegin(GL_LINE_STRIP); - for (i=0; i<gt->points; i++, lasso+=2) + for (i = 0; i < gt->points; i++, lasso += 2) glVertex2sv(lasso); - if (gt->type==WM_GESTURE_LASSO) + if (gt->type == WM_GESTURE_LASSO) glVertex2sv((short *)gt->customdata); glEnd(); glColor3ub(255, 255, 255); glLineStipple(1, 0x5555); glBegin(GL_LINE_STRIP); - lasso= (short *)gt->customdata; - for (i=0; i<gt->points; i++, lasso+=2) + lasso = (short *)gt->customdata; + for (i = 0; i < gt->points; i++, lasso += 2) glVertex2sv(lasso); - if (gt->type==WM_GESTURE_LASSO) + if (gt->type == WM_GESTURE_LASSO) glVertex2sv((short *)gt->customdata); glEnd(); @@ -303,7 +303,7 @@ static void wm_gesture_draw_lasso(wmGesture *gt) static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt) { - rcti *rect= (rcti *)gt->customdata; + rcti *rect = (rcti *)gt->customdata; glEnable(GL_LINE_STIPPLE); glColor3ub(96, 96, 96); @@ -321,41 +321,41 @@ static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt) /* called in wm_draw.c */ void wm_gesture_draw(wmWindow *win) { - wmGesture *gt= (wmGesture *)win->gesture.first; + 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) // 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); } } void wm_gesture_tag_redraw(bContext *C) { - wmWindow *win= CTX_wm_window(C); - bScreen *screen= CTX_wm_screen(C); - ARegion *ar= CTX_wm_region(C); + wmWindow *win = CTX_wm_window(C); + bScreen *screen = CTX_wm_screen(C); + ARegion *ar = CTX_wm_region(C); if (screen) - screen->do_draw_gesture= 1; + 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 0255a2249f5..a9f17359573 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -68,7 +68,7 @@ #include "BLI_utildefines.h" #include "RE_engine.h" -#include "RE_pipeline.h" /* RE_ free stuff */ +#include "RE_pipeline.h" /* RE_ free stuff */ #ifdef WITH_PYTHON #include "BPY_extern.h" @@ -125,20 +125,20 @@ int wm_start_with_console = 0; /* used in creator.c */ void WM_init(bContext *C, int argc, const char **argv) { if (!G.background) { - wm_ghost_init(C); /* note: it assigns C to ghost! */ + wm_ghost_init(C); /* note: it assigns C to ghost! */ wm_init_cursor_data(); } GHOST_CreateSystemPaths(); wm_operatortype_init(); WM_menutype_init(); - set_free_windowmanager_cb(wm_close_and_free); /* library.c */ + set_free_windowmanager_cb(wm_close_and_free); /* library.c */ set_blender_test_break_cb(wm_window_testbreak); /* blender.c */ DAG_editors_update_cb(ED_render_id_flush_update, ED_render_scene_update); /* depsgraph.c */ - ED_spacetypes_init(); /* editors/space_api/spacetype.c */ + ED_spacetypes_init(); /* editors/space_api/spacetype.c */ - ED_file_init(); /* for fsmenu */ + ED_file_init(); /* for fsmenu */ ED_init_node_butfuncs(); BLF_init(11, U.dpi); /* Please update source/gamengine/GamePlayer/GPG_ghost.cpp if you change this */ @@ -203,8 +203,8 @@ void WM_init(bContext *C, int argc, const char **argv) void WM_init_splash(bContext *C) { if ((U.uiflag & USER_SPLASH_DISABLE) == 0) { - wmWindowManager *wm= CTX_wm_manager(C); - wmWindow *prevwin= CTX_wm_window(C); + wmWindowManager *wm = CTX_wm_manager(C); + wmWindow *prevwin = CTX_wm_window(C); if (wm->windows.first) { CTX_wm_window_set(C, wm->windows.first); @@ -216,18 +216,18 @@ void WM_init_splash(bContext *C) int WM_init_game(bContext *C) { - wmWindowManager *wm= CTX_wm_manager(C); - wmWindow* win; + wmWindowManager *wm = CTX_wm_manager(C); + wmWindow *win; ScrArea *sa; - ARegion *ar= NULL; + ARegion *ar = NULL; - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); if (!scene) { // XXX, this should not be needed. Main *bmain = CTX_data_main(C); - scene= bmain->scene.first; + scene = bmain->scene.first; } win = wm->windows.first; @@ -237,7 +237,7 @@ int WM_init_game(bContext *C) CTX_wm_window_set(C, win); sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_VIEW3D, 0); - ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); // if we have a valid 3D view if (sa && ar) { @@ -251,7 +251,7 @@ int WM_init_game(bContext *C) 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) { + 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); @@ -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)); @@ -317,7 +317,7 @@ static void free_openrecent(void) /* bad stuff*/ - // XXX copy/paste buffer stuff... +// XXX copy/paste buffer stuff... extern void free_anim_copybuf(void); extern void free_anim_drivers_copybuf(void); extern void free_fmodifiers_copybuf(void); @@ -339,9 +339,9 @@ void WM_exit_ext(bContext *C, const short do_python) 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 */ + CTX_wm_window_set(C, win); /* needed by operator close callbacks */ WM_event_remove_handlers(C, &win->handlers); WM_event_remove_handlers(C, &win->modalhandlers); ED_screen_exit(C, win, win->screen); @@ -366,15 +366,15 @@ void WM_exit_ext(bContext *C, const short do_python) BKE_freecubetable(); - ED_preview_free_dbase(); /* frees a Main dbase, before free_blender! */ + ED_preview_free_dbase(); /* frees a Main dbase, before free_blender! */ if (C && CTX_wm_manager(C)) - wm_free_reports(C); /* before free_blender! - since the ListBases get freed there */ + wm_free_reports(C); /* before free_blender! - since the ListBases get freed there */ seq_free_clipboard(); /* sequencer.c */ BKE_tracking_free_clipboard(); - free_blender(); /* blender.c, does entire library and spacetypes */ + free_blender(); /* blender.c, does entire library and spacetypes */ // free_matcopybuf(); free_anim_copybuf(); free_anim_drivers_copybuf(); @@ -418,7 +418,7 @@ void WM_exit_ext(bContext *C, const short do_python) GPU_extensions_exit(); if (!G.background) { - BKE_undo_save_quit(); // saves quit.blend if global undo is on + BKE_undo_save_quit(); /* saves quit.blend if global undo is on */ } BKE_reset_undo(); @@ -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(); } @@ -458,5 +458,5 @@ void WM_exit_ext(bContext *C, const short do_python) void WM_exit(bContext *C) { WM_exit_ext(C, 1); - exit(G.afbreek==1); + exit(G.afbreek == 1); } diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index 4cef3f18e14..a55a8df3301 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -72,11 +72,11 @@ * * Stop job * - signal job to end - * on end, job will tag itself as sleeping + * on end, job will tag itself as sleeping * * Remove job * - signal job to end - * on end, job will remove itself + * on end, job will remove itself * * When job is done: * - it puts timer to sleep (or removes?) @@ -134,12 +134,12 @@ struct wmJob { */ static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const char *name) { - wmJob *steve, *found=NULL; + wmJob *steve, *found = NULL; - for (steve= wm->jobs.first; steve; steve= steve->next) - if (steve->owner==owner) { - found= steve; - if (name && strcmp(steve->name, name)==0) + for (steve = wm->jobs.first; steve; steve = steve->next) + if (steve->owner == owner) { + found = steve; + if (name && strcmp(steve->name, name) == 0) return steve; } @@ -153,15 +153,15 @@ static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const char *name) * when stopped it starts the new one */ wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char *name, int flag) { - wmJob *steve= wm_job_find(wm, owner, name); + wmJob *steve = wm_job_find(wm, owner, name); - if (steve==NULL) { - steve= MEM_callocN(sizeof(wmJob), "new job"); + if (steve == NULL) { + steve = MEM_callocN(sizeof(wmJob), "new job"); BLI_addtail(&wm->jobs, steve); - steve->win= win; - steve->owner= owner; - steve->flag= flag; + steve->win = win; + steve->owner = owner; + steve->flag = flag; BLI_strncpy(steve->name, name, sizeof(steve->name)); } @@ -173,8 +173,8 @@ int WM_jobs_test(wmWindowManager *wm, void *owner) { wmJob *steve; - 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) if (steve->running) return 1; return 0; @@ -182,7 +182,7 @@ int WM_jobs_test(wmWindowManager *wm, void *owner) float WM_jobs_progress(wmWindowManager *wm, void *owner) { - wmJob *steve= wm_job_find(wm, owner, NULL); + wmJob *steve = wm_job_find(wm, owner, NULL); if (steve && steve->flag & WM_JOB_PROGRESS) return steve->progress; @@ -192,7 +192,7 @@ float WM_jobs_progress(wmWindowManager *wm, void *owner) char *WM_jobs_name(wmWindowManager *wm, void *owner) { - wmJob *steve= wm_job_find(wm, owner, NULL); + wmJob *steve = wm_job_find(wm, owner, NULL); if (steve) return steve->name; @@ -205,7 +205,7 @@ int WM_jobs_is_running(wmJob *steve) return steve->running; } -void* WM_jobs_get_customdata(wmJob * steve) +void *WM_jobs_get_customdata(wmJob *steve) { if (!steve->customdata) { return steve->run_customdata; @@ -221,12 +221,12 @@ void WM_jobs_customdata(wmJob *steve, void *customdata, void (*free)(void *)) if (steve->customdata) steve->free(steve->customdata); - steve->customdata= customdata; - steve->free= free; + steve->customdata = customdata; + steve->free = free; if (steve->running) { /* signal job to end */ - steve->stop= 1; + steve->stop = 1; } } @@ -238,23 +238,23 @@ void WM_jobs_timer(wmJob *steve, double timestep, unsigned int note, unsigned in } void WM_jobs_callbacks(wmJob *steve, - void (*startjob)(void *, short *, short *, float *), - void (*initjob)(void *), - void (*update)(void *), - void (*endjob)(void *)) + void (*startjob)(void *, short *, short *, float *), + void (*initjob)(void *), + void (*update)(void *), + void (*endjob)(void *)) { - steve->startjob= startjob; - steve->initjob= initjob; - steve->update= update; - steve->endjob= endjob; + steve->startjob = startjob; + steve->initjob = initjob; + steve->update = update; + steve->endjob = endjob; } static void *do_job_thread(void *job_v) { - wmJob *steve= job_v; + wmJob *steve = job_v; steve->startjob(steve->run_customdata, &steve->stop, &steve->do_update, &steve->progress); - steve->ready= 1; + steve->ready = 1; return NULL; } @@ -263,41 +263,41 @@ static void *do_job_thread(void *job_v) static void wm_jobs_test_suspend_stop(wmWindowManager *wm, wmJob *test) { wmJob *steve; - int suspend= 0; + int suspend = 0; /* job added with suspend flag, we wait 1 timer step before activating it */ if (test->flag & WM_JOB_SUSPEND) { - suspend= 1; + 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 (0 == (steve->flag & WM_JOB_EXCL_RENDER)) continue; - suspend= 1; + suspend = 1; /* if this job has higher priority, stop others */ if (test->flag & WM_JOB_PRIORITY) { - steve->stop= 1; + steve->stop = 1; // printf("job stopped: %s\n", steve->name); } } } /* possible suspend ourselfs, waiting for other jobs, or de-suspend */ - test->suspended= suspend; + test->suspended = suspend; // if (suspend) printf("job suspended: %s\n", test->name); } @@ -307,7 +307,7 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *steve) { if (steve->running) { /* signal job to end and restart */ - steve->stop= 1; + steve->stop = 1; // printf("job started a running job, ending... %s\n", steve->name); } else { @@ -316,20 +316,20 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *steve) 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; - steve->free= NULL; - steve->customdata= NULL; - steve->running= 1; + steve->run_customdata = steve->customdata; + steve->run_free = steve->free; + steve->free = NULL; + steve->customdata = NULL; + steve->running = 1; if (steve->initjob) steve->initjob(steve->run_customdata); - steve->stop= 0; - steve->ready= 0; - steve->progress= 0.0; + steve->stop = 0; + steve->ready = 0; + steve->progress = 0.0; // printf("job started: %s\n", steve->name); @@ -338,8 +338,8 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *steve) } /* restarted job has timer already */ - if (steve->wt==NULL) - steve->wt= WM_event_add_timer(wm, steve->win, TIMERJOBS, steve->timestep); + if (steve->wt == NULL) + steve->wt = WM_event_add_timer(wm, steve->win, TIMERJOBS, steve->timestep); } else printf("job fails, not initialized\n"); } @@ -350,7 +350,7 @@ static void wm_jobs_kill_job(wmWindowManager *wm, wmJob *steve) { if (steve->running) { /* signal job to end */ - steve->stop= 1; + steve->stop = 1; BLI_end_threads(&steve->threads); if (steve->endjob) @@ -374,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); } @@ -384,10 +384,10 @@ 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) + for (steve = wm->jobs.first; steve; steve = steve->next) + if (steve->owner == owner || steve->startjob == startjob) if (steve->running) - steve->stop= 1; + steve->stop = 1; } /* actually terminate thread and job timer */ @@ -395,15 +395,15 @@ void WM_jobs_kill(wmWindowManager *wm, void *owner, void (*startjob)(void *, sho { wmJob *steve; - steve= wm->jobs.first; + steve = wm->jobs.first; while (steve) { - if (steve->owner==owner || steve->startjob==startjob) { - wmJob* bill = steve; - steve= steve->next; + if (steve->owner == owner || steve->startjob == startjob) { + wmJob *bill = steve; + steve = steve->next; wm_jobs_kill_job(wm, bill); } else { - steve= steve->next; + steve = steve->next; } } } @@ -414,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; } @@ -425,15 +425,15 @@ void wm_jobs_timer_ended(wmWindowManager *wm, wmTimer *wt) /* hardcoded to event TIMERJOBS */ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) { - wmJob *steve= wm->jobs.first, *stevenext; - float total_progress= 0.f; - float jobs_progress=0; + wmJob *steve = wm->jobs.first, *stevenext; + float total_progress = 0.f; + float jobs_progress = 0; - for (; steve; steve= stevenext) { - stevenext= steve->next; + for (; steve; steve = stevenext) { + stevenext = steve->next; - if (steve->wt==wt) { + if (steve->wt == wt) { /* running threads */ if (steve->threads.first) { @@ -446,8 +446,8 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) WM_event_add_notifier(C, steve->note, NULL); if (steve->flag & WM_JOB_PROGRESS) - WM_event_add_notifier(C, NC_WM|ND_JOB, NULL); - steve->do_update= 0; + WM_event_add_notifier(C, NC_WM | ND_JOB, NULL); + steve->do_update = 0; } if (steve->ready) { @@ -456,19 +456,19 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) /* free own data */ steve->run_free(steve->run_customdata); - steve->run_customdata= NULL; - steve->run_free= NULL; + steve->run_customdata = NULL; + steve->run_free = NULL; // if (steve->stop) printf("job ready but stopped %s\n", steve->name); // else printf("job finished %s\n", steve->name); - steve->running= 0; + steve->running = 0; BLI_end_threads(&steve->threads); if (steve->endnote) WM_event_add_notifier(C, steve->endnote, NULL); - WM_event_add_notifier(C, NC_WM|ND_JOB, NULL); + WM_event_add_notifier(C, NC_WM | ND_JOB, NULL); /* new job added for steve? */ if (steve->customdata) { @@ -477,7 +477,7 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) } else { WM_event_remove_timer(wm, steve->win, steve->wt); - steve->wt= NULL; + steve->wt = NULL; /* remove steve */ BLI_remlink(&wm->jobs, steve); @@ -520,7 +520,7 @@ int WM_jobs_has_running(wmWindowManager *wm) { wmJob *steve; - for (steve= wm->jobs.first; steve; steve= steve->next) + for (steve = wm->jobs.first; steve; steve = steve->next) if (steve->running) return 1; diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 8814a044901..ddbacc6b747 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -61,21 +61,21 @@ #include "wm_event_types.h" /******************************* Keymap Item ********************************** - * Item in a keymap, that maps from an event to an operator or modal map item */ +* Item in a keymap, that maps from an event to an operator or modal map item */ static wmKeyMapItem *wm_keymap_item_copy(wmKeyMapItem *kmi) { wmKeyMapItem *kmin = MEM_dupallocN(kmi); - kmin->prev= kmin->next= NULL; + kmin->prev = kmin->next = NULL; kmin->flag &= ~KMI_UPDATE; if (kmin->properties) { - kmin->ptr= MEM_callocN(sizeof(PointerRNA), "UserKeyMapItemPtr"); + kmin->ptr = MEM_callocN(sizeof(PointerRNA), "UserKeyMapItemPtr"); WM_operator_properties_create(kmin->ptr, kmin->idname); - kmin->properties= IDP_CopyProperty(kmin->properties); - kmin->ptr->data= kmin->properties; + kmin->properties = IDP_CopyProperty(kmin->properties); + kmin->ptr->data = kmin->properties; } return kmin; @@ -101,8 +101,8 @@ static int wm_keymap_item_equals_result(wmKeyMapItem *a, wmKeyMapItem *b) if (strcmp(a->idname, b->idname) != 0) return 0; - if (!((a->ptr==NULL && b->ptr==NULL) || - (a->ptr && b->ptr && IDP_EqualsProperties(a->ptr->data, b->ptr->data)))) + 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)) @@ -172,7 +172,7 @@ wmKeyConfig *WM_keyconfig_new(wmWindowManager *wm, const char *idname) { wmKeyConfig *keyconf; - keyconf= MEM_callocN(sizeof(wmKeyConfig), "wmKeyConfig"); + keyconf = MEM_callocN(sizeof(wmKeyConfig), "wmKeyConfig"); BLI_strncpy(keyconf->idname, idname, sizeof(keyconf->idname)); BLI_addtail(&wm->keyconfigs, keyconf); @@ -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; @@ -229,7 +229,7 @@ static wmKeyConfig *WM_keyconfig_active(wmWindowManager *wm) wmKeyConfig *keyconf; /* first try from preset */ - keyconf= wm_keyconfig_list_find(&wm->keyconfigs, U.keyconfigstr); + keyconf = wm_keyconfig_list_find(&wm->keyconfigs, U.keyconfigstr); if (keyconf) return keyconf; @@ -255,11 +255,11 @@ void WM_keyconfig_set_active(wmWindowManager *wm, const char *idname) static wmKeyMap *wm_keymap_new(const char *idname, int spaceid, int regionid) { - wmKeyMap *km= MEM_callocN(sizeof(struct wmKeyMap), "keymap list"); + wmKeyMap *km = MEM_callocN(sizeof(struct wmKeyMap), "keymap list"); BLI_strncpy(km->idname, idname, KMAP_MAX_NAME); - km->spaceid= spaceid; - km->regionid= regionid; + km->spaceid = spaceid; + km->regionid = regionid; return km; } @@ -270,18 +270,18 @@ static wmKeyMap *wm_keymap_copy(wmKeyMap *keymap) wmKeyMapItem *kmi, *kmin; wmKeyMapDiffItem *kmdi, *kmdin; - keymapn->modal_items= keymap->modal_items; - keymapn->poll= keymap->poll; - keymapn->items.first= keymapn->items.last= NULL; - keymapn->flag &= ~(KEYMAP_UPDATE|KEYMAP_EXPANDED); + keymapn->modal_items = keymap->modal_items; + keymapn->poll = keymap->poll; + keymapn->items.first = keymapn->items.last = NULL; + keymapn->flag &= ~(KEYMAP_UPDATE | KEYMAP_EXPANDED); - for (kmdi=keymap->diff_items.first; kmdi; kmdi=kmdi->next) { - kmdin= wm_keymap_diff_item_copy(kmdi); + 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) { - kmin= wm_keymap_item_copy(kmi); + 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); @@ -305,18 +305,18 @@ void WM_keymap_free(wmKeyMap *keymap) static void keymap_event_set(wmKeyMapItem *kmi, short type, short val, int modifier, short keymodifier) { - kmi->type= type; - kmi->val= val; - kmi->keymodifier= keymodifier; + kmi->type = type; + kmi->val = val; + kmi->keymodifier = keymodifier; if (modifier == KM_ANY) { - kmi->shift= kmi->ctrl= kmi->alt= kmi->oskey= KM_ANY; + kmi->shift = kmi->ctrl = kmi->alt = kmi->oskey = KM_ANY; } else { - kmi->shift= (modifier & KM_SHIFT) ? KM_MOD_FIRST : ((modifier & KM_SHIFT2) ? KM_MOD_SECOND : FALSE); - kmi->ctrl= (modifier & KM_CTRL) ? KM_MOD_FIRST : ((modifier & KM_CTRL2) ? KM_MOD_SECOND : FALSE); - kmi->alt= (modifier & KM_ALT) ? KM_MOD_FIRST : ((modifier & KM_ALT2) ? KM_MOD_SECOND : FALSE); - kmi->oskey= (modifier & KM_OSKEY) ? KM_MOD_FIRST : ((modifier & KM_OSKEY2) ? KM_MOD_SECOND : FALSE); + kmi->shift = (modifier & KM_SHIFT) ? KM_MOD_FIRST : ((modifier & KM_SHIFT2) ? KM_MOD_SECOND : FALSE); + kmi->ctrl = (modifier & KM_CTRL) ? KM_MOD_FIRST : ((modifier & KM_CTRL2) ? KM_MOD_SECOND : FALSE); + kmi->alt = (modifier & KM_ALT) ? KM_MOD_FIRST : ((modifier & KM_ALT2) ? KM_MOD_SECOND : FALSE); + kmi->oskey = (modifier & KM_OSKEY) ? KM_MOD_FIRST : ((modifier & KM_OSKEY2) ? KM_MOD_SECOND : FALSE); } } @@ -337,9 +337,9 @@ 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) + 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); @@ -402,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); @@ -413,7 +413,7 @@ static wmKeyMapItem *wm_keymap_find_item_equals(wmKeyMap *km, wmKeyMapItem *need { wmKeyMapItem *kmi; - for (kmi=km->items.first; kmi; kmi=kmi->next) + for (kmi = km->items.first; kmi; kmi = kmi->next) if (wm_keymap_item_equals(kmi, needle)) return kmi; @@ -424,7 +424,7 @@ static wmKeyMapItem *wm_keymap_find_item_equals_result(wmKeyMap *km, wmKeyMapIte { wmKeyMapItem *kmi; - for (kmi=km->items.first; kmi; kmi=kmi->next) + for (kmi = km->items.first; kmi; kmi = kmi->next) if (wm_keymap_item_equals_result(kmi, needle)) return kmi; @@ -436,7 +436,7 @@ 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) { @@ -467,7 +467,7 @@ static void wm_keymap_diff(wmKeyMap *diff_km, wmKeyMap *from_km, wmKeyMap *to_km } } - for (kmi=to_km->items.first; kmi; kmi=kmi->next) { + for (kmi = to_km->items.first; kmi; kmi = kmi->next) { if (kmi->id < 0) { /* add item */ kmdi = MEM_callocN(sizeof(wmKeyMapDiffItem), "wmKeyMapDiffItem"); @@ -482,7 +482,7 @@ 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) { @@ -527,7 +527,7 @@ 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) { - expanded = (km->flag & (KEYMAP_EXPANDED|KEYMAP_CHILDREN_EXPANDED)); + expanded = (km->flag & (KEYMAP_EXPANDED | KEYMAP_CHILDREN_EXPANDED)); WM_keymap_free(km); BLI_freelinkN(lb, km); } @@ -541,7 +541,7 @@ 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) orig_kmi = wm_keymap_find_item_equals_result(defaultmap, kmi); @@ -564,7 +564,7 @@ static wmKeyMap *wm_keymap_patch_update(ListBase *lb, wmKeyMap *defaultmap, wmKe /* tag as being user edited */ if (usermap) km->flag |= KEYMAP_USER_MODIFIED; - km->flag |= KEYMAP_USER|expanded; + km->flag |= KEYMAP_USER | expanded; /* apply user changes of diff keymap */ if (usermap && (usermap->flag & KEYMAP_DIFF)) @@ -596,7 +596,7 @@ 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 = wm_keymap_new(km->idname, km->spaceid, km->regionid); diffmap->flag |= KEYMAP_DIFF; if (defaultmap->flag & KEYMAP_MODAL) diffmap->flag |= KEYMAP_MODAL; @@ -628,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; @@ -638,10 +638,10 @@ wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int wmKeyMap *WM_keymap_find(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid) { - wmKeyMap *km= WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid); + wmKeyMap *km = WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid); - if (km==NULL) { - km= wm_keymap_new(idname, spaceid, regionid); + if (km == NULL) { + km = wm_keymap_new(idname, spaceid, regionid); BLI_addtail(&keyconf->keymaps, km); WM_keyconfig_update_tag(km, NULL); @@ -652,7 +652,7 @@ wmKeyMap *WM_keymap_find(wmKeyConfig *keyconf, const char *idname, int spaceid, wmKeyMap *WM_keymap_find_all(const bContext *C, const char *idname, int spaceid, int regionid) { - wmWindowManager *wm= CTX_wm_manager(C); + wmWindowManager *wm = CTX_wm_manager(C); return WM_keymap_list_find(&wm->userconf->keymaps, idname, spaceid, regionid); } @@ -663,14 +663,14 @@ wmKeyMap *WM_keymap_find_all(const bContext *C, const char *idname, int spaceid, wmKeyMap *WM_modalkeymap_add(wmKeyConfig *keyconf, const char *idname, EnumPropertyItem *items) { - wmKeyMap *km= WM_keymap_find(keyconf, idname, 0, 0); + wmKeyMap *km = WM_keymap_find(keyconf, idname, 0, 0); km->flag |= KEYMAP_MODAL; - km->modal_items= items; + km->modal_items = 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); + wmKeyMap *defaultkm = WM_keymap_list_find(&wm->defaultconf->keymaps, km->idname, 0, 0); if (defaultkm) { km->modal_items = defaultkm->modal_items; @@ -685,9 +685,9 @@ wmKeyMap *WM_modalkeymap_get(wmKeyConfig *keyconf, const char *idname) { wmKeyMap *km; - for (km= keyconf->keymaps.first; km; km= km->next) + for (km = keyconf->keymaps.first; km; km = km->next) if (km->flag & KEYMAP_MODAL) - if (0==strncmp(idname, km->idname, KMAP_MAX_NAME)) + if (0 == strncmp(idname, km->idname, KMAP_MAX_NAME)) break; return km; @@ -699,7 +699,7 @@ wmKeyMapItem *WM_modalkeymap_add_item(wmKeyMap *km, int type, int val, int modif wmKeyMapItem *kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry"); BLI_addtail(&km->items, kmi); - kmi->propvalue= value; + kmi->propvalue = value; keymap_event_set(kmi, type, val, modifier, keymodifier); @@ -712,7 +712,7 @@ wmKeyMapItem *WM_modalkeymap_add_item(wmKeyMap *km, int type, int val, int modif void WM_modalkeymap_assign(wmKeyMap *km, const char *opname) { - wmOperatorType *ot= WM_operatortype_find(opname, 0); + wmOperatorType *ot = WM_operatortype_find(opname, 0); if (ot) ot->modalkeymap = km; @@ -724,7 +724,7 @@ void WM_modalkeymap_assign(wmKeyMap *km, const char *opname) const char *WM_key_event_string(short type) { - const char *name= NULL; + const char *name = NULL; if (RNA_enum_name(event_type_items, (int)type, &name)) return name; @@ -735,12 +735,12 @@ char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len) { char buf[128]; - buf[0]= 0; + buf[0] = 0; if (kmi->shift == KM_ANY && - kmi->ctrl == KM_ANY && - kmi->alt == KM_ANY && - kmi->oskey == KM_ANY) { + kmi->ctrl == KM_ANY && + kmi->alt == KM_ANY && + kmi->oskey == KM_ANY) { strcat(buf, "Any "); } @@ -770,20 +770,20 @@ char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len) } static wmKeyMapItem *wm_keymap_item_find_handlers( - const bContext *C, ListBase *handlers, const char *opname, int UNUSED(opcontext), - IDProperty *properties, int compare_props, int hotkey, wmKeyMap **keymap_r) + const bContext *C, ListBase *handlers, const char *opname, int UNUSED(opcontext), + IDProperty *properties, int compare_props, int hotkey, wmKeyMap **keymap_r) { - wmWindowManager *wm= CTX_wm_manager(C); + wmWindowManager *wm = CTX_wm_manager(C); wmEventHandler *handler; wmKeyMap *keymap; wmKeyMapItem *kmi; /* find keymap item in handlers */ - for (handler=handlers->first; handler; handler=handler->next) { - keymap= WM_keymap_active(wm, handler->keymap); + 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 (hotkey) @@ -792,12 +792,12 @@ static wmKeyMapItem *wm_keymap_item_find_handlers( if (compare_props) { if (kmi->ptr && IDP_EqualsProperties(properties, kmi->ptr->data)) { - if (keymap_r) *keymap_r= keymap; + if (keymap_r) *keymap_r = keymap; return kmi; } } else { - if (keymap_r) *keymap_r= keymap; + if (keymap_r) *keymap_r = keymap; return kmi; } } @@ -806,54 +806,54 @@ 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; } static wmKeyMapItem *wm_keymap_item_find_props( - const bContext *C, const char *opname, int opcontext, - IDProperty *properties, int compare_props, int hotkey, wmKeyMap **keymap_r) + const bContext *C, const char *opname, int opcontext, + IDProperty *properties, int compare_props, int hotkey, wmKeyMap **keymap_r) { - wmWindow *win= CTX_wm_window(C); - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= CTX_wm_region(C); - wmKeyMapItem *found= NULL; + wmWindow *win = CTX_wm_window(C); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + wmKeyMapItem *found = NULL; /* look into multiple handler lists to find the item */ if (win) - found= wm_keymap_item_find_handlers(C, &win->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); + found = wm_keymap_item_find_handlers(C, &win->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); - if (sa && found==NULL) - found= wm_keymap_item_find_handlers(C, &sa->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); + 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 (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); + ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); if (ar) - found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); + 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)) { if (!(ar && ar->regiontype == RGN_TYPE_CHANNELS)) - ar= BKE_area_find_region_type(sa, RGN_TYPE_CHANNELS); + ar = BKE_area_find_region_type(sa, RGN_TYPE_CHANNELS); if (ar) - found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); + 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)) { if (!(ar && ar->regiontype == RGN_TYPE_PREVIEW)) - ar= BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW); + ar = BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW); if (ar) - found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); + found = wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); } else { if (ar) - found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); + found = wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); } } @@ -861,20 +861,20 @@ static wmKeyMapItem *wm_keymap_item_find_props( } static wmKeyMapItem *wm_keymap_item_find( - const bContext *C, const char *opname, int opcontext, - IDProperty *properties, const short hotkey, const short sloppy, wmKeyMap **keymap_r) + const bContext *C, const char *opname, int opcontext, + IDProperty *properties, const short hotkey, const short sloppy, wmKeyMap **keymap_r) { - wmKeyMapItem *found= wm_keymap_item_find_props(C, opname, opcontext, properties, 1, hotkey, keymap_r); + wmKeyMapItem *found = wm_keymap_item_find_props(C, opname, opcontext, properties, 1, hotkey, keymap_r); if (!found && sloppy) - found= wm_keymap_item_find_props(C, opname, opcontext, NULL, 0, hotkey, keymap_r); + found = wm_keymap_item_find_props(C, opname, opcontext, NULL, 0, hotkey, keymap_r); return found; } char *WM_key_event_operator_string( - const bContext *C, const char *opname, int opcontext, - IDProperty *properties, const short sloppy, char *str, int len) + const bContext *C, const char *opname, int opcontext, + IDProperty *properties, const short sloppy, char *str, int len) { wmKeyMapItem *kmi = wm_keymap_item_find(C, opname, opcontext, properties, 0, sloppy, NULL); @@ -887,8 +887,8 @@ char *WM_key_event_operator_string( } int WM_key_event_operator_id( - const bContext *C, const char *opname, int opcontext, - IDProperty *properties, int hotkey, wmKeyMap **keymap_r) + const bContext *C, const char *opname, int opcontext, + IDProperty *properties, int hotkey, wmKeyMap **keymap_r) { wmKeyMapItem *kmi = wm_keymap_item_find(C, opname, opcontext, properties, hotkey, TRUE, keymap_r); @@ -898,7 +898,7 @@ int WM_key_event_operator_id( return 0; } -int WM_keymap_item_compare(wmKeyMapItem *k1, wmKeyMapItem *k2) +int WM_keymap_item_compare(wmKeyMapItem *k1, wmKeyMapItem *k2) { int k1type, k2type; @@ -950,7 +950,7 @@ static int WM_KEYMAP_UPDATE = 0; void WM_keyconfig_update_tag(wmKeyMap *km, wmKeyMapItem *kmi) { /* quick tag to do delayed keymap updates */ - WM_KEYMAP_UPDATE= 1; + WM_KEYMAP_UPDATE = 1; if (km) km->flag |= KEYMAP_UPDATE; @@ -963,11 +963,11 @@ static int wm_keymap_test_and_clear_update(wmKeyMap *km) wmKeyMapItem *kmi; int update; - update= (km->flag & KEYMAP_UPDATE); + update = (km->flag & KEYMAP_UPDATE); km->flag &= ~KEYMAP_UPDATE; - for (kmi=km->items.first; kmi; kmi=kmi->next) { - update= update || (kmi->flag & KMI_UPDATE); + for (kmi = km->items.first; kmi; kmi = kmi->next) { + update = update || (kmi->flag & KMI_UPDATE); kmi->flag &= ~KMI_UPDATE; } @@ -976,12 +976,12 @@ static int wm_keymap_test_and_clear_update(wmKeyMap *km) static wmKeyMap *wm_keymap_preset(wmWindowManager *wm, wmKeyMap *km) { - wmKeyConfig *keyconf= WM_keyconfig_active(wm); + wmKeyConfig *keyconf = WM_keyconfig_active(wm); wmKeyMap *keymap; - keymap= WM_keymap_list_find(&keyconf->keymaps, km->idname, km->spaceid, km->regionid); + keymap = WM_keymap_list_find(&keyconf->keymaps, km->idname, km->spaceid, km->regionid); if (!keymap) - keymap= WM_keymap_list_find(&wm->defaultconf->keymaps, km->idname, km->spaceid, km->regionid); + keymap = WM_keymap_list_find(&wm->defaultconf->keymaps, km->idname, km->spaceid, km->regionid); return keymap; } @@ -999,27 +999,27 @@ void WM_keyconfig_update(wmWindowManager *wm) return; /* update operator properties for non-modal user keymaps */ - for (km=U.user_keymaps.first; km; km=km->next) { + 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) { + 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) 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)) { /* find keymaps */ - defaultmap= wm_keymap_preset(wm, km); - addonmap= WM_keymap_list_find(&wm->addonconf->keymaps, km->idname, km->spaceid, km->regionid); + defaultmap = wm_keymap_preset(wm, km); + addonmap = WM_keymap_list_find(&wm->addonconf->keymaps, km->idname, km->spaceid, km->regionid); /* diff */ if (defaultmap) @@ -1028,25 +1028,25 @@ void WM_keyconfig_update(wmWindowManager *wm) } /* 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); - usermap= WM_keymap_list_find(&U.user_keymaps, km->idname, km->spaceid, km->regionid); + defaultmap = wm_keymap_preset(wm, km); + addonmap = WM_keymap_list_find(&wm->addonconf->keymaps, km->idname, km->spaceid, km->regionid); + usermap = WM_keymap_list_find(&U.user_keymaps, km->idname, km->spaceid, km->regionid); /* add */ - kmn= wm_keymap_patch_update(&wm->userconf->keymaps, defaultmap, addonmap, usermap); + kmn = wm_keymap_patch_update(&wm->userconf->keymaps, defaultmap, addonmap, usermap); if (kmn) { - kmn->modal_items= km->modal_items; - kmn->poll= km->poll; + kmn->modal_items = km->modal_items; + kmn->poll = km->poll; } /* in case of old non-diff keymaps, force extra update to create diffs */ compat_update = compat_update || (usermap && !(usermap->flag & KEYMAP_DIFF)); } - WM_KEYMAP_UPDATE= 0; + WM_KEYMAP_UPDATE = 0; if (compat_update) { WM_keyconfig_update_tag(NULL, NULL); @@ -1067,7 +1067,7 @@ wmKeyMap *WM_keymap_active(wmWindowManager *wm, wmKeyMap *keymap) return NULL; /* first user defined keymaps */ - km= WM_keymap_list_find(&wm->userconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid); + km = WM_keymap_list_find(&wm->userconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid); if (km) return km; @@ -1088,8 +1088,8 @@ void WM_keymap_restore_item_to_default(bContext *C, wmKeyMap *keymap, wmKeyMapIt 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); + defaultmap = wm_keymap_preset(wm, keymap); + addonmap = WM_keymap_list_find(&wm->addonconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid); if (addonmap) { defaultmap = wm_keymap_copy(defaultmap); @@ -1110,11 +1110,11 @@ void WM_keymap_restore_item_to_default(bContext *C, wmKeyMap *keymap, wmKeyMapIt if (kmi->properties) { IDP_FreeProperty(kmi->properties); MEM_freeN(kmi->properties); - kmi->properties= NULL; + kmi->properties = NULL; } - kmi->properties= IDP_CopyProperty(orig->properties); - kmi->ptr->data= kmi->properties; + kmi->properties = IDP_CopyProperty(orig->properties); + kmi->ptr->data = kmi->properties; } kmi->propvalue = orig->propvalue; @@ -1143,7 +1143,7 @@ void WM_keymap_restore_to_default(wmKeyMap *keymap, bContext *C) wmKeyMap *usermap; /* remove keymap from U.user_keymaps and update */ - usermap= WM_keymap_list_find(&U.user_keymaps, keymap->idname, keymap->spaceid, keymap->regionid); + usermap = WM_keymap_list_find(&U.user_keymaps, keymap->idname, keymap->spaceid, keymap->regionid); if (usermap) { WM_keymap_free(usermap); @@ -1158,7 +1158,7 @@ wmKeyMapItem *WM_keymap_item_find_id(wmKeyMap *keymap, int id) { wmKeyMapItem *kmi; - for (kmi=keymap->items.first; kmi; kmi=kmi->next) { + for (kmi = keymap->items.first; kmi; kmi = kmi->next) { if (kmi->id == id) { return kmi; } @@ -1171,7 +1171,7 @@ wmKeyMapItem *WM_keymap_item_find_id(wmKeyMap *keymap, int id) /* Needs to be kept up to date with Keymap and Operator naming */ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) { - wmKeyMap *km=NULL; + wmKeyMap *km = NULL; SpaceLink *sl = CTX_wm_space_data(C); /* Window */ @@ -1206,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); } } @@ -1214,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); } } @@ -1225,7 +1225,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) km = WM_keymap_find_all(C, "Pose", 0, 0); } else if (strstr(opname, "SCULPT_OT")) { - switch(CTX_data_mode_enum(C)) { + switch (CTX_data_mode_enum(C)) { case OB_MODE_SCULPT: km = WM_keymap_find_all(C, "Sculpt", 0, 0); break; @@ -1238,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); } } @@ -1254,7 +1254,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) else if (strstr(opname, "PAINT_OT")) { /* check for relevant mode */ - switch(CTX_data_mode_enum(C)) { + switch (CTX_data_mode_enum(C)) { case OB_MODE_WEIGHT_PAINT: km = WM_keymap_find_all(C, "Weight Paint", 0, 0); break; @@ -1331,7 +1331,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) else if (strstr(opname, "TRANSFORM_OT")) { /* check for relevant editor */ - switch(sl->spacetype) { + switch (sl->spacetype) { case SPACE_VIEW3D: km = WM_keymap_find_all(C, "3D View", sl->spacetype, 0); break; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index a973eb4fe2c..94de4293a6e 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -101,7 +101,7 @@ #include "wm_subwindow.h" #include "wm_window.h" -static GHash *global_ops_hash= NULL; +static GHash *global_ops_hash = NULL; /* ************ operator API, exported ********** */ @@ -115,7 +115,7 @@ wmOperatorType *WM_operatortype_find(const char *idname, int quiet) char idname_bl[OP_MAX_TYPENAME]; WM_operator_bl_idname(idname_bl, idname); - ot= BLI_ghash_lookup(global_ops_hash, idname_bl); + ot = BLI_ghash_lookup(global_ops_hash, idname_bl); if (ot) { return ot; } @@ -140,38 +140,38 @@ GHashIterator *WM_operatortype_iter(void) } /* all ops in 1 list (for time being... needs evaluation later) */ -void WM_operatortype_append(void (*opfunc)(wmOperatorType*)) +void WM_operatortype_append(void (*opfunc)(wmOperatorType *)) { wmOperatorType *ot; - ot= MEM_callocN(sizeof(wmOperatorType), "operatortype"); + ot = MEM_callocN(sizeof(wmOperatorType), "operatortype"); ot->srna = RNA_def_struct(&BLENDER_RNA, "", "OperatorProperties"); /* Set the default i18n context now, so that opfunc can redefine it if needed! */ 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"); } // XXX All ops should have a description but for now allow them not to. - RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description:N_("(undocumented operator)")); + RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description : N_("(undocumented operator)")); RNA_def_struct_identifier(ot->srna, ot->idname); BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot); } -void WM_operatortype_append_ptr(void (*opfunc)(wmOperatorType*, void*), void *userdata) +void WM_operatortype_append_ptr(void (*opfunc)(wmOperatorType *, void *), void *userdata) { wmOperatorType *ot; - ot= MEM_callocN(sizeof(wmOperatorType), "operatortype"); + ot = MEM_callocN(sizeof(wmOperatorType), "operatortype"); ot->srna = RNA_def_struct(&BLENDER_RNA, "", "OperatorProperties"); /* Set the default i18n context now, so that opfunc can redefine it if needed! */ RNA_def_struct_translation_context(ot->srna, WM_OPERATOR_DEFAULT_I18NCONTEXT); opfunc(ot, userdata); - RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description:N_("(undocumented operator)")); + RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description : N_("(undocumented operator)")); RNA_def_struct_identifier(ot->srna, ot->idname); BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot); @@ -202,7 +202,7 @@ static int wm_macro_end(wmOperator *op, int retval) } /* if modal is ending, free custom data */ - if (retval & (OPERATOR_FINISHED|OPERATOR_CANCELLED)) { + if (retval & (OPERATOR_FINISHED | OPERATOR_CANCELLED)) { if (op->customdata) { MEM_freeN(op->customdata); op->customdata = NULL; @@ -216,14 +216,14 @@ static int wm_macro_end(wmOperator *op, int retval) static int wm_macro_exec(bContext *C, wmOperator *op) { wmOperator *opm; - int retval= OPERATOR_FINISHED; + int retval = OPERATOR_FINISHED; 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) { - retval= opm->type->exec(C, opm); + retval = opm->type->exec(C, opm); OPERATOR_RETVAL_CHECK(retval); if (retval & OPERATOR_FINISHED) { @@ -241,14 +241,14 @@ static int wm_macro_exec(bContext *C, wmOperator *op) static int wm_macro_invoke_internal(bContext *C, wmOperator *op, wmEvent *event, wmOperator *opm) { - int retval= OPERATOR_FINISHED; + int retval = OPERATOR_FINISHED; /* start from operator received as argument */ - for ( ; opm; opm= opm->next) { + for (; opm; opm = opm->next) { if (opm->type->invoke) - retval= opm->type->invoke(C, opm, event); + retval = opm->type->invoke(C, opm, event); else if (opm->type->exec) - retval= opm->type->exec(C, opm); + retval = opm->type->exec(C, opm); OPERATOR_RETVAL_CHECK(retval); @@ -275,9 +275,9 @@ static int wm_macro_invoke(bContext *C, wmOperator *op, wmEvent *event) static int wm_macro_modal(bContext *C, wmOperator *op, wmEvent *event) { wmOperator *opm = op->opm; - int retval= OPERATOR_FINISHED; + 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); @@ -311,16 +311,16 @@ static int wm_macro_modal(bContext *C, wmOperator *op, wmEvent *event) * This may end up grabbing twice, but we don't care. * */ if (op->opm->type->flag & OPTYPE_BLOCKING) { - int bounds[4] = {-1,-1,-1,-1}; + 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) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); if (ar) { - bounds[0]= ar->winrct.xmin; - bounds[1]= ar->winrct.ymax; - bounds[2]= ar->winrct.xmax; - bounds[3]= ar->winrct.ymin; + bounds[0] = ar->winrct.xmin; + bounds[1] = ar->winrct.ymax; + bounds[2] = ar->winrct.xmax; + bounds[3] = ar->winrct.ymin; } } @@ -353,12 +353,12 @@ wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *nam return NULL; } - ot= MEM_callocN(sizeof(wmOperatorType), "operatortype"); + ot = MEM_callocN(sizeof(wmOperatorType), "operatortype"); ot->srna = RNA_def_struct(&BLENDER_RNA, "", "OperatorProperties"); ot->idname = idname; ot->name = name; - ot->flag = OPTYPE_MACRO|flag; + ot->flag = OPTYPE_MACRO | flag; ot->exec = wm_macro_exec; ot->invoke = wm_macro_invoke; @@ -378,11 +378,11 @@ wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *nam return ot; } -void WM_operatortype_append_macro_ptr(void (*opfunc)(wmOperatorType*, void*), void *userdata) +void WM_operatortype_append_macro_ptr(void (*opfunc)(wmOperatorType *, void *), void *userdata) { wmOperatorType *ot; - ot= MEM_callocN(sizeof(wmOperatorType), "operatortype"); + ot = MEM_callocN(sizeof(wmOperatorType), "operatortype"); ot->srna = RNA_def_struct(&BLENDER_RNA, "", "OperatorProperties"); ot->flag = OPTYPE_MACRO; @@ -407,7 +407,7 @@ void WM_operatortype_append_macro_ptr(void (*opfunc)(wmOperatorType*, void*), vo wmOperatorTypeMacro *WM_operatortype_macro_define(wmOperatorType *ot, const char *idname) { - wmOperatorTypeMacro *otmacro= MEM_callocN(sizeof(wmOperatorTypeMacro), "wmOperatorTypeMacro"); + wmOperatorTypeMacro *otmacro = MEM_callocN(sizeof(wmOperatorTypeMacro), "wmOperatorTypeMacro"); BLI_strncpy(otmacro->idname, idname, OP_MAX_TYPENAME); @@ -422,7 +422,7 @@ wmOperatorTypeMacro *WM_operatortype_macro_define(wmOperatorType *ot, const char wmOperatorType *otsub = WM_operatortype_find(idname, 0); if (otsub) { RNA_def_pointer_runtime(ot->srna, otsub->idname, otsub->srna, - otsub->name, otsub->description); + otsub->name, otsub->description); } } @@ -433,7 +433,7 @@ static void wm_operatortype_free_macro(wmOperatorType *ot) { wmOperatorTypeMacro *otmacro; - for (otmacro= ot->macro.first; otmacro; otmacro= otmacro->next) { + for (otmacro = ot->macro.first; otmacro; otmacro = otmacro->next) { if (otmacro->ptr) { WM_operator_properties_free(otmacro->ptr); MEM_freeN(otmacro->ptr); @@ -447,7 +447,7 @@ int WM_operatortype_remove(const char *idname) { wmOperatorType *ot = WM_operatortype_find(idname, 0); - if (ot==NULL) + if (ot == NULL) return 0; RNA_struct_free(&BLENDER_RNA, ot->srna); @@ -469,17 +469,17 @@ int WM_operatortype_remove(const char *idname) /* SOME_OT_op -> some.op */ void WM_operator_py_idname(char *to, const char *from) { - char *sep= strstr(from, "_OT_"); + char *sep = strstr(from, "_OT_"); if (sep) { - int ofs= (sep-from); + int ofs = (sep - from); /* note, we use ascii tolower instead of system tolower, because the * latter depends on the locale, and can lead to idname mistmatch */ - memcpy(to, from, sizeof(char)*ofs); + memcpy(to, from, sizeof(char) * ofs); BLI_ascii_strtolower(to, ofs); to[ofs] = '.'; - BLI_strncpy(to+(ofs+1), sep+4, OP_MAX_TYPENAME); + BLI_strncpy(to + (ofs + 1), sep + 4, OP_MAX_TYPENAME); } else { /* should not happen but support just in case */ @@ -491,16 +491,16 @@ void WM_operator_py_idname(char *to, const char *from) void WM_operator_bl_idname(char *to, const char *from) { if (from) { - char *sep= strchr(from, '.'); + char *sep = strchr(from, '.'); if (sep) { - int ofs= (sep-from); + int ofs = (sep - from); - memcpy(to, from, sizeof(char)*ofs); + memcpy(to, from, sizeof(char) * ofs); BLI_ascii_strtoupper(to, ofs); - BLI_strncpy(to+ofs, "_OT_", OP_MAX_TYPENAME); - BLI_strncpy(to+(ofs+4), sep+1, OP_MAX_TYPENAME); + BLI_strncpy(to + ofs, "_OT_", OP_MAX_TYPENAME); + BLI_strncpy(to + (ofs + 4), sep + 1, OP_MAX_TYPENAME); } else { /* should not happen but support just in case */ @@ -508,7 +508,7 @@ void WM_operator_bl_idname(char *to, const char *from) } } else - to[0]= 0; + to[0] = 0; } /* print a string representation of the operator, with the args that it runs @@ -522,17 +522,17 @@ char *WM_operator_pystring(bContext *C, wmOperatorType *ot, PointerRNA *opptr, i char idname_py[OP_MAX_TYPENAME]; /* for building the string */ - DynStr *dynstr= BLI_dynstr_new(); + DynStr *dynstr = BLI_dynstr_new(); char *cstring; char *cstring_args; /* only to get the orginal props for comparisons */ PointerRNA opptr_default; - if (all_args==0 || opptr==NULL) { + if (all_args == 0 || opptr == NULL) { WM_operator_properties_create_ptr(&opptr_default, ot); - if (opptr==NULL) + if (opptr == NULL) opptr = &opptr_default; } @@ -543,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 +560,7 @@ void WM_operator_properties_create_ptr(PointerRNA *ptr, wmOperatorType *ot) void WM_operator_properties_create(PointerRNA *ptr, const char *opstring) { - wmOperatorType *ot= WM_operatortype_find(opstring, 0); + wmOperatorType *ot = WM_operatortype_find(opstring, 0); if (ot) WM_operator_properties_create_ptr(ptr, ot); @@ -572,33 +572,33 @@ 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"); + *properties = IDP_New(IDP_GROUP, &val, "wmOpItemProp"); } - if (*ptr==NULL) { - *ptr= MEM_callocN(sizeof(PointerRNA), "wmOpItemPtr"); + if (*ptr == NULL) { + *ptr = MEM_callocN(sizeof(PointerRNA), "wmOpItemPtr"); WM_operator_properties_create(*ptr, opstring); } - (*ptr)->data= *properties; + (*ptr)->data = *properties; } void WM_operator_properties_sanitize(PointerRNA *ptr, const short no_context) { RNA_STRUCT_BEGIN(ptr, prop) { - switch(RNA_property_type(prop)) { - case PROP_ENUM: - if (no_context) - RNA_def_property_flag(prop, PROP_ENUM_NO_CONTEXT); - else - RNA_def_property_clear_flag(prop, PROP_ENUM_NO_CONTEXT); - break; - case PROP_POINTER: + switch (RNA_property_type(prop)) { + case PROP_ENUM: + if (no_context) + RNA_def_property_flag(prop, PROP_ENUM_NO_CONTEXT); + else + RNA_def_property_clear_flag(prop, PROP_ENUM_NO_CONTEXT); + break; + case PROP_POINTER: { - StructRNA *ptype= RNA_property_pointer_type(ptr, prop); + StructRNA *ptype = RNA_property_pointer_type(ptr, prop); /* recurse into operator properties */ if (RNA_struct_is_a(ptype, &RNA_OperatorProperties)) { @@ -607,8 +607,8 @@ void WM_operator_properties_sanitize(PointerRNA *ptr, const short no_context) } break; } - default: - break; + default: + break; } } RNA_STRUCT_END; @@ -619,10 +619,10 @@ void WM_operator_properties_reset(wmOperator *op) { if (op->ptr->data) { PropertyRNA *iterprop; - iterprop= RNA_struct_iterator_property(op->type->srna); + iterprop = RNA_struct_iterator_property(op->type->srna); RNA_PROP_BEGIN(op->ptr, itemptr, iterprop) { - PropertyRNA *prop= itemptr.data; + PropertyRNA *prop = itemptr.data; if ((RNA_property_flag(prop) & PROP_SKIP_SAVE) == 0) { const char *identifier = RNA_property_identifier(prop); @@ -635,12 +635,12 @@ void WM_operator_properties_reset(wmOperator *op) void WM_operator_properties_free(PointerRNA *ptr) { - IDProperty *properties= ptr->data; + IDProperty *properties = ptr->data; if (properties) { IDP_FreeProperty(properties); MEM_freeN(properties); - ptr->data= NULL; /* just in case */ + ptr->data = NULL; /* just in case */ } } @@ -649,11 +649,11 @@ void WM_operator_properties_free(PointerRNA *ptr) /* invoke callback, uses enum property named "type" */ int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - PropertyRNA *prop= op->type->prop; + PropertyRNA *prop = op->type->prop; 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) { @@ -661,13 +661,13 @@ int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) __func__, op->type->idname, RNA_property_identifier(prop)); } else if (RNA_property_is_set(op->ptr, prop)) { - const int retval= op->type->exec(C, op); + const int retval = op->type->exec(C, op); OPERATOR_RETVAL_CHECK(retval); return retval; } else { - pup= uiPupMenuBegin(C, IFACE_(op->type->name), ICON_NONE); - layout= uiPupMenuLayout(pup); + pup = uiPupMenuBegin(C, IFACE_(op->type->name), ICON_NONE); + layout = uiPupMenuLayout(pup); uiItemsFullEnumO(layout, op->type->idname, RNA_property_identifier(prop), op->ptr->data, WM_OP_EXEC_REGION_WIN, 0); uiPupMenuEnd(C, pup); } @@ -680,9 +680,9 @@ int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) static void operator_enum_search_cb(const struct bContext *C, void *arg_ot, const char *str, uiSearchItems *items) { wmOperatorType *ot = (wmOperatorType *)arg_ot; - PropertyRNA *prop= ot->prop; + PropertyRNA *prop = ot->prop; - if (prop==NULL) { + if (prop == NULL) { printf("%s: %s has no enum property set\n", __func__, ot->idname); } @@ -699,10 +699,10 @@ 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 (0 == uiSearchItemAdd(items, item->name, SET_INT_IN_POINTER(item->value), 0)) break; } @@ -713,7 +713,7 @@ static void operator_enum_search_cb(const struct bContext *C, void *arg_ot, cons static void operator_enum_call_cb(struct bContext *C, void *arg1, void *arg2) { - wmOperatorType *ot= arg1; + wmOperatorType *ot = arg1; if (ot) { if (ot->prop) { @@ -731,31 +731,31 @@ static void operator_enum_call_cb(struct bContext *C, void *arg1, void *arg2) static uiBlock *wm_enum_search_menu(bContext *C, ARegion *ar, void *arg_op) { - static char search[256]= ""; + static char search[256] = ""; wmEvent event; - wmWindow *win= CTX_wm_window(C); + wmWindow *win = CTX_wm_window(C); uiBlock *block; uiBut *but; - wmOperator *op= (wmOperator *)arg_op; + wmOperator *op = (wmOperator *)arg_op; - block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); - uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_RET_1|UI_BLOCK_MOVEMOUSE_QUIT); + block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); + uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_RET_1 | UI_BLOCK_MOVEMOUSE_QUIT); //uiDefBut(block, LABEL, 0, op->type->name, 10, 10, 180, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); // ok, this isn't so easy... - but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, 9*UI_UNIT_X, UI_UNIT_Y, 0, 0, ""); + but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, 9 * UI_UNIT_X, UI_UNIT_Y, 0, 0, ""); uiButSetSearchFunc(but, operator_enum_search_cb, op->type, operator_enum_call_cb, NULL); /* fake button, it holds space for search items */ - uiDefBut(block, LABEL, 0, "", 10, 10 - uiSearchBoxhHeight(), 9*UI_UNIT_X, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL); + uiDefBut(block, LABEL, 0, "", 10, 10 - uiSearchBoxhHeight(), 9 * UI_UNIT_X, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL); uiPopupBoundsBlock(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */ uiEndBlock(C, block); - event= *(win->eventstate); /* XXX huh huh? make api call */ - event.type= EVT_BUT_OPEN; - event.val= KM_PRESS; - event.customdata= but; - event.customdatafree= FALSE; + event = *(win->eventstate); /* XXX huh huh? make api call */ + event.type = EVT_BUT_OPEN; + event.val = KM_PRESS; + event.customdata = but; + event.customdatafree = FALSE; wm_event_add(win, &event); return block; @@ -773,15 +773,15 @@ int WM_operator_confirm_message(bContext *C, wmOperator *op, const char *message { uiPopupMenu *pup; uiLayout *layout; - IDProperty *properties= op->ptr->data; + IDProperty *properties = op->ptr->data; if (properties && properties->len) - properties= IDP_CopyProperty(op->ptr->data); + properties = IDP_CopyProperty(op->ptr->data); else - properties= NULL; + properties = NULL; - pup= uiPupMenuBegin(C, IFACE_("OK?"), ICON_QUESTION); - layout= uiPupMenuLayout(pup); + pup = uiPupMenuBegin(C, IFACE_("OK?"), ICON_QUESTION); + layout = uiPupMenuLayout(pup); uiItemFullO_ptr(layout, op->type, message, ICON_NONE, properties, WM_OP_EXEC_REGION_WIN, 0); uiPupMenuEnd(C, pup); @@ -816,7 +816,8 @@ void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type, {FILE_SHORTDISPLAY, "FILE_SHORTDISPLAY", ICON_SHORTDISPLAY, "Short List", "Display files as short list"}, {FILE_LONGDISPLAY, "FILE_LONGDISPLAY", ICON_LONGDISPLAY, "Long List", "Display files as a detailed list"}, {FILE_IMGDISPLAY, "FILE_IMGDISPLAY", ICON_IMGDISPLAY, "Thumbnails", "Display files as thumbnails"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; if (flag & WM_FILESEL_FILEPATH) @@ -832,51 +833,51 @@ void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type, RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, "Files", ""); if (action == FILE_SAVE) { - prop= RNA_def_boolean(ot->srna, "check_existing", 1, "Check Existing", "Check and warn on overwriting existing files"); + prop = RNA_def_boolean(ot->srna, "check_existing", 1, "Check Existing", "Check and warn on overwriting existing files"); RNA_def_property_flag(prop, PROP_HIDDEN); } - prop= RNA_def_boolean(ot->srna, "filter_blender", (filter & BLENDERFILE), "Filter .blend files", ""); + prop = RNA_def_boolean(ot->srna, "filter_blender", (filter & BLENDERFILE), "Filter .blend files", ""); RNA_def_property_flag(prop, PROP_HIDDEN); - prop= RNA_def_boolean(ot->srna, "filter_image", (filter & IMAGEFILE), "Filter image files", ""); + prop = RNA_def_boolean(ot->srna, "filter_image", (filter & IMAGEFILE), "Filter image files", ""); RNA_def_property_flag(prop, PROP_HIDDEN); - prop= RNA_def_boolean(ot->srna, "filter_movie", (filter & MOVIEFILE), "Filter movie files", ""); + prop = RNA_def_boolean(ot->srna, "filter_movie", (filter & MOVIEFILE), "Filter movie files", ""); RNA_def_property_flag(prop, PROP_HIDDEN); - prop= RNA_def_boolean(ot->srna, "filter_python", (filter & PYSCRIPTFILE), "Filter python files", ""); + prop = RNA_def_boolean(ot->srna, "filter_python", (filter & PYSCRIPTFILE), "Filter python files", ""); RNA_def_property_flag(prop, PROP_HIDDEN); - prop= RNA_def_boolean(ot->srna, "filter_font", (filter & FTFONTFILE), "Filter font files", ""); + prop = RNA_def_boolean(ot->srna, "filter_font", (filter & FTFONTFILE), "Filter font files", ""); RNA_def_property_flag(prop, PROP_HIDDEN); - prop= RNA_def_boolean(ot->srna, "filter_sound", (filter & SOUNDFILE), "Filter sound files", ""); + prop = RNA_def_boolean(ot->srna, "filter_sound", (filter & SOUNDFILE), "Filter sound files", ""); RNA_def_property_flag(prop, PROP_HIDDEN); - prop= RNA_def_boolean(ot->srna, "filter_text", (filter & TEXTFILE), "Filter text files", ""); + prop = RNA_def_boolean(ot->srna, "filter_text", (filter & TEXTFILE), "Filter text files", ""); RNA_def_property_flag(prop, PROP_HIDDEN); - prop= RNA_def_boolean(ot->srna, "filter_btx", (filter & BTXFILE), "Filter btx files", ""); + prop = RNA_def_boolean(ot->srna, "filter_btx", (filter & BTXFILE), "Filter btx files", ""); RNA_def_property_flag(prop, PROP_HIDDEN); - prop= RNA_def_boolean(ot->srna, "filter_collada", (filter & COLLADAFILE), "Filter COLLADA files", ""); + prop = RNA_def_boolean(ot->srna, "filter_collada", (filter & COLLADAFILE), "Filter COLLADA files", ""); RNA_def_property_flag(prop, PROP_HIDDEN); - prop= RNA_def_boolean(ot->srna, "filter_folder", (filter & FOLDERFILE), "Filter folders", ""); + prop = RNA_def_boolean(ot->srna, "filter_folder", (filter & FOLDERFILE), "Filter folders", ""); RNA_def_property_flag(prop, PROP_HIDDEN); - prop= RNA_def_int(ot->srna, "filemode", type, FILE_LOADLIB, FILE_SPECIAL, - "File Browser Mode", "The setting for the file browser mode to load a .blend file, a library or a special file", - FILE_LOADLIB, FILE_SPECIAL); + prop = RNA_def_int(ot->srna, "filemode", type, FILE_LOADLIB, FILE_SPECIAL, + "File Browser Mode", "The setting for the file browser mode to load a .blend file, a library or a special file", + FILE_LOADLIB, FILE_SPECIAL); RNA_def_property_flag(prop, PROP_HIDDEN); 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", ""); + prop = RNA_def_enum(ot->srna, "display_type", file_display_items, display, "Display Type", ""); RNA_def_property_flag(prop, PROP_HIDDEN); } void WM_operator_properties_select_all(wmOperatorType *ot) { static EnumPropertyItem select_all_actions[] = { - {SEL_TOGGLE, "TOGGLE", 0, "Toggle", "Toggle selection for all elements"}, - {SEL_SELECT, "SELECT", 0, "Select", "Select all elements"}, - {SEL_DESELECT, "DESELECT", 0, "Deselect", "Deselect all elements"}, - {SEL_INVERT, "INVERT", 0, "Invert", "Invert selection of all elements"}, - {0, NULL, 0, NULL, NULL} + {SEL_TOGGLE, "TOGGLE", 0, "Toggle", "Toggle selection for all elements"}, + {SEL_SELECT, "SELECT", 0, "Select", "Select all elements"}, + {SEL_DESELECT, "DESELECT", 0, "Deselect", "Deselect all elements"}, + {SEL_INVERT, "INVERT", 0, "Invert", "Invert selection of all elements"}, + {0, NULL, 0, NULL, NULL} }; RNA_def_enum(ot->srna, "action", select_all_actions, SEL_TOGGLE, "Action", "Selection action to execute"); @@ -909,26 +910,26 @@ 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; } /* return FALSE, if the UI should be disabled */ int WM_operator_check_ui_enabled(const bContext *C, const char *idname) { - wmWindowManager *wm= CTX_wm_manager(C); - Scene *scene= CTX_data_scene(C); + wmWindowManager *wm = CTX_wm_manager(C); + Scene *scene = CTX_data_scene(C); - return !(ED_undo_valid(C, idname)==0 || WM_jobs_test(wm, scene)); + return !(ED_undo_valid(C, idname) == 0 || WM_jobs_test(wm, scene)); } wmOperator *WM_operator_last_redo(const bContext *C) { - wmWindowManager *wm= CTX_wm_manager(C); + wmWindowManager *wm = CTX_wm_manager(C); wmOperator *op; /* only for operators that are registered and did an undo push */ - for (op= wm->operators.last; op; op= op->prev) + for (op = wm->operators.last; op; op = op->prev) if ((op->type->flag & OPTYPE_REGISTER) && (op->type->flag & OPTYPE_UNDO)) break; @@ -937,29 +938,29 @@ wmOperator *WM_operator_last_redo(const bContext *C) static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op) { - wmOperator *op= arg_op; + wmOperator *op = arg_op; uiBlock *block; uiLayout *layout; - uiStyle *style= UI_GetStyle(); - int width= 300; + uiStyle *style = UI_GetStyle(); + int width = 300; - block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); + block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockClearFlag(block, UI_BLOCK_LOOP); - uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1|UI_BLOCK_MOVEMOUSE_QUIT); + uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_RET_1 | UI_BLOCK_MOVEMOUSE_QUIT); /* if register is not enabled, the operator gets freed on OPERATOR_FINISHED - * ui_apply_but_funcs_after calls ED_undo_operator_repeate_cb and crashes */ + * ui_apply_but_funcs_after calls ED_undo_operator_repeate_cb and crashes */ assert(op->type->flag & OPTYPE_REGISTER); uiBlockSetHandleFunc(block, ED_undo_operator_repeat_cb_evt, arg_op); - layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, width, UI_UNIT_Y, style); + layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, width, UI_UNIT_Y, style); 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) { + 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); } @@ -975,8 +976,7 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op) return block; } -typedef struct wmOpPopUp -{ +typedef struct wmOpPopUp { wmOperator *op; int width; int height; @@ -986,8 +986,8 @@ typedef struct wmOpPopUp /* Only invoked by OK button in popups created with wm_block_dialog_create() */ static void dialog_exec_cb(bContext *C, void *arg1, void *arg2) { - wmOpPopUp *data= arg1; - uiBlock *block= arg2; + wmOpPopUp *data = arg1; + uiBlock *block = arg2; WM_operator_call(C, data->op); @@ -1003,7 +1003,7 @@ 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; + wmOperator *op = op_ptr; if (op->type->check) { if (op->type->check(C, op)) { /* refresh */ @@ -1014,17 +1014,17 @@ static void dialog_check_cb(bContext *C, void *op_ptr, void *UNUSED(arg)) /* Dialogs are popups that require user verification (click OK) before exec */ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *ar, void *userData) { - wmOpPopUp *data= userData; - wmOperator *op= data->op; + wmOpPopUp *data = userData; + wmOperator *op = data->op; uiBlock *block; uiLayout *layout; - uiStyle *style= UI_GetStyle(); + uiStyle *style = UI_GetStyle(); block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockClearFlag(block, UI_BLOCK_LOOP); - uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1|UI_BLOCK_MOVEMOUSE_QUIT); + uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_RET_1 | UI_BLOCK_MOVEMOUSE_QUIT); - layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, style); + layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, style); uiBlockSetFunc(block, dialog_check_cb, op, NULL); @@ -1039,15 +1039,15 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *ar, void *userData) uiLayout *col; uiBut *btn; - col= uiLayoutColumn(layout, FALSE); - col_block= uiLayoutGetBlock(col); + col = uiLayoutColumn(layout, FALSE); + col_block = uiLayoutGetBlock(col); /* Create OK button, the callback of which will execute op */ - btn= uiDefBut(col_block, BUT, 0, IFACE_("OK"), 0, -30, 0, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); + btn = uiDefBut(col_block, BUT, 0, IFACE_("OK"), 0, -30, 0, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); uiButSetFunc(btn, dialog_exec_cb, data, col_block); } /* center around the mouse */ - uiPopupBoundsBlock(block, 4, data->width/-2, data->height/2); + uiPopupBoundsBlock(block, 4, data->width / -2, data->height / 2); uiEndBlock(C, block); return block; @@ -1055,17 +1055,17 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *ar, void *userData) static uiBlock *wm_operator_ui_create(bContext *C, ARegion *ar, void *userData) { - wmOpPopUp *data= userData; - wmOperator *op= data->op; + wmOpPopUp *data = userData; + wmOperator *op = data->op; uiBlock *block; uiLayout *layout; - uiStyle *style= UI_GetStyle(); + uiStyle *style = UI_GetStyle(); - block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); + block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockClearFlag(block, UI_BLOCK_LOOP); - uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1|UI_BLOCK_MOVEMOUSE_QUIT); + uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_RET_1 | UI_BLOCK_MOVEMOUSE_QUIT); - layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, style); + layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, style); /* since ui is defined the auto-layout args are not used */ uiLayoutOperatorButs(C, layout, op, NULL, 'V', 0); @@ -1078,9 +1078,9 @@ static uiBlock *wm_operator_ui_create(bContext *C, ARegion *ar, void *userData) static void wm_operator_ui_popup_cancel(void *userData) { - wmOpPopUp *data= userData; + wmOpPopUp *data = userData; if (data->free_op && data->op) { - wmOperator *op= data->op; + wmOperator *op = data->op; WM_operator_free(op); } @@ -1089,8 +1089,8 @@ static void wm_operator_ui_popup_cancel(void *userData) static void wm_operator_ui_popup_ok(struct bContext *C, void *arg, int retval) { - wmOpPopUp *data= arg; - wmOperator *op= data->op; + wmOpPopUp *data = arg; + wmOperator *op = data->op; if (op && retval > 0) WM_operator_call(C, op); @@ -1098,11 +1098,11 @@ static void wm_operator_ui_popup_ok(struct bContext *C, void *arg, int retval) int WM_operator_ui_popup(bContext *C, wmOperator *op, int width, int height) { - wmOpPopUp *data= MEM_callocN(sizeof(wmOpPopUp), "WM_operator_ui_popup"); - data->op= op; - data->width= width; - data->height= height; - data->free_op= TRUE; /* if this runs and gets registered we may want not to free it */ + wmOpPopUp *data = MEM_callocN(sizeof(wmOpPopUp), "WM_operator_ui_popup"); + data->op = op; + data->width = width; + data->height = height; + data->free_op = TRUE; /* if this runs and gets registered we may want not to free it */ uiPupBlockEx(C, wm_operator_ui_create, NULL, wm_operator_ui_popup_cancel, data); return OPERATOR_RUNNING_MODAL; } @@ -1111,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; @@ -1127,12 +1127,12 @@ int WM_operator_props_popup(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) int WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width, int height) { - wmOpPopUp *data= MEM_callocN(sizeof(wmOpPopUp), "WM_operator_props_dialog_popup"); + wmOpPopUp *data = MEM_callocN(sizeof(wmOpPopUp), "WM_operator_props_dialog_popup"); - data->op= op; - data->width= width; - data->height= height; - data->free_op= TRUE; /* if this runs and gets registered we may want not to free it */ + data->op = op; + data->width = width; + data->height = height; + data->free_op = TRUE; /* if this runs and gets registered we may want not to free it */ /* op is not executed until popup OK but is clicked */ uiPupBlockEx(C, wm_block_dialog_create, wm_operator_ui_popup_ok, wm_operator_ui_popup_cancel, data); @@ -1143,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; } @@ -1161,7 +1161,7 @@ int WM_operator_redo_popup(bContext *C, wmOperator *op) static int wm_debug_menu_exec(bContext *C, wmOperator *op) { - G.rt= RNA_int_get(op->ptr, "debug_value"); + G.rt = RNA_int_get(op->ptr, "debug_value"); ED_screen_refresh(CTX_wm_manager(C), CTX_wm_window(C)); WM_event_add_notifier(C, NC_WINDOW, NULL); @@ -1171,7 +1171,7 @@ static int wm_debug_menu_exec(bContext *C, wmOperator *op) static int wm_debug_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { RNA_int_set(op->ptr, "debug_value", G.rt); - return WM_operator_props_dialog_popup(C, op, 9*UI_UNIT_X, UI_UNIT_Y); + return WM_operator_props_dialog_popup(C, op, 9 * UI_UNIT_X, UI_UNIT_Y); } static void WM_OT_debug_menu(wmOperatorType *ot) @@ -1199,7 +1199,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *arg_unuse /* XXX: hack to refresh splash screen with updated prest menu name, * since popup blocks don't get regenerated like panels do */ -static void wm_block_splash_refreshmenu (bContext *UNUSED(C), void *UNUSED(arg_block), void *UNUSED(arg)) +static void wm_block_splash_refreshmenu(bContext *UNUSED(C), void *UNUSED(arg_block), void *UNUSED(arg)) { /* ugh, causes crashes in other buttons, disabling for now until * a better fix */ @@ -1212,14 +1212,14 @@ static void wm_block_splash_refreshmenu (bContext *UNUSED(C), void *UNUSED(arg_b static int wm_resource_check_prev(void) { - char *res= BLI_get_folder_version(BLENDER_RESOURCE_PATH_USER, BLENDER_VERSION, TRUE); + char *res = BLI_get_folder_version(BLENDER_RESOURCE_PATH_USER, BLENDER_VERSION, TRUE); // if (res) printf("USER: %s\n", res); #if 0 /* ignore the local folder */ 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); + res = BLI_get_folder_version(BLENDER_RESOURCE_PATH_LOCAL, BLENDER_VERSION, TRUE); } #endif @@ -1237,7 +1237,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar uiBlock *block; uiBut *but; uiLayout *layout, *split, *col; - uiStyle *style= UI_GetStyle(); + uiStyle *style = UI_GetStyle(); struct RecentFile *recent; int i; MenuType *mt = WM_menutype_find("USERPREF_MT_splash", TRUE); @@ -1247,9 +1247,9 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar extern char datatoc_splash_png[]; extern int datatoc_splash_png_size; - ImBuf *ibuf= IMB_ibImageFromMemory((unsigned char*)datatoc_splash_png, datatoc_splash_png_size, IB_rect, "<splash screen>"); + ImBuf *ibuf = IMB_ibImageFromMemory((unsigned char *)datatoc_splash_png, datatoc_splash_png_size, IB_rect, "<splash screen>"); #else - ImBuf *ibuf= NULL; + ImBuf *ibuf = NULL; #endif @@ -1260,7 +1260,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar extern char build_rev[]; BLI_snprintf(version_buf, sizeof(version_buf), - "%d.%02d.%d", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION); + "%d.%02d.%d", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION); BLI_snprintf(revision_buf, sizeof(revision_buf), "r%s", build_rev); BLF_size(style->widgetlabel.uifont_id, style->widgetlabel.points, U.dpi); @@ -1268,7 +1268,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar rev_width = (int)BLF_width(style->widgetlabel.uifont_id, revision_buf) + 5; #endif //WITH_BUILDINFO - block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); + block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN); but = uiDefBut(block, BUT_IMAGE, 0, "", 0, 10, 501, 282, ibuf, 0.0, 0.0, 0, 0, ""); /* button owns the imbuf now */ @@ -1276,18 +1276,18 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar uiBlockSetFunc(block, wm_block_splash_refreshmenu, block, NULL); #ifdef WITH_BUILDINFO - uiDefBut(block, LABEL, 0, version_buf, 494-ver_width, 282-24, ver_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); - uiDefBut(block, LABEL, 0, revision_buf, 494-rev_width, 282-36, rev_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); + uiDefBut(block, LABEL, 0, version_buf, 494 - ver_width, 282 - 24, ver_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); + uiDefBut(block, LABEL, 0, revision_buf, 494 - rev_width, 282 - 36, rev_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); #endif //WITH_BUILDINFO - layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 10, 2, 480, 110, style); + layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 10, 2, 480, 110, style); uiBlockSetEmboss(block, UI_EMBOSS); /* show the splash menu (containing interaction presets), using python */ if (mt) { - Menu menu= {NULL}; - menu.layout= layout; - menu.type= mt; + Menu menu = {NULL}; + menu.layout = layout; + menu.type = mt; mt->draw(C, &menu); // wmWindowManager *wm= CTX_wm_manager(C); @@ -1306,11 +1306,11 @@ 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) { - 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); + 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 { - BLI_snprintf(url, sizeof(url), "http://www.blender.org/documentation/blender_python_api_%d_%d_%d", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION); + BLI_snprintf(url, sizeof(url), "http://www.blender.org/documentation/blender_python_api_%d_%d_%d", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION); } uiItemStringO(col, IFACE_("Python API Reference"), ICON_URL, "WM_OT_url_open", "url", url); uiItemL(col, "", ICON_NONE); @@ -1323,7 +1323,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar } 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 +1358,7 @@ static void WM_OT_splash(wmOperatorType *ot) /* ***************** Search menu ************************* */ static void operator_call_cb(struct bContext *C, void *UNUSED(arg1), void *arg2) { - wmOperatorType *ot= arg2; + wmOperatorType *ot = arg2; if (ot) WM_operator_name_call(C, ot->idname, WM_OP_INVOKE_DEFAULT, NULL); @@ -1366,18 +1366,18 @@ static void operator_call_cb(struct bContext *C, void *UNUSED(arg1), void *arg2) static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), const char *str, uiSearchItems *items) { - GHashIterator *iter= WM_operatortype_iter(); + GHashIterator *iter = WM_operatortype_iter(); - for ( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { - wmOperatorType *ot= BLI_ghashIterator_getValue(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) continue; if (BLI_strcasestr(ot->name, str)) { - if (WM_operator_poll((bContext*)C, ot)) { + if (WM_operator_poll((bContext *)C, ot)) { char name[256]; - int len= strlen(ot->name); + int len = strlen(ot->name); /* display name for menu, can hold hotkey */ BLI_strncpy(name, ot->name, sizeof(name)); @@ -1385,13 +1385,13 @@ static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), cons /* check for hotkey */ if (len < sizeof(name) - 6) { if (WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, TRUE, - &name[len+1], sizeof(name)-len-1)) + &name[len + 1], sizeof(name) - len - 1)) { - name[len]= '|'; + name[len] = '|'; } } - if (0==uiSearchItemAdd(items, name, ot, 0)) + if (0 == uiSearchItemAdd(items, name, ot, 0)) break; } } @@ -1401,29 +1401,29 @@ static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), cons static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *UNUSED(arg_op)) { - static char search[256]= ""; + static char search[256] = ""; wmEvent event; - wmWindow *win= CTX_wm_window(C); + wmWindow *win = CTX_wm_window(C); uiBlock *block; uiBut *but; - block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); - uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_RET_1|UI_BLOCK_MOVEMOUSE_QUIT); + block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); + uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_RET_1 | UI_BLOCK_MOVEMOUSE_QUIT); - but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, 9*UI_UNIT_X, UI_UNIT_Y, 0, 0, ""); + but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, 9 * UI_UNIT_X, UI_UNIT_Y, 0, 0, ""); uiButSetSearchFunc(but, operator_search_cb, NULL, operator_call_cb, NULL); /* fake button, it holds space for search items */ - uiDefBut(block, LABEL, 0, "", 10, 10 - uiSearchBoxhHeight(), 9*UI_UNIT_X, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL); + uiDefBut(block, LABEL, 0, "", 10, 10 - uiSearchBoxhHeight(), 9 * UI_UNIT_X, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL); uiPopupBoundsBlock(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */ uiEndBlock(C, block); - event= *(win->eventstate); /* XXX huh huh? make api call */ - event.type= EVT_BUT_OPEN; - event.val= KM_PRESS; - event.customdata= but; - event.customdatafree= FALSE; + event = *(win->eventstate); /* XXX huh huh? make api call */ + event.type = EVT_BUT_OPEN; + event.val = KM_PRESS; + event.customdata = but; + event.customdatafree = FALSE; wm_event_add(win, &event); return block; @@ -1444,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); + 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->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 + 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 } } return 1; @@ -1500,9 +1500,9 @@ static void WM_OT_call_menu(wmOperatorType *ot) * while it crashes on full screen */ static int wm_operator_winactive_normal(bContext *C) { - wmWindow *win= CTX_wm_window(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; @@ -1571,7 +1571,7 @@ static void open_set_use_scripts(wmOperator *op) static int wm_open_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - const char *openname= G.main->name; + const char *openname = G.main->name; if (CTX_wm_window(C) == NULL) { /* in rare cases this could happen, when trying to invoke in background @@ -1633,7 +1633,7 @@ static void WM_OT_open_mainfile(wmOperatorType *ot) ot->exec = wm_open_mainfile_exec; /* ommit window poll so this can work in background mode */ - WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_OPENFILE, + WM_operator_properties_filesel(ot, FOLDERFILE | BLENDERFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); RNA_def_boolean(ot->srna, "load_ui", 1, "Load UI", "Load user interface setup in the .blend file"); @@ -1682,7 +1682,7 @@ static int wm_link_append_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(ev static short wm_link_append_flag(wmOperator *op) { - short flag= 0; + short flag = 0; if (RNA_boolean_get(op->ptr, "autoselect")) flag |= FILE_AUTOSELECT; if (RNA_boolean_get(op->ptr, "active_layer")) flag |= FILE_ACTIVELAY; @@ -1695,13 +1695,13 @@ static short wm_link_append_flag(wmOperator *op) static int wm_link_append_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - Main *mainl= NULL; + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + Main *mainl = NULL; BlendHandle *bh; PropertyRNA *prop; char name[FILE_MAX], dir[FILE_MAX], libname[FILE_MAX], group[GROUP_MAX]; - int idcode, totfiles=0; + int idcode, totfiles = 0; short flag; RNA_string_get(op->ptr, "filename", name); @@ -1724,7 +1724,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) /* check if something is indicated for append/link */ prop = RNA_struct_find_property(op->ptr, "files"); if (prop) { - totfiles= RNA_property_collection_length(op->ptr, prop); + totfiles = RNA_property_collection_length(op->ptr, prop); if (totfiles == 0) { if (name[0] == '\0') { BKE_report(op->reports, RPT_ERROR, "Nothing indicated"); @@ -1760,7 +1760,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) /* sanity checks for flag */ 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); + BKE_reportf(op->reports, RPT_WARNING, "Scene '%s' is linked, group instance disabled", scene->id.name + 2); flag &= ~FILE_GROUP_INSTANCE; } @@ -1789,10 +1789,10 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) recalc_all_library_objects(bmain); /* append, rather than linking */ - if ((flag & FILE_LINK)==0) { - Library *lib= BLI_findstring(&bmain->library, libname, offsetof(Library, filepath)); - if (lib) BKE_library_make_local(bmain, lib, 1); - else BLI_assert(!"cant find name of just added library!"); + if ((flag & FILE_LINK) == 0) { + Library *lib = BLI_findstring(&bmain->library, libname, offsetof(Library, filepath)); + if (lib) BKE_library_make_local(bmain, lib, 1); + else BLI_assert(!"cant find name of just added library!"); } /* important we unset, otherwise these object wont @@ -1826,9 +1826,9 @@ static void WM_OT_link_append(wmOperatorType *ot) ot->flag |= OPTYPE_UNDO; WM_operator_properties_filesel( - ot, FOLDERFILE|BLENDERFILE, FILE_LOADLIB, FILE_OPENFILE, - WM_FILESEL_FILEPATH|WM_FILESEL_DIRECTORY|WM_FILESEL_FILENAME|WM_FILESEL_RELPATH|WM_FILESEL_FILES, - FILE_DEFAULTDISPLAY); + ot, FOLDERFILE | BLENDERFILE, FILE_LOADLIB, FILE_OPENFILE, + WM_FILESEL_FILEPATH | WM_FILESEL_DIRECTORY | WM_FILESEL_FILENAME | WM_FILESEL_RELPATH | WM_FILESEL_FILES, + FILE_DEFAULTDISPLAY); RNA_def_boolean(ot->srna, "link", 1, "Link", "Link the objects or datablocks rather than appending"); RNA_def_boolean(ot->srna, "autoselect", 1, "Select", "Select the linked objects"); @@ -1916,8 +1916,8 @@ static void WM_OT_recover_auto_save(wmOperatorType *ot) static void untitled(char *name) { - if (G.save_over == 0 && strlen(name) < FILE_MAX-16) { - char *c= BLI_last_slash(name); + if (G.save_over == 0 && strlen(name) < FILE_MAX - 16) { + char *c = BLI_last_slash(name); if (c) strcpy(&c[1], "untitled.blend"); @@ -1943,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); } @@ -1963,7 +1963,7 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op) { char path[FILE_MAX]; int fileflags; - int copy=0; + int copy = 0; save_set_compress(op); @@ -1977,28 +1977,28 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op) if (RNA_struct_property_is_set(op->ptr, "copy")) copy = RNA_boolean_get(op->ptr, "copy"); - fileflags= G.fileflags; + fileflags = G.fileflags; /* set compression flag */ - 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; - else fileflags &= ~G_FILE_RELATIVE_REMAP; + 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; + 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; - else 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 { fileflags &= ~G_FILE_MESH_COMPAT; } #endif - if ( WM_write_file(C, path, fileflags, op->reports, copy) != 0) + if (WM_write_file(C, path, fileflags, op->reports, copy) != 0) return OPERATOR_CANCELLED; - WM_event_add_notifier(C, NC_WM|ND_FILESAVE, NULL); + WM_event_add_notifier(C, NC_WM | ND_FILESAVE, NULL); return OPERATOR_FINISHED; } @@ -2029,7 +2029,7 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot) ot->check = blend_save_check; /* ommit window poll so this can work in background mode */ - WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); + WM_operator_properties_filesel(ot, FOLDERFILE | BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); RNA_def_boolean(ot->srna, "compress", 0, "Compress", "Write compressed .blend file"); RNA_def_boolean(ot->srna, "relative_remap", 1, "Remap Relative", "Remap relative paths when saving in a different directory"); RNA_def_boolean(ot->srna, "copy", 0, "Save Copy", "Save a copy of the actual working state but does not make saved file active"); @@ -2043,7 +2043,7 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot) static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { char name[FILE_MAX]; - int check_existing=1; + int check_existing = 1; int ret; /* cancel if no active window */ @@ -2053,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); } @@ -2065,21 +2065,21 @@ static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED( RNA_string_set(op->ptr, "filepath", name); if (RNA_struct_find_property(op->ptr, "check_existing")) - if (RNA_boolean_get(op->ptr, "check_existing")==0) + if (RNA_boolean_get(op->ptr, "check_existing") == 0) check_existing = 0; if (G.save_over) { if (check_existing && BLI_exists(name)) { uiPupMenuSaveOver(C, op, name); - ret= OPERATOR_RUNNING_MODAL; + ret = OPERATOR_RUNNING_MODAL; } else { - ret= wm_save_as_mainfile_exec(C, op); + ret = wm_save_as_mainfile_exec(C, op); } } else { WM_event_add_fileselect(C, op); - ret= OPERATOR_RUNNING_MODAL; + ret = OPERATOR_RUNNING_MODAL; } return ret; @@ -2096,7 +2096,7 @@ static void WM_OT_save_mainfile(wmOperatorType *ot) ot->check = blend_save_check; /* ommit window poll so this can work in background mode */ - WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); + WM_operator_properties_filesel(ot, FOLDERFILE | BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); RNA_def_boolean(ot->srna, "compress", 0, "Compress", "Write compressed .blend file"); RNA_def_boolean(ot->srna, "relative_remap", 0, "Remap Relative", "Remap relative paths when saving in a different directory"); } @@ -2151,11 +2151,11 @@ static void WM_OT_collada_export(wmOperatorType *ot) ot->exec = wm_collada_export_exec; ot->poll = WM_operator_winactive; - WM_operator_properties_filesel(ot, FOLDERFILE|COLLADAFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); + WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); RNA_def_boolean(ot->srna, "selected", 0, "Export only selected", - "Export only selected elements"); + "Export only selected elements"); RNA_def_boolean(ot->srna, "second_life", 0, "Export for Second Life", - "Compatibility mode for Second Life"); + "Compatibility mode for Second Life"); } /* function used for WM_OT_save_mainfile too */ @@ -2185,7 +2185,7 @@ static void WM_OT_collada_import(wmOperatorType *ot) ot->exec = wm_collada_import_exec; ot->poll = WM_operator_winactive; - WM_operator_properties_filesel(ot, FOLDERFILE|COLLADAFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); + WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); } #endif @@ -2253,15 +2253,15 @@ static void WM_OT_console_toggle(wmOperatorType *ot) */ void *WM_paint_cursor_activate(wmWindowManager *wm, int (*poll)(bContext *C), - wmPaintCursorDraw draw, void *customdata) + wmPaintCursorDraw draw, void *customdata) { - wmPaintCursor *pc= MEM_callocN(sizeof(wmPaintCursor), "paint cursor"); + wmPaintCursor *pc = MEM_callocN(sizeof(wmPaintCursor), "paint cursor"); BLI_addtail(&wm->paintcursors, pc); pc->customdata = customdata; - pc->poll= poll; - pc->draw= draw; + pc->poll = poll; + pc->draw = draw; return pc; } @@ -2270,7 +2270,7 @@ void WM_paint_cursor_end(wmWindowManager *wm, void *handle) { wmPaintCursor *pc; - for (pc= wm->paintcursors.first; pc; pc= pc->next) { + for (pc = wm->paintcursors.first; pc; pc = pc->next) { if (pc == (wmPaintCursor *)handle) { BLI_remlink(&wm->paintcursors, pc); MEM_freeN(pc); @@ -2295,10 +2295,10 @@ void WM_paint_cursor_end(wmWindowManager *wm, void *handle) static int border_apply_rect(wmOperator *op) { - wmGesture *gesture= op->customdata; - rcti *rect= gesture->customdata; + 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; @@ -2317,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); @@ -2326,23 +2326,23 @@ static int border_apply(bContext *C, wmOperator *op, int gesture_mode) static void wm_gesture_end(bContext *C, wmOperator *op) { - wmGesture *gesture= op->customdata; + wmGesture *gesture = op->customdata; - WM_gesture_end(C, gesture); /* frees gesture itself, and unregisters from window */ - op->customdata= NULL; + WM_gesture_end(C, gesture); /* frees gesture itself, and unregisters from window */ + op->customdata = NULL; 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)) - op->customdata= WM_gesture_new(C, event, WM_GESTURE_RECT); + op->customdata = WM_gesture_new(C, event, WM_GESTURE_RECT); else - op->customdata= WM_gesture_new(C, event, WM_GESTURE_CROSS_RECT); + op->customdata = WM_gesture_new(C, event, WM_GESTURE_CROSS_RECT); /* add modal handler */ WM_event_add_modal_handler(C, op); @@ -2354,14 +2354,14 @@ int WM_border_select_invoke(bContext *C, wmOperator *op, wmEvent *event) int WM_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) { - wmGesture *gesture= op->customdata; - rcti *rect= gesture->customdata; + wmGesture *gesture = op->customdata; + 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; } @@ -2373,29 +2373,29 @@ int WM_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) wm_gesture_tag_redraw(C); } - else if (event->type==EVT_MODAL_MAP) { + else if (event->type == EVT_MODAL_MAP) { switch (event->val) { - case GESTURE_MODAL_BEGIN: - if (gesture->type==WM_GESTURE_CROSS_RECT && gesture->mode==0) { - gesture->mode= 1; - wm_gesture_tag_redraw(C); - } - break; - case GESTURE_MODAL_SELECT: - case GESTURE_MODAL_DESELECT: - case GESTURE_MODAL_IN: - case GESTURE_MODAL_OUT: - if (border_apply(C, op, event->val)) { + case GESTURE_MODAL_BEGIN: + if (gesture->type == WM_GESTURE_CROSS_RECT && gesture->mode == 0) { + gesture->mode = 1; + wm_gesture_tag_redraw(C); + } + break; + case GESTURE_MODAL_SELECT: + case GESTURE_MODAL_DESELECT: + case GESTURE_MODAL_IN: + case GESTURE_MODAL_OUT: + if (border_apply(C, op, event->val)) { + wm_gesture_end(C, op); + return OPERATOR_FINISHED; + } wm_gesture_end(C, op); - return OPERATOR_FINISHED; - } - wm_gesture_end(C, op); - return OPERATOR_CANCELLED; - break; + return OPERATOR_CANCELLED; + break; - case GESTURE_MODAL_CANCEL: - wm_gesture_end(C, op); - return OPERATOR_CANCELLED; + case GESTURE_MODAL_CANCEL: + wm_gesture_end(C, op); + return OPERATOR_CANCELLED; } } @@ -2418,12 +2418,12 @@ int WM_border_select_cancel(bContext *C, wmOperator *op) /* works now only for selection or modal paint stuff, calls exec while hold mouse, exit on release */ #ifdef GESTURE_MEMORY -int circle_select_size= 25; // XXX - need some operator memory thing\! +int circle_select_size = 25; // XXX - need some operator memory thing\! #endif int WM_gesture_circle_invoke(bContext *C, wmOperator *op, wmEvent *event) { - op->customdata= WM_gesture_new(C, event, WM_GESTURE_CIRCLE); + op->customdata = WM_gesture_new(C, event, WM_GESTURE_CIRCLE); /* add modal handler */ WM_event_add_modal_handler(C, op); @@ -2435,10 +2435,10 @@ int WM_gesture_circle_invoke(bContext *C, wmOperator *op, wmEvent *event) static void gesture_circle_apply(bContext *C, wmOperator *op) { - wmGesture *gesture= op->customdata; - rcti *rect= gesture->customdata; + 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. */ @@ -2449,17 +2449,17 @@ static void gesture_circle_apply(bContext *C, wmOperator *op) if (op->type->exec) op->type->exec(C, op); #ifdef GESTURE_MEMORY - circle_select_size= rect->xmax; + circle_select_size = rect->xmax; #endif } int WM_gesture_circle_modal(bContext *C, wmOperator *op, wmEvent *event) { - wmGesture *gesture= op->customdata; - rcti *rect= gesture->customdata; + wmGesture *gesture = op->customdata; + 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; @@ -2470,35 +2470,35 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, wmEvent *event) if (gesture->mode) gesture_circle_apply(C, op); } - else if (event->type==EVT_MODAL_MAP) { + else if (event->type == EVT_MODAL_MAP) { switch (event->val) { - case GESTURE_MODAL_CIRCLE_ADD: - rect->xmax += 2 + rect->xmax/10; - wm_gesture_tag_redraw(C); - break; - case GESTURE_MODAL_CIRCLE_SUB: - rect->xmax -= 2 + rect->xmax/10; - 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")) - RNA_int_set(op->ptr, "gesture_mode", event->val); - - if (event->val != GESTURE_MODAL_NOP) { - /* apply first click */ - gesture_circle_apply(C, op); - gesture->mode= 1; + case GESTURE_MODAL_CIRCLE_ADD: + rect->xmax += 2 + rect->xmax / 10; wm_gesture_tag_redraw(C); - } - break; + break; + case GESTURE_MODAL_CIRCLE_SUB: + rect->xmax -= 2 + rect->xmax / 10; + 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")) + RNA_int_set(op->ptr, "gesture_mode", event->val); + + if (event->val != GESTURE_MODAL_NOP) { + /* apply first click */ + gesture_circle_apply(C, op); + gesture->mode = 1; + wm_gesture_tag_redraw(C); + } + break; - case GESTURE_MODAL_CANCEL: - case GESTURE_MODAL_CONFIRM: - wm_gesture_end(C, op); - return OPERATOR_FINISHED; /* use finish or we don't get an undo */ + case GESTURE_MODAL_CANCEL: + case GESTURE_MODAL_CONFIRM: + wm_gesture_end(C, op); + return OPERATOR_FINISHED; /* use finish or we don't get an undo */ } } // // Allow view navigation??? @@ -2540,12 +2540,12 @@ void WM_OT_circle_gesture(wmOperatorType *ot) static void tweak_gesture_modal(bContext *C, wmEvent *event) { - wmWindow *window= CTX_wm_window(C); - wmGesture *gesture= window->tweak; - rcti *rect= gesture->customdata; + wmWindow *window = CTX_wm_window(C); + wmGesture *gesture = window->tweak; + rcti *rect = gesture->customdata; int sx, sy, val; - switch(event->type) { + switch (event->type) { case MOUSEMOVE: case INBETWEEN_MOUSEMOVE: @@ -2554,21 +2554,21 @@ 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) - tevent.type= EVT_TWEAK_L; - else if (gesture->event_type==RIGHTMOUSE) - tevent.type= EVT_TWEAK_R; + tevent = *(window->eventstate); + if (gesture->event_type == LEFTMOUSE) + tevent.type = EVT_TWEAK_L; + else if (gesture->event_type == RIGHTMOUSE) + tevent.type = EVT_TWEAK_R; else - tevent.type= EVT_TWEAK_M; - tevent.val= val; + tevent.type = EVT_TWEAK_M; + tevent.val = val; /* mouse coords! */ wm_event_add(window, &tevent); - WM_gesture_end(C, gesture); /* frees gesture itself, and unregisters from window */ + WM_gesture_end(C, gesture); /* frees gesture itself, and unregisters from window */ } break; @@ -2576,11 +2576,11 @@ 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 */ - event->val= KM_RELEASE; + event->val = KM_RELEASE; } break; default: @@ -2594,13 +2594,13 @@ static void tweak_gesture_modal(bContext *C, wmEvent *event) /* standard tweak, called after window handlers passed on event */ void wm_tweakevent_test(bContext *C, wmEvent *event, int action) { - wmWindow *win= CTX_wm_window(C); + wmWindow *win = CTX_wm_window(C); - if (win->tweak==NULL) { + 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); + if (event->val == KM_PRESS) { + if (ELEM3(event->type, LEFTMOUSE, MIDDLEMOUSE, RIGHTMOUSE) ) + win->tweak = WM_gesture_new(C, event, WM_GESTURE_TWEAK); } } } @@ -2618,14 +2618,14 @@ void wm_tweakevent_test(bContext *C, wmEvent *event, int action) int WM_gesture_lasso_invoke(bContext *C, wmOperator *op, wmEvent *event) { - op->customdata= WM_gesture_new(C, event, WM_GESTURE_LASSO); + op->customdata = WM_gesture_new(C, event, WM_GESTURE_LASSO); /* add modal handler */ WM_event_add_modal_handler(C, op); 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; @@ -2633,14 +2633,14 @@ int WM_gesture_lasso_invoke(bContext *C, wmOperator *op, wmEvent *event) int WM_gesture_lines_invoke(bContext *C, wmOperator *op, wmEvent *event) { - op->customdata= WM_gesture_new(C, event, WM_GESTURE_LINES); + op->customdata = WM_gesture_new(C, event, WM_GESTURE_LINES); /* add modal handler */ WM_event_add_modal_handler(C, op); 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; @@ -2649,18 +2649,18 @@ int WM_gesture_lines_invoke(bContext *C, wmOperator *op, wmEvent *event) static void gesture_lasso_apply(bContext *C, wmOperator *op) { - wmGesture *gesture= op->customdata; + wmGesture *gesture = op->customdata; PointerRNA itemptr; float loc[2]; int i; - short *lasso= gesture->customdata; + short *lasso = gesture->customdata; /* operator storage as path. */ RNA_collection_clear(op->ptr, "path"); - for (i=0; i<gesture->points; i++, lasso+=2) { - loc[0]= lasso[0]; - loc[1]= lasso[1]; + for (i = 0; i < gesture->points; i++, lasso += 2) { + loc[0] = lasso[0]; + loc[1] = lasso[1]; RNA_collection_add(op->ptr, "path", &itemptr); RNA_float_set_array(&itemptr, "loc", loc); } @@ -2673,10 +2673,10 @@ static void gesture_lasso_apply(bContext *C, wmOperator *op) int WM_gesture_lasso_modal(bContext *C, wmOperator *op, wmEvent *event) { - wmGesture *gesture= op->customdata; + wmGesture *gesture = op->customdata; int sx, sy; - switch(event->type) { + switch (event->type) { case MOUSEMOVE: case INBETWEEN_MOUSEMOVE: @@ -2686,8 +2686,8 @@ int WM_gesture_lasso_modal(bContext *C, wmOperator *op, wmEvent *event) 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); + 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); gesture->size = gesture->size + WM_LASSO_MIN_POINTS; MEM_freeN(old_lasso); // printf("realloc\n"); @@ -2695,7 +2695,7 @@ int WM_gesture_lasso_modal(bContext *C, wmOperator *op, wmEvent *event) { int x, y; - short *lasso= gesture->customdata; + short *lasso = gesture->customdata; lasso += (2 * gesture->points - 2); x = (event->x - sx - lasso[0]); @@ -2703,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; @@ -2715,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; } @@ -2751,7 +2751,8 @@ int WM_gesture_lines_cancel(bContext *C, wmOperator *op) static int gesture_lasso_exec(bContext *C, wmOperator *op) { - RNA_BEGIN(op->ptr, itemptr, "path") { + RNA_BEGIN(op->ptr, itemptr, "path") + { float loc[2]; RNA_float_get_array(&itemptr, "loc", loc); @@ -2776,7 +2777,7 @@ void WM_OT_lasso_gesture(wmOperatorType *ot) ot->poll = WM_operator_winactive; - prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE); + prop = RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath); } #endif @@ -2785,10 +2786,10 @@ void WM_OT_lasso_gesture(wmOperatorType *ot) static int straightline_apply(bContext *C, wmOperator *op) { - wmGesture *gesture= op->customdata; - rcti *rect= gesture->customdata; + 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. */ @@ -2806,14 +2807,14 @@ static int straightline_apply(bContext *C, wmOperator *op) int WM_gesture_straightline_invoke(bContext *C, wmOperator *op, wmEvent *event) { - op->customdata= WM_gesture_new(C, event, WM_GESTURE_STRAIGHTLINE); + op->customdata = WM_gesture_new(C, event, WM_GESTURE_STRAIGHTLINE); /* add modal handler */ WM_event_add_modal_handler(C, op); 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; @@ -2821,14 +2822,14 @@ int WM_gesture_straightline_invoke(bContext *C, wmOperator *op, wmEvent *event) int WM_gesture_straightline_modal(bContext *C, wmOperator *op, wmEvent *event) { - wmGesture *gesture= op->customdata; - rcti *rect= gesture->customdata; + wmGesture *gesture = op->customdata; + 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; } @@ -2840,11 +2841,11 @@ int WM_gesture_straightline_modal(bContext *C, wmOperator *op, wmEvent *event) wm_gesture_tag_redraw(C); } - else if (event->type==EVT_MODAL_MAP) { + else if (event->type == EVT_MODAL_MAP) { switch (event->val) { case GESTURE_MODAL_BEGIN: - if (gesture->mode==0) { - gesture->mode= 1; + if (gesture->mode == 0) { + gesture->mode = 1; wm_gesture_tag_redraw(C); } break; @@ -2916,22 +2917,22 @@ static void radial_control_set_initial_mouse(RadialControl *rc, wmEvent *event) float d[2] = {0, 0}; float zoom[2] = {1, 1}; - rc->initial_mouse[0]= event->x; - rc->initial_mouse[1]= event->y; - - switch(rc->subtype) { - case PROP_DISTANCE: - d[0] = rc->initial_value; - break; - case PROP_FACTOR: - d[0] = WM_RADIAL_CONTROL_DISPLAY_SIZE * (1 - rc->initial_value); - break; - case PROP_ANGLE: - d[0] = WM_RADIAL_CONTROL_DISPLAY_SIZE * cos(rc->initial_value); - d[1] = WM_RADIAL_CONTROL_DISPLAY_SIZE * sin(rc->initial_value); - break; - default: - return; + rc->initial_mouse[0] = event->x; + rc->initial_mouse[1] = event->y; + + switch (rc->subtype) { + case PROP_DISTANCE: + d[0] = rc->initial_value; + break; + case PROP_FACTOR: + d[0] = WM_RADIAL_CONTROL_DISPLAY_SIZE * (1 - rc->initial_value); + break; + case PROP_ANGLE: + d[0] = WM_RADIAL_CONTROL_DISPLAY_SIZE * cos(rc->initial_value); + d[1] = WM_RADIAL_CONTROL_DISPLAY_SIZE * sin(rc->initial_value); + break; + default: + return; } if (rc->zoom_prop) { @@ -2940,27 +2941,27 @@ static void radial_control_set_initial_mouse(RadialControl *rc, wmEvent *event) d[1] *= zoom[1]; } - rc->initial_mouse[0]-= d[0]; - rc->initial_mouse[1]-= d[1]; + rc->initial_mouse[0] -= d[0]; + rc->initial_mouse[1] -= d[1]; } static void radial_control_set_tex(RadialControl *rc) { ImBuf *ibuf; - 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))) { - glGenTextures(1, &rc->gltex); - glBindTexture(GL_TEXTURE_2D, rc->gltex); - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, ibuf->x, ibuf->y, 0, - GL_ALPHA, GL_FLOAT, ibuf->rect_float); - MEM_freeN(ibuf->rect_float); - MEM_freeN(ibuf); - } - break; - default: - break; + 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))) { + glGenTextures(1, &rc->gltex); + glBindTexture(GL_TEXTURE_2D, rc->gltex); + glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, ibuf->x, ibuf->y, 0, + GL_ALPHA, GL_FLOAT, ibuf->rect_float); + MEM_freeN(ibuf->rect_float); + MEM_freeN(ibuf); + } + break; + default: + break; } } @@ -2990,13 +2991,13 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph /* draw textured quad */ glEnable(GL_TEXTURE_2D); glBegin(GL_QUADS); - glTexCoord2f(0,0); + glTexCoord2f(0, 0); glVertex2f(-radius, -radius); - glTexCoord2f(1,0); + glTexCoord2f(1, 0); glVertex2f(radius, -radius); - glTexCoord2f(1,1); + glTexCoord2f(1, 1); glVertex2f(radius, radius); - glTexCoord2f(0,1); + glTexCoord2f(0, 1); glVertex2f(-radius, radius); glEnd(); glDisable(GL_TEXTURE_2D); @@ -3015,29 +3016,29 @@ static void radial_control_paint_cursor(bContext *C, int x, int y, void *customd { RadialControl *rc = customdata; ARegion *ar = CTX_wm_region(C); - float r1=0.0f, r2=0.0f, tex_radius, alpha; + float r1 = 0.0f, r2 = 0.0f, tex_radius, alpha; float zoom[2], col[3] = {1, 1, 1}; - switch(rc->subtype) { - case PROP_DISTANCE: - r1= rc->current_value; - r2= rc->initial_value; - tex_radius= r1; - alpha = 0.75; - break; - case PROP_FACTOR: - r1= (1 - rc->current_value) * WM_RADIAL_CONTROL_DISPLAY_SIZE; - r2= tex_radius= WM_RADIAL_CONTROL_DISPLAY_SIZE; - alpha = rc->current_value / 2.0f + 0.5f; - break; - case PROP_ANGLE: - r1= r2= tex_radius= WM_RADIAL_CONTROL_DISPLAY_SIZE; - alpha = 0.75; - break; - default: - tex_radius= WM_RADIAL_CONTROL_DISPLAY_SIZE; /* note, this is a dummy value */ - alpha = 0.75; - break; + switch (rc->subtype) { + case PROP_DISTANCE: + r1 = rc->current_value; + r2 = rc->initial_value; + tex_radius = r1; + alpha = 0.75; + break; + case PROP_FACTOR: + r1 = (1 - rc->current_value) * WM_RADIAL_CONTROL_DISPLAY_SIZE; + r2 = tex_radius = WM_RADIAL_CONTROL_DISPLAY_SIZE; + alpha = rc->current_value / 2.0f + 0.5f; + break; + case PROP_ANGLE: + r1 = r2 = tex_radius = WM_RADIAL_CONTROL_DISPLAY_SIZE; + alpha = 0.75; + break; + default: + tex_radius = WM_RADIAL_CONTROL_DISPLAY_SIZE; /* note, this is a dummy value */ + alpha = 0.75; + break; } /* Keep cursor in the original place */ @@ -3074,8 +3075,8 @@ static void radial_control_paint_cursor(bContext *C, int x, int y, void *customd } /* draw circles on top */ - glutil_draw_lined_arc(0.0, (float)(M_PI*2.0), r1, 40); - glutil_draw_lined_arc(0.0, (float)(M_PI*2.0), r2, 40); + glutil_draw_lined_arc(0.0, (float)(M_PI * 2.0), r1, 40); + glutil_draw_lined_arc(0.0, (float)(M_PI * 2.0), r2, 40); glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); @@ -3091,8 +3092,8 @@ typedef enum { * returns 0 for failure, 1 for success, and also 1 if property is not * set */ static int radial_control_get_path(PointerRNA *ctx_ptr, wmOperator *op, - const char *name, PointerRNA *r_ptr, - PropertyRNA **r_prop, int req_length, RCPropFlags flags) + const char *name, PointerRNA *r_ptr, + PropertyRNA **r_prop, int req_length, RCPropFlags flags) { PropertyRNA *unused_prop; int len; @@ -3133,10 +3134,10 @@ static int radial_control_get_path(PointerRNA *ctx_ptr, wmOperator *op, PropertyType prop_type = RNA_property_type(*r_prop); if (((flags & RC_PROP_REQUIRE_BOOL) && (prop_type != PROP_BOOLEAN)) || - ((flags & RC_PROP_REQUIRE_FLOAT) && prop_type != PROP_FLOAT)) { + ((flags & RC_PROP_REQUIRE_FLOAT) && prop_type != PROP_FLOAT)) { MEM_freeN(str); BKE_reportf(op->reports, RPT_ERROR, - "Property from path %s is not a float", name); + "Property from path %s is not a float", name); return 0; } } @@ -3167,14 +3168,15 @@ static int radial_control_get_properties(bContext *C, wmOperator *op) /* check if we use primary or secondary path */ 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))) { + &use_secondary_ptr, &use_secondary_prop, + 0, (RC_PROP_ALLOW_MISSING | + RC_PROP_REQUIRE_BOOL))) + { return 0; } else { if (use_secondary_prop && - RNA_property_boolean_get(&use_secondary_ptr, use_secondary_prop)) + RNA_property_boolean_get(&use_secondary_ptr, use_secondary_prop)) data_path = "data_path_secondary"; else data_path = "data_path_primary"; @@ -3198,8 +3200,8 @@ static int radial_control_get_properties(bContext *C, wmOperator *op) * correctly. needed because 3d texture paint shares the same * keymap as 2d image paint */ 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)) + &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)) @@ -3208,7 +3210,7 @@ static int radial_control_get_properties(bContext *C, wmOperator *op) /* extra check, pointer must be to an ID */ 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"); + "Pointer from path image_id is not an ID"); return 0; } } @@ -3232,23 +3234,23 @@ static int radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) } /* get type, initial, min, and max values of the property */ - switch((rc->type = RNA_property_type(rc->prop))) { - case PROP_INT: - rc->initial_value = RNA_property_int_get(&rc->ptr, rc->prop); - RNA_property_int_ui_range(&rc->ptr, rc->prop, &min_value_int, - &max_value_int, &step_int); - rc->min_value = min_value_int; - rc->max_value = max_value_int; - break; - case PROP_FLOAT: - rc->initial_value = RNA_property_float_get(&rc->ptr, rc->prop); - RNA_property_float_ui_range(&rc->ptr, rc->prop, &rc->min_value, - &rc->max_value, &step_float, &precision); - break; - default: - BKE_report(op->reports, RPT_ERROR, "Property must be an integer or a float"); - MEM_freeN(rc); - return OPERATOR_CANCELLED; + switch ((rc->type = RNA_property_type(rc->prop))) { + case PROP_INT: + rc->initial_value = RNA_property_int_get(&rc->ptr, rc->prop); + RNA_property_int_ui_range(&rc->ptr, rc->prop, &min_value_int, + &max_value_int, &step_int); + rc->min_value = min_value_int; + rc->max_value = max_value_int; + break; + case PROP_FLOAT: + rc->initial_value = RNA_property_float_get(&rc->ptr, rc->prop); + RNA_property_float_ui_range(&rc->ptr, rc->prop, &rc->min_value, + &rc->max_value, &step_float, &precision); + break; + default: + BKE_report(op->reports, RPT_ERROR, "Property must be an integer or a float"); + MEM_freeN(rc); + return OPERATOR_CANCELLED; } /* get subtype of property */ @@ -3270,7 +3272,7 @@ static int radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) /* add radial control paint cursor */ rc->cursor = WM_paint_cursor_activate(wm, op->type->poll, - radial_control_paint_cursor, rc); + radial_control_paint_cursor, rc); WM_event_add_modal_handler(C, op); @@ -3279,15 +3281,15 @@ static int radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) static void radial_control_set_value(RadialControl *rc, float val) { - switch(rc->type) { - case PROP_INT: - RNA_property_int_set(&rc->ptr, rc->prop, val); - break; - case PROP_FLOAT: - RNA_property_float_set(&rc->ptr, rc->prop, val); - break; - default: - break; + switch (rc->type) { + case PROP_INT: + RNA_property_int_set(&rc->ptr, rc->prop, val); + break; + case PROP_FLOAT: + RNA_property_float_set(&rc->ptr, rc->prop, val); + break; + default: + break; } } @@ -3323,56 +3325,56 @@ static int radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) snap = event->ctrl; - switch(event->type) { - case MOUSEMOVE: - delta[0]= rc->initial_mouse[0] - event->x; - delta[1]= rc->initial_mouse[1] - event->y; + switch (event->type) { + case MOUSEMOVE: + delta[0] = rc->initial_mouse[0] - event->x; + delta[1] = rc->initial_mouse[1] - event->y; - if (rc->zoom_prop) { - RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom); - delta[0] /= zoom[0]; - delta[1] /= zoom[1]; - } + if (rc->zoom_prop) { + RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom); + delta[0] /= zoom[0]; + delta[1] /= zoom[1]; + } - dist= sqrt(delta[0]*delta[0]+delta[1]*delta[1]); + dist = sqrt(delta[0] * delta[0] + delta[1] * delta[1]); - /* calculate new value and apply snapping */ - switch(rc->subtype) { - case PROP_DISTANCE: - new_value = dist; - 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; - 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); + /* calculate new value and apply snapping */ + switch (rc->subtype) { + case PROP_DISTANCE: + new_value = dist; + 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; + 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); + break; + default: + new_value = dist; /* dummy value, should this ever happen? - campbell */ + break; + } + + /* clamp and update */ + CLAMP(new_value, rc->min_value, rc->max_value); + radial_control_set_value(rc, new_value); + rc->current_value = new_value; break; - default: - new_value = dist; /* dummy value, should this ever happen? - campbell */ + + case ESCKEY: + case RIGHTMOUSE: + /* canceled; restore original value */ + radial_control_set_value(rc, rc->initial_value); + ret = OPERATOR_CANCELLED; break; - } - /* clamp and update */ - CLAMP(new_value, rc->min_value, rc->max_value); - radial_control_set_value(rc, new_value); - rc->current_value = new_value; - break; - - case ESCKEY: - case RIGHTMOUSE: - /* canceled; restore original value */ - radial_control_set_value(rc, rc->initial_value); - ret = OPERATOR_CANCELLED; - break; - - case LEFTMOUSE: - case PADENTER: - /* done; value already set */ - ret = OPERATOR_FINISHED; - break; + case LEFTMOUSE: + case PADENTER: + /* done; value already set */ + ret = OPERATOR_FINISHED; + break; } ED_region_tag_redraw(CTX_wm_region(C)); @@ -3392,7 +3394,7 @@ static void WM_OT_radial_control(wmOperatorType *ot) ot->modal = radial_control_modal; ot->cancel = radial_control_cancel; - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* all paths relative to the context */ RNA_def_string(ot->srna, "data_path_primary", "", 0, "Primary Data Path", "Primary path of property to be set by the radial control"); @@ -3411,14 +3413,14 @@ static void WM_OT_radial_control(wmOperatorType *ot) static void redraw_timer_window_swap(bContext *C) { - wmWindow *win= CTX_wm_window(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); - CTX_wm_window_set(C, win); /* XXX context manipulation warning! */ + CTX_wm_window_set(C, win); /* XXX context manipulation warning! */ } static EnumPropertyItem redraw_timer_type_items[] = { @@ -3429,45 +3431,46 @@ static EnumPropertyItem redraw_timer_type_items[] = { {4, "ANIM_STEP", 0, "Anim Step", "Animation Steps"}, {5, "ANIM_PLAY", 0, "Anim Play", "Animation Playback"}, {6, "UNDO", 0, "Undo/Redo", "Undo/Redo"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; static int redraw_timer_exec(bContext *C, wmOperator *op) { - ARegion *ar= CTX_wm_region(C); - double stime= PIL_check_seconds_timer(); + ARegion *ar = CTX_wm_region(C); + double stime = PIL_check_seconds_timer(); int type = RNA_enum_get(op->ptr, "type"); int iter = RNA_int_get(op->ptr, "iterations"); int a; float time; - const char *infostr= ""; + const char *infostr = ""; WM_cursor_wait(1); - for (a=0; a<iter; a++) { - if (type==0) { + for (a = 0; a < iter; a++) { + if (type == 0) { if (ar) ED_region_do_draw(C, ar); } - else if (type==1) { - wmWindow *win= CTX_wm_window(C); + else if (type == 1) { + wmWindow *win = CTX_wm_window(C); ED_region_tag_redraw(ar); wm_draw_update(C); - CTX_wm_window_set(C, win); /* XXX context manipulation warning! */ + CTX_wm_window_set(C, win); /* XXX context manipulation warning! */ } - else if (type==2) { - wmWindow *win= CTX_wm_window(C); + else if (type == 2) { + wmWindow *win = CTX_wm_window(C); ScrArea *sa; - ScrArea *sa_back= CTX_wm_area(C); - ARegion *ar_back= CTX_wm_region(C); + ScrArea *sa_back = CTX_wm_area(C); + ARegion *ar_back = CTX_wm_region(C); - for (sa= CTX_wm_screen(C)->areabase.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) { + 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); @@ -3475,34 +3478,34 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) } } - CTX_wm_window_set(C, win); /* XXX context manipulation warning! */ + CTX_wm_window_set(C, win); /* XXX context manipulation warning! */ CTX_wm_area_set(C, sa_back); CTX_wm_region_set(C, ar_back); } - else if (type==3) { + else if (type == 3) { redraw_timer_window_swap(C); } - else if (type==4) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + else if (type == 4) { + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); if (a & 1) scene->r.cfra--; else scene->r.cfra++; scene_update_for_newframe(bmain, scene, scene->lay); } - else if (type==5) { + else if (type == 5) { /* play anim, return on same frame as started with */ - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - int tot= (scene->r.efra - scene->r.sfra) + 1; + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + int tot = (scene->r.efra - scene->r.sfra) + 1; while (tot--) { /* todo, ability to escape! */ scene->r.cfra++; if (scene->r.cfra > scene->r.efra) - scene->r.cfra= scene->r.sfra; + scene->r.cfra = scene->r.sfra; scene_update_for_newframe(bmain, scene, scene->lay); redraw_timer_window_swap(C); @@ -3514,13 +3517,13 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) } } - time= (float)((PIL_check_seconds_timer()-stime)*1000); + time = (float)((PIL_check_seconds_timer() - stime) * 1000); RNA_enum_description(redraw_timer_type_items, type, &infostr); WM_cursor_wait(0); - BKE_reportf(op->reports, RPT_WARNING, "%d x %s: %.2f ms, average: %.4f", iter, infostr, time, time/iter); + BKE_reportf(op->reports, RPT_WARNING, "%d x %s: %.2f ms, average: %.4f", iter, infostr, time, time / iter); return OPERATOR_FINISHED; } @@ -3536,7 +3539,7 @@ static void WM_OT_redraw_timer(wmOperatorType *ot) ot->poll = WM_operator_winactive; ot->prop = RNA_def_enum(ot->srna, "type", redraw_timer_type_items, 0, "Type", ""); - RNA_def_int(ot->srna, "iterations", 10, 1,INT_MAX, "Iterations", "Number of times to redraw", 1,1000); + RNA_def_int(ot->srna, "iterations", 10, 1, INT_MAX, "Iterations", "Number of times to redraw", 1, 1000); } @@ -3561,9 +3564,9 @@ static void WM_OT_memory_statistics(wmOperatorType *ot) static int dependency_relations_exec(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + Object *ob = CTX_data_active_object(C); DAG_print_dependencies(bmain, scene, ob); @@ -3588,9 +3591,9 @@ static int wm_ndof_sensitivity_exec(bContext *UNUSED(C), wmOperator *op) float sensitivity = U.ndof_sensitivity; if (RNA_boolean_get(op->ptr, "fast")) - change = 0.5f; // 50% change + change = 0.5f; // 50% change else - change = 0.1f; // 10% + change = 0.1f; // 10% if (RNA_boolean_get(op->ptr, "decrease")) { sensitivity -= sensitivity * change; @@ -3644,13 +3647,13 @@ static void operatortype_ghash_free_cb(wmOperatorType *ot) void wm_operatortype_free(void) { BLI_ghash_free(global_ops_hash, NULL, (GHashValFreeFP)operatortype_ghash_free_cb); - global_ops_hash= NULL; + global_ops_hash = NULL; } /* called on initialize WM_init() */ void wm_operatortype_init(void) { - global_ops_hash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "wm_operatortype_init gh"); + global_ops_hash = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "wm_operatortype_init gh"); WM_operatortype_append(WM_OT_window_duplicate); WM_operatortype_append(WM_OT_read_homefile); @@ -3688,24 +3691,23 @@ void wm_operatortype_init(void) static void gesture_circle_modal_keymap(wmKeyConfig *keyconf) { static EnumPropertyItem modal_items[] = { - {GESTURE_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, - {GESTURE_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, - {GESTURE_MODAL_CIRCLE_ADD, "ADD", 0, "Add", ""}, - {GESTURE_MODAL_CIRCLE_SUB, "SUBTRACT", 0, "Subtract", ""}, - - {GESTURE_MODAL_SELECT, "SELECT", 0, "Select", ""}, - {GESTURE_MODAL_DESELECT,"DESELECT", 0, "DeSelect", ""}, - {GESTURE_MODAL_NOP,"NOP", 0, "No Operation", ""}, + {GESTURE_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, + {GESTURE_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, + {GESTURE_MODAL_CIRCLE_ADD, "ADD", 0, "Add", ""}, + {GESTURE_MODAL_CIRCLE_SUB, "SUBTRACT", 0, "Subtract", ""}, + {GESTURE_MODAL_SELECT, "SELECT", 0, "Select", ""}, + {GESTURE_MODAL_DESELECT, "DESELECT", 0, "DeSelect", ""}, + {GESTURE_MODAL_NOP, "NOP", 0, "No Operation", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL}}; - wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "View3D Gesture Circle"); + 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; - keymap= WM_modalkeymap_add(keyconf, "View3D Gesture Circle", modal_items); + keymap = WM_modalkeymap_add(keyconf, "View3D Gesture Circle", modal_items); /* items for modal map */ WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, GESTURE_MODAL_CANCEL); @@ -3742,17 +3744,17 @@ static void gesture_circle_modal_keymap(wmKeyConfig *keyconf) static void gesture_straightline_modal_keymap(wmKeyConfig *keyconf) { static EnumPropertyItem modal_items[] = { - {GESTURE_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, - {GESTURE_MODAL_SELECT, "SELECT", 0, "Select", ""}, - {GESTURE_MODAL_BEGIN, "BEGIN", 0, "Begin", ""}, + {GESTURE_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, + {GESTURE_MODAL_SELECT, "SELECT", 0, "Select", ""}, + {GESTURE_MODAL_BEGIN, "BEGIN", 0, "Begin", ""}, {0, NULL, 0, NULL, NULL}}; - wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "Gesture Straight Line"); + 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; - keymap= WM_modalkeymap_add(keyconf, "Gesture Straight Line", modal_items); + keymap = WM_modalkeymap_add(keyconf, "Gesture Straight Line", modal_items); /* items for modal map */ WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, GESTURE_MODAL_CANCEL); @@ -3770,22 +3772,22 @@ static void gesture_straightline_modal_keymap(wmKeyConfig *keyconf) static void gesture_border_modal_keymap(wmKeyConfig *keyconf) { static EnumPropertyItem modal_items[] = { - {GESTURE_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, - {GESTURE_MODAL_SELECT, "SELECT", 0, "Select", ""}, - {GESTURE_MODAL_DESELECT,"DESELECT", 0, "DeSelect", ""}, - {GESTURE_MODAL_BEGIN, "BEGIN", 0, "Begin", ""}, - {0, NULL, 0, NULL, NULL}}; + {GESTURE_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, + {GESTURE_MODAL_SELECT, "SELECT", 0, "Select", ""}, + {GESTURE_MODAL_DESELECT, "DESELECT", 0, "DeSelect", ""}, + {GESTURE_MODAL_BEGIN, "BEGIN", 0, "Begin", ""}, + {0, NULL, 0, NULL, NULL}}; - wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "Gesture Border"); + wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Gesture Border"); /* this function is called for each spacetype, only needs to add map once */ if (keymap) return; - keymap= WM_modalkeymap_add(keyconf, "Gesture Border", modal_items); + keymap = WM_modalkeymap_add(keyconf, "Gesture Border", modal_items); /* items for modal map */ WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, GESTURE_MODAL_CANCEL); - /* Note: cancel only on press otherwise you cannot map this to RMB-gesture */ + /* Note: cancel only on press otherwise you cannot map this to RMB-gesture */ WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_PRESS, KM_ANY, 0, GESTURE_MODAL_CANCEL); WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_BEGIN); @@ -3829,18 +3831,18 @@ static void gesture_border_modal_keymap(wmKeyConfig *keyconf) static void gesture_zoom_border_modal_keymap(wmKeyConfig *keyconf) { static EnumPropertyItem modal_items[] = { - {GESTURE_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, - {GESTURE_MODAL_IN, "IN", 0, "In", ""}, - {GESTURE_MODAL_OUT, "OUT", 0, "Out", ""}, - {GESTURE_MODAL_BEGIN, "BEGIN", 0, "Begin", ""}, - {0, NULL, 0, NULL, NULL}}; + {GESTURE_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, + {GESTURE_MODAL_IN, "IN", 0, "In", ""}, + {GESTURE_MODAL_OUT, "OUT", 0, "Out", ""}, + {GESTURE_MODAL_BEGIN, "BEGIN", 0, "Begin", ""}, + {0, NULL, 0, NULL, NULL}}; - wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "Gesture Zoom Border"); + 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; - keymap= WM_modalkeymap_add(keyconf, "Gesture Zoom Border", modal_items); + keymap = WM_modalkeymap_add(keyconf, "Gesture Zoom Border", modal_items); /* items for modal map */ WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, GESTURE_MODAL_CANCEL); @@ -3864,38 +3866,38 @@ void wm_window_keymap(wmKeyConfig *keyconf) wmKeyMapItem *kmi; /* note, this doesn't replace existing keymap items */ - WM_keymap_verify_item(keymap, "WM_OT_window_duplicate", WKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); + WM_keymap_verify_item(keymap, "WM_OT_window_duplicate", WKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); #ifdef __APPLE__ WM_keymap_add_item(keymap, "WM_OT_read_homefile", NKEY, KM_PRESS, KM_OSKEY, 0); - WM_keymap_add_menu(keymap, "INFO_MT_file_open_recent", OKEY, KM_PRESS, KM_SHIFT|KM_OSKEY, 0); + WM_keymap_add_menu(keymap, "INFO_MT_file_open_recent", OKEY, KM_PRESS, KM_SHIFT | KM_OSKEY, 0); WM_keymap_add_item(keymap, "WM_OT_open_mainfile", OKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "WM_OT_save_mainfile", SKEY, KM_PRESS, KM_OSKEY, 0); - WM_keymap_add_item(keymap, "WM_OT_save_as_mainfile", SKEY, KM_PRESS, KM_SHIFT|KM_OSKEY, 0); + WM_keymap_add_item(keymap, "WM_OT_save_as_mainfile", SKEY, KM_PRESS, KM_SHIFT | KM_OSKEY, 0); WM_keymap_add_item(keymap, "WM_OT_quit_blender", QKEY, KM_PRESS, KM_OSKEY, 0); #endif WM_keymap_add_item(keymap, "WM_OT_read_homefile", NKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "WM_OT_save_homefile", UKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_menu(keymap, "INFO_MT_file_open_recent", OKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); + WM_keymap_add_menu(keymap, "INFO_MT_file_open_recent", OKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); WM_keymap_add_item(keymap, "WM_OT_open_mainfile", OKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "WM_OT_open_mainfile", F1KEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "WM_OT_link_append", OKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); + WM_keymap_add_item(keymap, "WM_OT_link_append", OKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); kmi = WM_keymap_add_item(keymap, "WM_OT_link_append", F1KEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "link", FALSE); RNA_boolean_set(kmi->ptr, "instance_groups", FALSE); WM_keymap_add_item(keymap, "WM_OT_save_mainfile", SKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "WM_OT_save_mainfile", WKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "WM_OT_save_as_mainfile", SKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); + WM_keymap_add_item(keymap, "WM_OT_save_as_mainfile", SKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); WM_keymap_add_item(keymap, "WM_OT_save_as_mainfile", F2KEY, KM_PRESS, 0, 0); - kmi = WM_keymap_add_item(keymap, "WM_OT_save_as_mainfile", SKEY, KM_PRESS, KM_ALT|KM_CTRL, 0); + kmi = WM_keymap_add_item(keymap, "WM_OT_save_as_mainfile", SKEY, KM_PRESS, KM_ALT | KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "copy", TRUE); WM_keymap_verify_item(keymap, "WM_OT_window_fullscreen_toggle", F11KEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "WM_OT_quit_blender", QKEY, KM_PRESS, KM_CTRL, 0); /* debug/testing */ - WM_keymap_verify_item(keymap, "WM_OT_redraw_timer", TKEY, KM_PRESS, KM_ALT|KM_CTRL, 0); - WM_keymap_verify_item(keymap, "WM_OT_debug_menu", DKEY, KM_PRESS, KM_ALT|KM_CTRL, 0); + WM_keymap_verify_item(keymap, "WM_OT_redraw_timer", TKEY, KM_PRESS, KM_ALT | KM_CTRL, 0); + WM_keymap_verify_item(keymap, "WM_OT_debug_menu", DKEY, KM_PRESS, KM_ALT | KM_CTRL, 0); /* menus that can be accessed anywhere in blender */ WM_keymap_verify_item(keymap, "WM_OT_search_menu", SPACEKEY, KM_PRESS, 0, 0); @@ -3972,20 +3974,20 @@ void wm_window_keymap(wmKeyConfig *keyconf) /* Generic itemf's for operators that take library args */ static EnumPropertyItem *rna_id_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), int *do_free, ID *id, int local) { - EnumPropertyItem item_tmp= {0}, *item= NULL; - int totitem= 0; - int i= 0; + EnumPropertyItem item_tmp = {0}, *item = NULL; + int totitem = 0; + int i = 0; - for ( ; id; id= id->next) { - if (local==FALSE || id->lib==NULL) { - item_tmp.identifier= item_tmp.name= id->name+2; - item_tmp.value= i++; + 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); } } RNA_enum_item_end(&item, &totitem); - *do_free= 1; + *do_free = 1; return item; } diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c index 149c1355c06..564fa963d6e 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); @@ -105,35 +105,35 @@ 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; } void wm_subwindow_getsize(wmWindow *win, int swinid, int *x, int *y) { - wmSubWindow *swin= swin_from_swinid(win, swinid); + wmSubWindow *swin = swin_from_swinid(win, swinid); if (swin) { - *x= swin->winrct.xmax - swin->winrct.xmin + 1; - *y= swin->winrct.ymax - swin->winrct.ymin + 1; + *x = swin->winrct.xmax - swin->winrct.xmin + 1; + *y = swin->winrct.ymax - swin->winrct.ymin + 1; } } void wm_subwindow_getorigin(wmWindow *win, int swinid, int *x, int *y) { - wmSubWindow *swin= swin_from_swinid(win, swinid); + wmSubWindow *swin = swin_from_swinid(win, swinid); if (swin) { - *x= swin->winrct.xmin; - *y= swin->winrct.ymin; + *x = swin->winrct.xmin; + *y = swin->winrct.ymin; } } void wm_subwindow_getmatrix(wmWindow *win, int swinid, float mat[][4]) { - wmSubWindow *swin= swin_from_swinid(win, swinid); + wmSubWindow *swin = swin_from_swinid(win, swinid); if (swin) { /* used by UI, should find a better way to get the matrix there */ @@ -141,10 +141,10 @@ void wm_subwindow_getmatrix(wmWindow *win, int swinid, float mat[][4]) int width, height; wm_subwindow_getsize(win, swin->swinid, &width, &height); - orthographic_m4(mat, -0.375f, (float)width-0.375f, -0.375f, (float)height-0.375f, -100, 100); + orthographic_m4(mat, -0.375f, (float)width - 0.375f, -0.375f, (float)height - 0.375f, -100, 100); } else - glGetFloatv(GL_PROJECTION_MATRIX, (float*)mat); + glGetFloatv(GL_PROJECTION_MATRIX, (float *)mat); } } @@ -154,25 +154,25 @@ int wm_subwindow_open(wmWindow *win, rcti *winrct) { wmSubWindow *swin; int width, height; - int freewinid= 1; + int freewinid = 1; - for (swin= win->subwindows.first; swin; swin= swin->next) + for (swin = win->subwindows.first; swin; swin = swin->next) if (freewinid <= swin->swinid) - freewinid= swin->swinid+1; + freewinid = swin->swinid + 1; - win->curswin= swin= MEM_callocN(sizeof(wmSubWindow), "swinopen"); + win->curswin = swin = MEM_callocN(sizeof(wmSubWindow), "swinopen"); BLI_addtail(&win->subwindows, swin); if (G.f & G_DEBUG) printf("swin %d added\n", freewinid); - swin->swinid= freewinid; - swin->winrct= *winrct; + swin->swinid = freewinid; + swin->winrct = *winrct; /* and we appy it all right away */ wmSubWindowSet(win, swin->swinid); /* extra service */ wm_subwindow_getsize(win, swin->swinid, &width, &height); - wmOrtho2(-0.375f, (float)width-0.375f, -0.375f, (float)height-0.375f); + wmOrtho2(-0.375f, (float)width - 0.375f, -0.375f, (float)height - 0.375f); glLoadIdentity(); return swin->swinid; @@ -181,11 +181,11 @@ int wm_subwindow_open(wmWindow *win, rcti *winrct) void wm_subwindow_close(wmWindow *win, int swinid) { - wmSubWindow *swin= swin_from_swinid(win, swinid); + wmSubWindow *swin = swin_from_swinid(win, swinid); if (swin) { - if (swin==win->curswin) - win->curswin= NULL; + if (swin == win->curswin) + win->curswin = NULL; wm_subwindow_free(swin); BLI_remlink(&win->subwindows, swin); MEM_freeN(swin); @@ -199,12 +199,12 @@ void wm_subwindow_close(wmWindow *win, int swinid) /* pixels go from 0-99 for a 100 pixel window */ void wm_subwindow_position(wmWindow *win, int swinid, rcti *winrct) { - wmSubWindow *swin= swin_from_swinid(win, swinid); + wmSubWindow *swin = swin_from_swinid(win, swinid); if (swin) { int width, height; - swin->winrct= *winrct; + swin->winrct = *winrct; /* CRITICAL, this clamping ensures that * the viewport never goes outside the screen @@ -227,7 +227,7 @@ void wm_subwindow_position(wmWindow *win, int swinid, rcti *winrct) /* extra service */ wmSubWindowSet(win, swinid); wm_subwindow_getsize(win, swinid, &width, &height); - wmOrtho2(-0.375f, (float)width-0.375f, -0.375f, (float)height-0.375f); + wmOrtho2(-0.375f, (float)width - 0.375f, -0.375f, (float)height - 0.375f); } else { printf("wm_subwindow_position: Internal error, bad winid: %d\n", swinid); @@ -238,35 +238,35 @@ void wm_subwindow_position(wmWindow *win, int swinid, rcti *winrct) /* ----------------- exported in WM_api.h ------------------------------------------------------ */ /* internal state, no threaded opengl! XXX */ -static wmWindow *_curwindow= NULL; -static wmSubWindow *_curswin= NULL; +static wmWindow *_curwindow = NULL; +static wmSubWindow *_curswin = NULL; void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct) { int width, height; - _curswin= swin_from_swinid(win, swinid); + _curswin = swin_from_swinid(win, swinid); - if (_curswin==NULL) { + if (_curswin == NULL) { printf("wmSubWindowSet %d: doesn't exist\n", swinid); return; } - win->curswin= _curswin; - _curwindow= win; + win->curswin = _curswin; + _curwindow = win; - width= _curswin->winrct.xmax - _curswin->winrct.xmin + 1; - height= _curswin->winrct.ymax - _curswin->winrct.ymin + 1; + width = _curswin->winrct.xmax - _curswin->winrct.xmin + 1; + height = _curswin->winrct.ymax - _curswin->winrct.ymin + 1; glViewport(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height); if (srct) { - width= srct->xmax - srct->xmin + 1; - height= srct->ymax - srct->ymin + 1; + width = srct->xmax - srct->xmin + 1; + height = srct->ymax - srct->ymin + 1; glScissor(srct->xmin, srct->ymin, width, height); } else glScissor(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height); - wmOrtho2(-0.375f, (float)width-0.375f, -0.375f, (float)height-0.375f); + wmOrtho2(-0.375f, (float)width - 0.375f, -0.375f, (float)height - 0.375f); glLoadIdentity(); glFlush(); @@ -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); } @@ -314,25 +314,25 @@ void wmOrtho2(float x1, float x2, float y1, float y2) unsigned int index_to_framebuffer(int index) { - unsigned int i= index; - - switch(GPU_color_depth()) { - case 12: - i= ((i & 0xF00)<<12) + ((i & 0xF0)<<8) + ((i & 0xF)<<4); - /* sometimes dithering subtracts! */ - i |= 0x070707; - break; - case 15: - case 16: - i= ((i & 0x7C00)<<9) + ((i & 0x3E0)<<6) + ((i & 0x1F)<<3); - i |= 0x030303; - break; - case 24: - break; - default: // 18 bits... - i= ((i & 0x3F000)<<6) + ((i & 0xFC0)<<4) + ((i & 0x3F)<<2); - i |= 0x010101; - break; + unsigned int i = index; + + switch (GPU_color_depth()) { + case 12: + i = ((i & 0xF00) << 12) + ((i & 0xF0) << 8) + ((i & 0xF) << 4); + /* sometimes dithering subtracts! */ + i |= 0x070707; + break; + case 15: + case 16: + i = ((i & 0x7C00) << 9) + ((i & 0x3E0) << 6) + ((i & 0x1F) << 3); + i |= 0x030303; + break; + case 24: + break; + default: // 18 bits... + i = ((i & 0x3F000) << 6) + ((i & 0xFC0) << 4) + ((i & 0x3F) << 2); + i |= 0x010101; + break; } return i; @@ -344,27 +344,27 @@ unsigned int index_to_framebuffer(int index) unsigned int index_to_framebuffer(int index) { - unsigned int i= index; + unsigned int i = index; - switch(GPU_color_depth()) { + switch (GPU_color_depth()) { case 8: - i= ((i & 48)<<18) + ((i & 12)<<12) + ((i & 3)<<6); + i = ((i & 48) << 18) + ((i & 12) << 12) + ((i & 3) << 6); i |= 0x3F3F3F; break; case 12: - i= ((i & 0xF00)<<12) + ((i & 0xF0)<<8) + ((i & 0xF)<<4); + i = ((i & 0xF00) << 12) + ((i & 0xF0) << 8) + ((i & 0xF) << 4); /* sometimes dithering subtracts! */ i |= 0x0F0F0F; break; case 15: case 16: - i= ((i & 0x7C00)<<9) + ((i & 0x3E0)<<6) + ((i & 0x1F)<<3); + i = ((i & 0x7C00) << 9) + ((i & 0x3E0) << 6) + ((i & 0x1F) << 3); i |= 0x070707; break; case 24: break; - default: // 18 bits... - i= ((i & 0x3F000)<<6) + ((i & 0xFC0)<<4) + ((i & 0x3F)<<2); + default: // 18 bits... + i = ((i & 0x3F000) << 6) + ((i & 0xFC0) << 4) + ((i & 0x3F) << 2); i |= 0x030303; break; } @@ -376,26 +376,26 @@ unsigned int index_to_framebuffer(int index) void WM_set_framebuffer_index_color(int index) { - const int col= index_to_framebuffer(index); + const int col = index_to_framebuffer(index); cpack(col); } int WM_framebuffer_to_index(unsigned int col) { - if (col==0) return 0; - - switch(GPU_color_depth()) { - case 8: - return ((col & 0xC00000)>>18) + ((col & 0xC000)>>12) + ((col & 0xC0)>>6); - case 12: - return ((col & 0xF00000)>>12) + ((col & 0xF000)>>8) + ((col & 0xF0)>>4); - case 15: - case 16: - return ((col & 0xF80000)>>9) + ((col & 0xF800)>>6) + ((col & 0xF8)>>3); - case 24: - return col & 0xFFFFFF; - default: // 18 bits... - return ((col & 0xFC0000)>>6) + ((col & 0xFC00)>>4) + ((col & 0xFC)>>2); + if (col == 0) return 0; + + switch (GPU_color_depth()) { + case 8: + return ((col & 0xC00000) >> 18) + ((col & 0xC000) >> 12) + ((col & 0xC0) >> 6); + case 12: + return ((col & 0xF00000) >> 12) + ((col & 0xF000) >> 8) + ((col & 0xF0) >> 4); + case 15: + case 16: + return ((col & 0xF80000) >> 9) + ((col & 0xF800) >> 6) + ((col & 0xF8) >> 3); + case 24: + return col & 0xFFFFFF; + default: // 18 bits... + return ((col & 0xFC0000) >> 6) + ((col & 0xFC00) >> 4) + ((col & 0xFC) >> 2); } } diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index b79a89b89bd..fd9d789ffd4 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -76,7 +76,7 @@ #include "UI_interface.h" /* the global to talk to ghost */ -static GHOST_SystemHandle g_system= NULL; +static GHOST_SystemHandle g_system = NULL; typedef enum WinOverrideFlag { WIN_OVERRIDE_GEOM = (1 << 0), @@ -103,8 +103,8 @@ void wm_get_screensize(int *width_r, int *height_r) unsigned int uiheight; GHOST_GetMainDisplayDimensions(g_system, &uiwidth, &uiheight); - *width_r= uiwidth; - *height_r= uiheight; + *width_r = uiwidth; + *height_r = uiheight; } /* keeps offset and size within monitor bounds */ @@ -128,12 +128,12 @@ static void wm_window_check_position(rcti *rect) rect->ymin = 0; } if (rect->xmax > width) { - d= rect->xmax - width; + d = rect->xmax - width; rect->xmax -= d; rect->xmin -= d; } if (rect->ymax > height) { - d= rect->ymax - height; + d = rect->ymax - height; rect->ymax -= d; rect->ymin -= d; } @@ -147,7 +147,7 @@ static void wm_ghostwindow_destroy(wmWindow *win) { if (win->ghostwin) { GHOST_DisposeWindow(g_system, win->ghostwin); - win->ghostwin= NULL; + win->ghostwin = NULL; } } @@ -162,26 +162,26 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win) 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); } /* always set drawable and active to NULL, * prevents non-drawable state of main windows (bugs #22967 and #25071, possibly #22477 too) */ - wm->windrawable= NULL; - wm->winactive= NULL; + wm->windrawable = NULL; + wm->winactive = NULL; /* end running jobs, a job end also removes its timer */ - for (wt= wm->timers.first; wt; wt= wtnext) { - wtnext= wt->next; - if (wt->win==win && wt->event_type==TIMERJOBS) + for (wt = wm->timers.first; wt; wt = wtnext) { + wtnext = wt->next; + 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) { - wtnext= wt->next; - if (wt->win==win) + for (wt = wm->timers.first; wt; wt = wtnext) { + wtnext = wt->next; + if (wt->win == win) WM_event_remove_timer(wm, win, wt); } @@ -201,11 +201,11 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win) static int find_free_winid(wmWindowManager *wm) { wmWindow *win; - int id= 1; + int id = 1; - for (win= wm->windows.first; win; win= win->next) + for (win = wm->windows.first; win; win = win->next) if (id <= win->winid) - id= win->winid+1; + id = win->winid + 1; return id; } @@ -213,11 +213,11 @@ static int find_free_winid(wmWindowManager *wm) /* don't change context itself */ wmWindow *wm_window_new(bContext *C) { - wmWindowManager *wm= CTX_wm_manager(C); - wmWindow *win= MEM_callocN(sizeof(wmWindow), "window"); + wmWindowManager *wm = CTX_wm_manager(C); + wmWindow *win = MEM_callocN(sizeof(wmWindow), "window"); BLI_addtail(&wm->windows, win); - win->winid= find_free_winid(wm); + win->winid = find_free_winid(wm); return win; } @@ -226,23 +226,23 @@ wmWindow *wm_window_new(bContext *C) /* part of wm_window.c api */ wmWindow *wm_window_copy(bContext *C, wmWindow *winorig) { - wmWindow *win= wm_window_new(C); + wmWindow *win = wm_window_new(C); - win->posx= winorig->posx+10; - win->posy= winorig->posy; - win->sizex= winorig->sizex; - win->sizey= winorig->sizey; + win->posx = winorig->posx + 10; + win->posy = winorig->posy; + win->sizex = winorig->sizex; + win->sizey = winorig->sizey; /* duplicate assigns to window */ - win->screen= ED_screen_duplicate(win, winorig->screen); - BLI_strncpy(win->screenname, win->screen->id.name+2, sizeof(win->screenname)); - win->screen->winid= win->winid; + win->screen = ED_screen_duplicate(win, winorig->screen); + BLI_strncpy(win->screenname, win->screen->id.name + 2, sizeof(win->screenname)); + win->screen->winid = win->winid; - win->screen->do_refresh= 1; - win->screen->do_draw= 1; + win->screen->do_refresh = 1; + win->screen->do_draw = 1; - win->drawmethod= -1; - win->drawdata= NULL; + win->drawmethod = -1; + win->drawdata = NULL; return win; } @@ -251,7 +251,7 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *winorig) void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win) { wmWindow *tmpwin; - bScreen *screen= win->screen; + bScreen *screen = win->screen; /* first check if we have any non-temp remaining windows */ if ((U.uiflag & USER_QUIT_PROMPT) && !wm->file_saved) { @@ -272,7 +272,7 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win) BLI_remlink(&wm->windows, win); wm_draw_window_clear(win); - CTX_wm_window_set(C, win); /* needed by handlers */ + CTX_wm_window_set(C, win); /* needed by handlers */ WM_event_remove_handlers(C, &win->handlers); WM_event_remove_handlers(C, &win->modalhandlers); ED_screen_exit(C, win, win->screen); @@ -281,17 +281,17 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win) /* if temp screen, delete it after window free (it stops jobs that can access it) */ if (screen->temp) { - Main *bmain= CTX_data_main(C); + 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) + 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 @@ -302,8 +302,8 @@ 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) { - char *title= GHOST_GetTitle(win->ghostwin); - if (title==NULL || title[0]==0) + char *title = GHOST_GetTitle(win->ghostwin); + if (title == NULL || title[0] == 0) GHOST_SetTitle(win->ghostwin, "Blender"); } else { @@ -311,7 +311,7 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win) /* this is set to 1 if you don't have startup.blend open */ 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); + BLI_snprintf(str, sizeof(str), "Blender%s [%s]", wm->file_saved ? "" : "*", G.main->name); GHOST_SetTitle(win->ghostwin, str); } else @@ -320,7 +320,7 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win) /* Informs GHOST of unsaved changes, to set window modified visual indicator (MAC OS X) * and to give hint of unsaved changes for a user warning mechanism * in case of OS application terminate request (e.g. OS Shortcut Alt+F4, Cmd+Q, (...), or session end) */ - GHOST_SetWindowModifiedState(win->ghostwin, (GHOST_TUns8)!wm->file_saved); + GHOST_SetWindowModifiedState(win->ghostwin, (GHOST_TUns8) !wm->file_saved); #if defined(__APPLE__) && !defined(GHOST_COCOA) if (wm->file_saved) @@ -338,7 +338,7 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win) int scr_w, scr_h, posy; wm_get_screensize(&scr_w, &scr_h); - posy= (scr_h - win->posy - win->sizey); + posy = (scr_h - win->posy - win->sizey); #if defined(__APPLE__) && !defined(GHOST_COCOA) { @@ -348,12 +348,12 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win) #endif /* Disable AA for now, as GL_SELECT (used for border, lasso, ... select) * doesn't work well when AA is initialized, even if not used. */ - ghostwin= GHOST_CreateWindow(g_system, title, - win->posx, posy, win->sizex, win->sizey, - (GHOST_TWindowState)win->windowstate, - GHOST_kDrawingContextTypeOpenGL, - 0 /* no stereo */, - 0 /* no AA */); + ghostwin = GHOST_CreateWindow(g_system, title, + win->posx, posy, win->sizex, win->sizey, + (GHOST_TWindowState)win->windowstate, + GHOST_kDrawingContextTypeOpenGL, + 0 /* no stereo */, + 0 /* no AA */); if (ghostwin) { /* needed so we can detect the graphics card below */ @@ -362,11 +362,11 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win) /* set the state*/ GHOST_SetWindowState(ghostwin, (GHOST_TWindowState)win->windowstate); - win->ghostwin= ghostwin; - GHOST_SetWindowUserData(ghostwin, win); /* pointer back */ + win->ghostwin = ghostwin; + GHOST_SetWindowUserData(ghostwin, win); /* pointer back */ - if (win->eventstate==NULL) - win->eventstate= MEM_callocN(sizeof(wmEvent), "window event state"); + 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); @@ -404,7 +404,7 @@ void wm_window_add_ghostwindows(wmWindowManager *wm) #if defined(__APPLE__) && !defined(GHOST_COCOA) //Cocoa provides functions to get correct max window size { - extern void wm_set_apple_prefsize(int, int); /* wm_apple.c */ + extern void wm_set_apple_prefsize(int, int); /* wm_apple.c */ wm_set_apple_prefsize(wm_init_state.size_x, wm_init_state.size_y); } @@ -415,8 +415,8 @@ void wm_window_add_ghostwindows(wmWindowManager *wm) #endif } - for (win= wm->windows.first; win; win= win->next) { - if (win->ghostwin==NULL) { + for (win = wm->windows.first; win; win = win->next) { + if (win->ghostwin == NULL) { if ((win->sizex == 0) || (wm_init_state.override_flag & WIN_OVERRIDE_GEOM)) { win->posx = wm_init_state.start_x; win->posy = wm_init_state.start_y; @@ -433,8 +433,8 @@ void wm_window_add_ghostwindows(wmWindowManager *wm) wm_window_add_ghostwindow("Blender", win); } /* happens after fileread */ - if (win->eventstate==NULL) - win->eventstate= MEM_callocN(sizeof(wmEvent), "window event state"); + if (win->eventstate == NULL) + win->eventstate = MEM_callocN(sizeof(wmEvent), "window event state"); /* add keymap handlers (1 handler for all keys in map!) */ keymap = WM_keymap_find(wm->defaultconf, "Window", 0, 0); @@ -448,7 +448,7 @@ void wm_window_add_ghostwindows(wmWindowManager *wm) /* add drop boxes */ { - ListBase *lb= WM_dropboxmap_find("Window", 0, 0); + ListBase *lb = WM_dropboxmap_find("Window", 0, 0); WM_event_add_dropbox_handler(&win->handlers, lb); } wm_window_title(wm, win); @@ -460,15 +460,15 @@ void wm_window_add_ghostwindows(wmWindowManager *wm) /* area-rip calls this */ wmWindow *WM_window_open(bContext *C, rcti *rect) { - wmWindow *win= wm_window_new(C); + wmWindow *win = wm_window_new(C); - win->posx= rect->xmin; - win->posy= rect->ymin; - win->sizex= rect->xmax - rect->xmin; - win->sizey= rect->ymax - rect->ymin; + win->posx = rect->xmin; + win->posy = rect->ymin; + win->sizex = rect->xmax - rect->xmin; + win->sizey = rect->ymax - rect->ymin; - win->drawmethod= -1; - win->drawdata= NULL; + win->drawmethod = -1; + win->drawdata = NULL; WM_check(C); @@ -488,20 +488,20 @@ 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) + for (win = CTX_wm_manager(C)->windows.first; win; win = win->next) if (win->screen->temp) break; /* add new window? */ - if (win==NULL) { - win= wm_window_new(C); + if (win == NULL) { + win = wm_window_new(C); - win->posx= position->xmin; - win->posy= position->ymin; + win->posx = position->xmin; + win->posy = position->ymin; } - win->sizex= position->xmax - position->xmin; - win->sizey= position->ymax - position->ymin; + win->sizex = position->xmax - position->xmin; + win->sizey = position->ymax - position->ymin; if (win->ghostwin) { wm_window_set_size(win, win->sizex, win->sizey); @@ -509,8 +509,8 @@ void WM_window_open_temp(bContext *C, rcti *position, int type) } /* add new screen? */ - if (win->screen==NULL) - win->screen= ED_screen_add(win, CTX_data_scene(C), "temp"); + if (win->screen == NULL) + win->screen = ED_screen_add(win, CTX_data_scene(C), "temp"); win->screen->temp = 1; /* make window active, and validate/resize */ @@ -518,10 +518,10 @@ void WM_window_open_temp(bContext *C, rcti *position, int type) WM_check(C); /* ensure it shows the right spacetype editor */ - sa= win->screen->areabase.first; + 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)) 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"); @@ -549,7 +549,7 @@ int wm_window_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) wm_window_copy(C, CTX_wm_window(C)); WM_check(C); - WM_event_add_notifier(C, NC_WINDOW|NA_ADDED, NULL); + WM_event_add_notifier(C, NC_WINDOW | NA_ADDED, NULL); return OPERATOR_FINISHED; } @@ -558,14 +558,14 @@ int wm_window_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) /* fullscreen operator callback */ int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { - wmWindow *window= CTX_wm_window(C); + wmWindow *window = CTX_wm_window(C); GHOST_TWindowState state; if (G.background) return OPERATOR_CANCELLED; - state= GHOST_GetWindowState(window->ghostwin); - if (state!=GHOST_kWindowStateFullScreen) + state = GHOST_GetWindowState(window->ghostwin); + if (state != GHOST_kWindowStateFullScreen) GHOST_SetWindowState(window->ghostwin, GHOST_kWindowStateFullScreen); else GHOST_SetWindowState(window->ghostwin, GHOST_kWindowStateNormal); @@ -589,24 +589,24 @@ typedef enum static int query_qual(modifierKeyType qual) { GHOST_TModifierKeyMask left, right; - int val= 0; + int val = 0; - switch(qual) { + switch (qual) { case SHIFT: - left= GHOST_kModifierKeyLeftShift; - right= GHOST_kModifierKeyRightShift; + left = GHOST_kModifierKeyLeftShift; + right = GHOST_kModifierKeyRightShift; break; case CONTROL: - left= GHOST_kModifierKeyLeftControl; - right= GHOST_kModifierKeyRightControl; + left = GHOST_kModifierKeyLeftControl; + right = GHOST_kModifierKeyRightControl; break; case OS: - left= right= GHOST_kModifierKeyOS; + left = right = GHOST_kModifierKeyOS; break; case ALT: default: - left= GHOST_kModifierKeyLeftAlt; - right= GHOST_kModifierKeyRightAlt; + left = GHOST_kModifierKeyLeftAlt; + right = GHOST_kModifierKeyRightAlt; break; } @@ -619,12 +619,12 @@ static int query_qual(modifierKeyType qual) void wm_window_make_drawable(bContext *C, wmWindow *win) { - wmWindowManager *wm= CTX_wm_manager(C); + wmWindowManager *wm = CTX_wm_manager(C); if (win != wm->windrawable && win->ghostwin) { // win->lmbut= 0; /* keeps hanging when mousepressed while other window opened */ - wm->windrawable= win; + wm->windrawable = win; if (G.f & G_DEBUG) printf("set drawable %d\n", win->winid); GHOST_ActivateWindowDrawingContext(win->ghostwin); } @@ -633,17 +633,17 @@ void wm_window_make_drawable(bContext *C, wmWindow *win) /* called by ghost, here we handle events for windows themselves or send to event system */ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) { - bContext *C= private; - wmWindowManager *wm= CTX_wm_manager(C); - GHOST_TEventType type= GHOST_GetEventType(evt); - int time= GHOST_GetEventTime(evt); + bContext *C = private; + wmWindowManager *wm = CTX_wm_manager(C); + GHOST_TEventType type = GHOST_GetEventType(evt); + int time = GHOST_GetEventTime(evt); if (type == GHOST_kEventQuit) { WM_exit(C); } else { - GHOST_WindowHandle ghostwin= GHOST_GetEventWindow(evt); - GHOST_TEventDataPtr data= GHOST_GetEventData(evt); + GHOST_WindowHandle ghostwin = GHOST_GetEventWindow(evt); + GHOST_TEventDataPtr data = GHOST_GetEventData(evt); wmWindow *win; if (!ghostwin) { @@ -659,54 +659,54 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) return 1; } else { - win= GHOST_GetWindowUserData(ghostwin); + win = GHOST_GetWindowUserData(ghostwin); } - switch(type) { + switch (type) { case GHOST_kEventWindowDeactivate: wm_event_add_ghostevent(wm, win, type, time, data); - win->active= 0; /* XXX */ + win->active = 0; /* XXX */ break; case GHOST_kEventWindowActivate: { GHOST_TEventKeyData kdata; int cx, cy, wx, wy; - wm->winactive= win; /* no context change! c->wm->windrawable is drawable, or for area queues */ + wm->winactive = win; /* no context change! c->wm->windrawable is drawable, or for area queues */ - win->active= 1; + win->active = 1; // window_handle(win, INPUTCHANGE, win->active); /* bad ghost support for modifier keys... so on activate we set the modifiers again */ - kdata.ascii= '\0'; - kdata.utf8_buf[0]= '\0'; + kdata.ascii = '\0'; + kdata.utf8_buf[0] = '\0'; if (win->eventstate->shift && !query_qual(SHIFT)) { - kdata.key= GHOST_kKeyLeftShift; + kdata.key = GHOST_kKeyLeftShift; wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata); } if (win->eventstate->ctrl && !query_qual(CONTROL)) { - kdata.key= GHOST_kKeyLeftControl; + kdata.key = GHOST_kKeyLeftControl; wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata); } if (win->eventstate->alt && !query_qual(ALT)) { - kdata.key= GHOST_kKeyLeftAlt; + kdata.key = GHOST_kKeyLeftAlt; wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata); } if (win->eventstate->oskey && !query_qual(OS)) { - kdata.key= GHOST_kKeyOS; + kdata.key = GHOST_kKeyOS; wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata); } /* keymodifier zero, it hangs on hotkeys that open windows otherwise */ - win->eventstate->keymodifier= 0; + win->eventstate->keymodifier = 0; /* entering window, update mouse pos. but no event */ GHOST_GetCursorPosition(g_system, &wx, &wy); GHOST_ScreenToClient(win->ghostwin, wx, wy, &cx, &cy); - win->eventstate->x= cx; - win->eventstate->y= (win->sizey-1) - cy; + win->eventstate->x = cx; + win->eventstate->y = (win->sizey - 1) - cy; - win->addmousemove= 1; /* enables highlighted buttons */ + win->addmousemove = 1; /* enables highlighted buttons */ wm_window_make_drawable(C, win); break; @@ -729,22 +729,22 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) state = GHOST_GetWindowState(win->ghostwin); win->windowstate = state; - /* win32: gives undefined window size when minimized */ - if (state!=GHOST_kWindowStateMinimized) { + /* win32: gives undefined window size when minimized */ + if (state != GHOST_kWindowStateMinimized) { GHOST_RectangleHandle client_rect; int l, t, r, b, scr_w, scr_h; int sizex, sizey, posx, posy; - client_rect= GHOST_GetClientBounds(win->ghostwin); + client_rect = GHOST_GetClientBounds(win->ghostwin); GHOST_GetRectangle(client_rect, &l, &t, &r, &b); GHOST_DisposeRectangle(client_rect); wm_get_screensize(&scr_w, &scr_h); - sizex= r-l; - sizey= b-t; - posx= l; - posy= scr_h - t - win->sizey; + sizex = r - l; + sizey = b - t; + posx = l; + posy = scr_h - t - win->sizey; /* * Ghost sometimes send size or move events when the window hasn't changed. @@ -755,33 +755,33 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) * another time. */ if (win->sizex != sizex || - win->sizey != sizey || - win->posx != posx || - win->posy != posy) + win->sizey != sizey || + win->posx != posx || + win->posy != posy) { - win->sizex= sizex; - win->sizey= sizey; - win->posx= posx; - win->posy= posy; + win->sizex = sizex; + win->sizey = sizey; + win->posx = posx; + win->posy = posy; /* debug prints */ if (0) { state = GHOST_GetWindowState(win->ghostwin); - if (state==GHOST_kWindowStateNormal) { + if (state == GHOST_kWindowStateNormal) { if (G.f & G_DEBUG) printf("window state: normal\n"); } - else if (state==GHOST_kWindowStateMinimized) { + else if (state == GHOST_kWindowStateMinimized) { if (G.f & G_DEBUG) printf("window state: minimized\n"); } - else if (state==GHOST_kWindowStateMaximized) { + else if (state == GHOST_kWindowStateMaximized) { if (G.f & G_DEBUG) printf("window state: maximized\n"); } - else if (state==GHOST_kWindowStateFullScreen) { + else if (state == GHOST_kWindowStateFullScreen) { if (G.f & G_DEBUG) printf("window state: fullscreen\n"); } - if (type!=GHOST_kEventWindowSize) { + 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); @@ -792,8 +792,8 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) wm_window_make_drawable(C, win); wm_draw_window_clear(win); - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); - WM_event_add_notifier(C, NC_WINDOW|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_WINDOW | NA_EDITED, NULL); } } break; @@ -823,35 +823,35 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) case GHOST_kEventDraggingDropDone: { wmEvent event; - GHOST_TEventDragnDropData *ddd= GHOST_GetEventData(evt); + GHOST_TEventDragnDropData *ddd = GHOST_GetEventData(evt); int cx, cy, wx, wy; /* entering window, update mouse pos */ GHOST_GetCursorPosition(g_system, &wx, &wy); GHOST_ScreenToClient(win->ghostwin, wx, wy, &cx, &cy); - win->eventstate->x= cx; - win->eventstate->y= (win->sizey-1) - cy; + win->eventstate->x = cx; + win->eventstate->y = (win->sizey - 1) - cy; - event= *(win->eventstate); /* copy last state, like mouse coords */ + event = *(win->eventstate); /* copy last state, like mouse coords */ // activate region - event.type= MOUSEMOVE; - event.prevx= event.x; - event.prevy= event.y; + event.type = MOUSEMOVE; + event.prevx = event.x; + event.prevy = event.y; - wm->winactive= win; /* no context change! c->wm->windrawable is drawable, or for area queues */ - win->active= 1; + wm->winactive = win; /* no context change! c->wm->windrawable is drawable, or for area queues */ + win->active = 1; wm_event_add(win, &event); /* make blender drop event with custom data pointing to wm drags */ - event.type= EVT_DROP; - event.val= KM_RELEASE; - event.custom= EVT_DATA_LISTBASE; - event.customdata= &wm->drags; - event.customdatafree= 1; + event.type = EVT_DROP; + event.val = KM_RELEASE; + event.custom = EVT_DATA_LISTBASE; + event.customdata = &wm->drags; + event.customdatafree = 1; wm_event_add(win, &event); @@ -860,13 +860,13 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) /* add drag data to wm for paths: */ if (ddd->dataType == GHOST_kDragnDropTypeFilenames) { - GHOST_TStringArray *stra= ddd->data; + GHOST_TStringArray *stra = ddd->data; int a, icon; - for (a=0; a<stra->count; a++) { + for (a = 0; a < stra->count; 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]); + icon = ED_file_extension_icon((char *)stra->strings[a]); WM_event_start_drag(C, icon, WM_DRAG_PATH, stra->strings[a], 0.0); /* void poin should point to string, it makes a copy */ @@ -897,36 +897,36 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) */ static int wm_window_timer(const bContext *C) { - wmWindowManager *wm= CTX_wm_manager(C); + wmWindowManager *wm = CTX_wm_manager(C); wmTimer *wt, *wtnext; wmWindow *win; - double time= PIL_check_seconds_timer(); - int retval= 0; + double time = PIL_check_seconds_timer(); + int retval = 0; - for (wt= wm->timers.first; wt; wt= wtnext) { - wtnext= wt->next; /* in case timer gets removed */ - win= wt->win; + for (wt = wm->timers.first; wt; wt = wtnext) { + wtnext = wt->next; /* in case timer gets removed */ + win = wt->win; - if (wt->sleep==0) { + if (wt->sleep== 0) { if (time > wt->ntime) { - wt->delta= time - wt->ltime; + wt->delta = time - wt->ltime; wt->duration += wt->delta; - wt->ltime= time; - wt->ntime= wt->stime + wt->timestep*ceil(wt->duration/wt->timestep); + wt->ltime = time; + wt->ntime = wt->stime + wt->timestep *ceil(wt->duration / wt->timestep); if (wt->event_type == TIMERJOBS) wm_jobs_timer(C, wm, wt); else if (wt->event_type == TIMERAUTOSAVE) wm_autosave_timer(C, wm, wt); else if (win) { - wmEvent event= *(win->eventstate); + wmEvent event = *(win->eventstate); - event.type= wt->event_type; - event.custom= EVT_DATA_TIMER; - event.customdata= wt; + event.type = wt->event_type; + event.custom = EVT_DATA_TIMER; + event.customdata = wt; wm_event_add(win, &event); - retval= 1; + retval = 1; } } } @@ -936,7 +936,7 @@ static int wm_window_timer(const bContext *C) void wm_window_process_events(const bContext *C) { - int hasevent= GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */ + int hasevent = GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */ if (hasevent) GHOST_DispatchEvents(g_system); @@ -944,7 +944,7 @@ void wm_window_process_events(const bContext *C) hasevent |= wm_window_timer(C); /* no event, we sleep 5 milliseconds */ - if (hasevent==0) + if (hasevent == 0) PIL_sleep_ms(5); } @@ -957,19 +957,19 @@ void wm_window_process_events_nosleep(void) /* exported as handle callback to bke blender.c */ void wm_window_testbreak(void) { - static double ltime= 0; - double curtime= PIL_check_seconds_timer(); + static double ltime = 0; + double curtime = PIL_check_seconds_timer(); /* only check for breaks every 50 milliseconds * if we get called more often. */ - if ((curtime-ltime)>.05) { - int hasevent= GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */ + if ((curtime - ltime) > .05) { + int hasevent = GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */ if (hasevent) GHOST_DispatchEvents(g_system); - ltime= curtime; + ltime = curtime; } } @@ -978,9 +978,9 @@ void wm_window_testbreak(void) void wm_ghost_init(bContext *C) { if (!g_system) { - GHOST_EventConsumerHandle consumer= GHOST_CreateEventConsumer(ghost_event_proc, C); + GHOST_EventConsumerHandle consumer = GHOST_CreateEventConsumer(ghost_event_proc, C); - g_system= GHOST_CreateSystem(); + g_system = GHOST_CreateSystem(); GHOST_AddEventConsumer(g_system, consumer); } } @@ -990,7 +990,7 @@ void wm_ghost_exit(void) if (g_system) GHOST_DisposeSystem(g_system); - g_system= NULL; + g_system = NULL; } /* **************** timer ********************** */ @@ -1000,24 +1000,24 @@ 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) - wt->sleep= dosleep; + wt->sleep = dosleep; } wmTimer *WM_event_add_timer(wmWindowManager *wm, wmWindow *win, int event_type, double timestep) { - wmTimer *wt= MEM_callocN(sizeof(wmTimer), "window timer"); + wmTimer *wt = MEM_callocN(sizeof(wmTimer), "window timer"); - wt->event_type= event_type; - wt->ltime= PIL_check_seconds_timer(); - wt->ntime= wt->ltime + timestep; - wt->stime= wt->ltime; - wt->timestep= timestep; - wt->win= win; + wt->event_type = event_type; + wt->ltime = PIL_check_seconds_timer(); + wt->ntime = wt->ltime + timestep; + wt->stime = wt->ltime; + wt->timestep = timestep; + wt->win = win; BLI_addtail(&wm->timers, wt); @@ -1029,12 +1029,12 @@ 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) - wm->reports.reporttimer= NULL; + wm->reports.reporttimer = NULL; BLI_remlink(&wm->timers, wt); if (wt->customdata) @@ -1052,18 +1052,18 @@ char *WM_clipboard_text_get(int selection) if (G.background) return NULL; - buf= (char*)GHOST_getClipboard(selection); + buf = (char *)GHOST_getClipboard(selection); if (!buf) return NULL; /* always convert from \r\n to \n */ - newbuf= MEM_callocN(strlen(buf)+1, "WM_clipboard_text_get"); + newbuf = MEM_callocN(strlen(buf) + 1, "WM_clipboard_text_get"); - for (p= buf, p2= newbuf; *p; p++) { + for (p = buf, p2 = newbuf; *p; p++) { if (*p != '\r') - *(p2++)= *p; + *(p2++) = *p; } - *p2= '\0'; + *p2 = '\0'; free(buf); /* ghost uses regular malloc */ @@ -1076,29 +1076,29 @@ void WM_clipboard_text_set(char *buf, int selection) #ifdef _WIN32 /* do conversion from \n to \r\n on Windows */ char *p, *p2, *newbuf; - int newlen= 0; + int newlen = 0; - for (p= buf; *p; p++) { + for (p = buf; *p; p++) { if (*p == '\n') newlen += 2; else newlen++; } - newbuf= MEM_callocN(newlen+1, "WM_clipboard_text_set"); + newbuf = MEM_callocN(newlen + 1, "WM_clipboard_text_set"); - for (p= buf, p2= newbuf; *p; p++, p2++) { + for (p = buf, p2 = newbuf; *p; p++, p2++) { if (*p == '\n') { - *(p2++)= '\r'; *p2= '\n'; + *(p2++) = '\r'; *p2 = '\n'; } - else *p2= *p; + else *p2 = *p; } - *p2= '\0'; + *p2 = '\0'; - GHOST_putClipboard((GHOST_TInt8*)newbuf, selection); + GHOST_putClipboard((GHOST_TInt8 *)newbuf, selection); MEM_freeN(newbuf); #else - GHOST_putClipboard((GHOST_TInt8*)buf, selection); + GHOST_putClipboard((GHOST_TInt8 *)buf, selection); #endif } } @@ -1119,23 +1119,23 @@ void WM_progress_clear(wmWindow *win) void wm_window_get_position(wmWindow *win, int *posx_r, int *posy_r) { - *posx_r= win->posx; - *posy_r= win->posy; + *posx_r = win->posx; + *posy_r = win->posy; } void wm_window_get_size(wmWindow *win, int *width_r, int *height_r) { - *width_r= win->sizex; - *height_r= win->sizey; + *width_r = win->sizex; + *height_r = win->sizey; } /* exceptional case: - splash is called before events are processed * this means we don't actually know the window size so get this from GHOST */ void wm_window_get_size_ghost(wmWindow *win, int *width_r, int *height_r) { - GHOST_RectangleHandle bounds= GHOST_GetClientBounds(win->ghostwin); - *width_r= GHOST_GetWidthRectangle(bounds); - *height_r= GHOST_GetHeightRectangle(bounds); + GHOST_RectangleHandle bounds = GHOST_GetClientBounds(win->ghostwin); + *width_r = GHOST_GetWidthRectangle(bounds); + *height_r = GHOST_GetHeightRectangle(bounds); GHOST_DisposeRectangle(bounds); } @@ -1171,7 +1171,7 @@ void wm_get_cursor_position(wmWindow *win, int *x, int *y) { GHOST_GetCursorPosition(g_system, x, y); GHOST_ScreenToClient(win->ghostwin, *x, *y, x, y); - *y = (win->sizey-1) - *y; + *y = (win->sizey - 1) - *y; } /* ******************* exported api ***************** */ @@ -1204,15 +1204,15 @@ void WM_setinitialstate_normal(void) void WM_cursor_warp(wmWindow *win, int x, int y) { if (win && win->ghostwin) { - int oldx=x, oldy=y; + int oldx = x, oldy = y; - y= win->sizey -y - 1; + y = win->sizey - y - 1; GHOST_ClientToScreen(win->ghostwin, x, y, &x, &y); GHOST_SetCursorPosition(g_system, x, y); - win->eventstate->prevx= oldx; - win->eventstate->prevy= oldy; + win->eventstate->prevx = oldx; + win->eventstate->prevy = oldy; } } |