diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-27 05:24:16 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-27 05:24:16 +0400 |
commit | ae654301b041cae9cce8107614c1d17bae3ff12a (patch) | |
tree | 55cafe73461bd00b2f8c64475ab26acfb69a69bf /source/blender/windowmanager/intern/wm_gesture.c | |
parent | 126c9d4caa9ad92f2e8fb50c406f5b5932b0f058 (diff) |
style cleanup: wm, mosyly adding space around ops
Diffstat (limited to 'source/blender/windowmanager/intern/wm_gesture.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_gesture.c | 150 |
1 files changed, 75 insertions, 75 deletions
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); } |