From 81255ca8ce5339910b3ab9de2878bfc470e714da Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 May 2012 18:29:02 +0000 Subject: [PATCH] style cleanup: gpencil & metaball --- source/blender/editors/gpencil/drawgpencil.c | 306 ++++---- .../editors/gpencil/editaction_gpencil.c | 142 ++-- .../blender/editors/gpencil/gpencil_buttons.c | 56 +- source/blender/editors/gpencil/gpencil_edit.c | 210 +++--- .../blender/editors/gpencil/gpencil_intern.h | 34 +- source/blender/editors/gpencil/gpencil_ops.c | 28 +- .../blender/editors/gpencil/gpencil_paint.c | 714 +++++++++--------- source/blender/editors/gpencil/gpencil_undo.c | 46 +- source/blender/editors/interface/interface.c | 18 +- .../editors/interface/interface_intern.h | 96 +-- .../editors/interface/interface_layout.c | 18 +- source/blender/editors/metaball/mball_edit.c | 234 +++--- source/blender/editors/metaball/mball_ops.c | 4 +- .../blender/editors/space_time/space_time.c | 258 +++---- source/blender/editors/space_time/time_ops.c | 54 +- 15 files changed, 1111 insertions(+), 1107 deletions(-) diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 12a54658f90..8d771f0dc58 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -74,23 +74,23 @@ /* flags for sflag */ typedef enum eDrawStrokeFlags { - GP_DRAWDATA_NOSTATUS = (1<<0), /* don't draw status info */ - GP_DRAWDATA_ONLY3D = (1<<1), /* only draw 3d-strokes */ - GP_DRAWDATA_ONLYV2D = (1<<2), /* only draw 'canvas' strokes */ - GP_DRAWDATA_ONLYI2D = (1<<3), /* only draw 'image' strokes */ - GP_DRAWDATA_IEDITHACK = (1<<4), /* special hack for drawing strokes in Image Editor (weird coordinates) */ - GP_DRAWDATA_NO_XRAY = (1<<5), /* don't draw xray in 3D view (which is default) */ + GP_DRAWDATA_NOSTATUS = (1 << 0), /* don't draw status info */ + GP_DRAWDATA_ONLY3D = (1 << 1), /* only draw 3d-strokes */ + GP_DRAWDATA_ONLYV2D = (1 << 2), /* only draw 'canvas' strokes */ + GP_DRAWDATA_ONLYI2D = (1 << 3), /* only draw 'image' strokes */ + GP_DRAWDATA_IEDITHACK = (1 << 4), /* special hack for drawing strokes in Image Editor (weird coordinates) */ + GP_DRAWDATA_NO_XRAY = (1 << 5), /* don't draw xray in 3D view (which is default) */ } eDrawStrokeFlags; /* thickness above which we should use special drawing */ -#define GP_DRAWTHICKNESS_SPECIAL 3 +#define GP_DRAWTHICKNESS_SPECIAL 3 /* ----- Tool Buffer Drawing ------ */ /* draw stroke defined in buffer (simple ogl lines/points for now, as dotted lines) */ -static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thickness, short dflag, short sflag) +static void gp_draw_stroke_buffer(tGPspoint *points, int totpoints, short thickness, short dflag, short sflag) { tGPspoint *pt; int i; @@ -100,14 +100,14 @@ static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thick return; /* check if buffer can be drawn */ - if (dflag & (GP_DRAWDATA_ONLY3D|GP_DRAWDATA_ONLYV2D)) + if (dflag & (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_ONLYV2D)) return; /* if drawing a single point, draw it larger */ if (totpoints == 1) { /* draw point */ glBegin(GL_POINTS); - glVertex2iv(&points->x); + glVertex2iv(&points->x); glEnd(); } else if (sflag & GP_STROKE_ERASER) { @@ -122,7 +122,7 @@ static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thick glLineWidth(oldpressure * thickness); glBegin(GL_LINE_STRIP); - for (i=0, pt=points; i < totpoints && pt; i++, pt++) { + for (i = 0, pt = points; i < totpoints && pt; i++, pt++) { /* if there was a significant pressure change, stop the curve, change the thickness of the stroke, * and continue drawing again (since line-width cannot change in middle of GL_LINE_STRIP) */ @@ -154,12 +154,12 @@ static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thick /* ----- Existing Strokes Drawing (3D and Point) ------ */ /* draw a given stroke - just a single dot (only one point) */ -static void gp_draw_stroke_point (bGPDspoint *points, short thickness, short dflag, short sflag, int offsx, int offsy, int winx, int winy) +static void gp_draw_stroke_point(bGPDspoint *points, short thickness, short dflag, short sflag, int offsx, int offsy, int winx, int winy) { /* draw point */ if (sflag & GP_STROKE_3DSPACE) { glBegin(GL_POINTS); - glVertex3fv(&points->x); + glVertex3fv(&points->x); glEnd(); } else { @@ -167,26 +167,26 @@ static void gp_draw_stroke_point (bGPDspoint *points, short thickness, short dfl /* get coordinates of point */ if (sflag & GP_STROKE_2DSPACE) { - co[0]= points->x; - co[1]= points->y; + co[0] = points->x; + co[1] = points->y; } else if (sflag & GP_STROKE_2DIMAGE) { - co[0]= (points->x * winx) + offsx; - co[1]= (points->y * winy) + offsy; + co[0] = (points->x * winx) + offsx; + co[1] = (points->y * winy) + offsy; } else { - co[0]= (points->x / 100 * winx) + offsx; - co[1]= (points->y / 100 * winy) + offsy; + co[0] = (points->x / 100 * winx) + offsx; + co[1] = (points->y / 100 * winy) + offsy; } /* if thickness is less than GP_DRAWTHICKNESS_SPECIAL, simple dot looks ok - * - also mandatory in if Image Editor 'image-based' dot + * - also mandatory in if Image Editor 'image-based' dot */ if ( (thickness < GP_DRAWTHICKNESS_SPECIAL) || - ((dflag & GP_DRAWDATA_IEDITHACK) && (sflag & GP_STROKE_2DSPACE)) ) + ((dflag & GP_DRAWDATA_IEDITHACK) && (sflag & GP_STROKE_2DSPACE)) ) { glBegin(GL_POINTS); - glVertex2fv(co); + glVertex2fv(co); glEnd(); } else { @@ -206,7 +206,7 @@ static void gp_draw_stroke_point (bGPDspoint *points, short thickness, short dfl } /* draw a given stroke in 3d (i.e. in 3d-space), using simple ogl lines */ -static void gp_draw_stroke_3d (bGPDspoint *points, int totpoints, short thickness, short debug) +static void gp_draw_stroke_3d(bGPDspoint *points, int totpoints, short thickness, short debug) { bGPDspoint *pt; float oldpressure = 0.0f; @@ -214,7 +214,7 @@ static void gp_draw_stroke_3d (bGPDspoint *points, int totpoints, short thicknes /* draw stroke curve */ glBegin(GL_LINE_STRIP); - for (i=0, pt=points; i < totpoints && pt; i++, pt++) { + for (i = 0, pt = points; i < totpoints && pt; i++, pt++) { /* if there was a significant pressure change, stop the curve, change the thickness of the stroke, * and continue drawing again (since line-width cannot change in middle of GL_LINE_STRIP) */ @@ -240,7 +240,7 @@ static void gp_draw_stroke_3d (bGPDspoint *points, int totpoints, short thicknes /* draw debug points of curve on top? */ if (debug) { glBegin(GL_POINTS); - for (i=0, pt=points; i < totpoints && pt; i++, pt++) + for (i = 0, pt = points; i < totpoints && pt; i++, pt++) glVertex3fv(&pt->x); glEnd(); } @@ -249,35 +249,35 @@ static void gp_draw_stroke_3d (bGPDspoint *points, int totpoints, short thicknes /* ----- Fancy 2D-Stroke Drawing ------ */ /* draw a given stroke in 2d */ -static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s, short dflag, short sflag, - short debug, int offsx, int offsy, int winx, int winy) +static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s, short dflag, short sflag, + short debug, int offsx, int offsy, int winx, int winy) { /* otherwise thickness is twice that of the 3D view */ - float thickness= (float)thickness_s * 0.5f; + float thickness = (float)thickness_s * 0.5f; /* if thickness is less than GP_DRAWTHICKNESS_SPECIAL, 'smooth' opengl lines look better - * - 'smooth' opengl lines are also required if Image Editor 'image-based' stroke + * - 'smooth' opengl lines are also required if Image Editor 'image-based' stroke */ if ( (thickness < GP_DRAWTHICKNESS_SPECIAL) || - ((dflag & GP_DRAWDATA_IEDITHACK) && (dflag & GP_DRAWDATA_ONLYV2D)) ) + ((dflag & GP_DRAWDATA_IEDITHACK) && (dflag & GP_DRAWDATA_ONLYV2D)) ) { bGPDspoint *pt; int i; glBegin(GL_LINE_STRIP); - for (i=0, pt=points; i < totpoints && pt; i++, pt++) { + for (i = 0, pt = points; i < totpoints && pt; i++, pt++) { if (sflag & GP_STROKE_2DSPACE) { glVertex2f(pt->x, pt->y); } else if (sflag & GP_STROKE_2DIMAGE) { - const float x= (pt->x * winx) + offsx; - const float y= (pt->y * winy) + offsy; + const float x = (pt->x * winx) + offsx; + const float y = (pt->y * winy) + offsy; glVertex2f(x, y); } else { - const float x= (pt->x / 100 * winx) + offsx; - const float y= (pt->y / 100 * winy) + offsy; + const float x = (pt->x / 100 * winx) + offsx; + const float y = (pt->y / 100 * winy) + offsy; glVertex2f(x, y); } @@ -296,67 +296,67 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s glShadeModel(GL_FLAT); glBegin(GL_QUADS); - for (i=0, pt1=points, pt2=points+1; i < (totpoints-1); i++, pt1++, pt2++) { - float s0[2], s1[2]; /* segment 'center' points */ - float t0[2], t1[2]; /* tessellated coordinates */ - float m1[2], m2[2]; /* gradient and normal */ - float mt[2], sc[2]; /* gradient for thickness, point for end-cap */ - float pthick; /* thickness at segment point */ + for (i = 0, pt1 = points, pt2 = points + 1; i < (totpoints - 1); i++, pt1++, pt2++) { + float s0[2], s1[2]; /* segment 'center' points */ + float t0[2], t1[2]; /* tessellated coordinates */ + float m1[2], m2[2]; /* gradient and normal */ + float mt[2], sc[2]; /* gradient for thickness, point for end-cap */ + float pthick; /* thickness at segment point */ /* get x and y coordinates from points */ if (sflag & GP_STROKE_2DSPACE) { - s0[0]= pt1->x; s0[1]= pt1->y; - s1[0]= pt2->x; s1[1]= pt2->y; + s0[0] = pt1->x; s0[1] = pt1->y; + s1[0] = pt2->x; s1[1] = pt2->y; } else if (sflag & GP_STROKE_2DIMAGE) { - s0[0]= (pt1->x * winx) + offsx; - s0[1]= (pt1->y * winy) + offsy; - s1[0]= (pt2->x * winx) + offsx; - s1[1]= (pt2->y * winy) + offsy; + s0[0] = (pt1->x * winx) + offsx; + s0[1] = (pt1->y * winy) + offsy; + s1[0] = (pt2->x * winx) + offsx; + s1[1] = (pt2->y * winy) + offsy; } else { - s0[0]= (pt1->x / 100 * winx) + offsx; - s0[1]= (pt1->y / 100 * winy) + offsy; - s1[0]= (pt2->x / 100 * winx) + offsx; - s1[1]= (pt2->y / 100 * winy) + offsy; + s0[0] = (pt1->x / 100 * winx) + offsx; + s0[1] = (pt1->y / 100 * winy) + offsy; + s1[0] = (pt2->x / 100 * winx) + offsx; + s1[1] = (pt2->y / 100 * winy) + offsy; } /* calculate gradient and normal - 'angle'=(ny/nx) */ - m1[1]= s1[1] - s0[1]; - m1[0]= s1[0] - s0[0]; + m1[1] = s1[1] - s0[1]; + m1[0] = s1[0] - s0[0]; normalize_v2(m1); - m2[1]= -m1[0]; - m2[0]= m1[1]; + m2[1] = -m1[0]; + m2[0] = m1[1]; /* always use pressure from first point here */ - pthick= (pt1->pressure * thickness); + pthick = (pt1->pressure * thickness); /* if the first segment, start of segment is segment's normal */ if (i == 0) { /* draw start cap first * - make points slightly closer to center (about halfway across) */ - mt[0]= m2[0] * pthick * 0.5f; - mt[1]= m2[1] * pthick * 0.5f; - sc[0]= s0[0] - (m1[0] * pthick * 0.75f); - sc[1]= s0[1] - (m1[1] * pthick * 0.75f); - - t0[0]= sc[0] - mt[0]; - t0[1]= sc[1] - mt[1]; - t1[0]= sc[0] + mt[0]; - t1[1]= sc[1] + mt[1]; + mt[0] = m2[0] * pthick * 0.5f; + mt[1] = m2[1] * pthick * 0.5f; + sc[0] = s0[0] - (m1[0] * pthick * 0.75f); + sc[1] = s0[1] - (m1[1] * pthick * 0.75f); + + t0[0] = sc[0] - mt[0]; + t0[1] = sc[1] - mt[1]; + t1[0] = sc[0] + mt[0]; + t1[1] = sc[1] + mt[1]; glVertex2fv(t0); glVertex2fv(t1); /* calculate points for start of segment */ - mt[0]= m2[0] * pthick; - mt[1]= m2[1] * pthick; + mt[0] = m2[0] * pthick; + mt[1] = m2[1] * pthick; - t0[0]= s0[0] - mt[0]; - t0[1]= s0[1] - mt[1]; - t1[0]= s0[0] + mt[0]; - t1[1]= s0[1] + mt[1]; + t0[0] = s0[0] - mt[0]; + t0[1] = s0[1] - mt[1]; + t1[0] = s0[0] + mt[0]; + t1[1] = s0[1] + mt[1]; /* draw this line twice (first to finish off start cap, then for stroke) */ glVertex2fv(t1); @@ -366,33 +366,33 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s } /* if not the first segment, use bisector of angle between segments */ else { - float mb[2]; /* bisector normal */ - float athick, dfac; /* actual thickness, difference between thicknesses */ + float mb[2]; /* bisector normal */ + float athick, dfac; /* actual thickness, difference between thicknesses */ /* calculate gradient of bisector (as average of normals) */ - mb[0]= (pm[0] + m2[0]) / 2; - mb[1]= (pm[1] + m2[1]) / 2; + mb[0] = (pm[0] + m2[0]) / 2; + mb[1] = (pm[1] + m2[1]) / 2; normalize_v2(mb); /* calculate gradient to apply - * - as basis, use just pthick * bisector gradient + * - as basis, use just pthick * bisector gradient * - if cross-section not as thick as it should be, add extra padding to fix it */ - mt[0]= mb[0] * pthick; - mt[1]= mb[1] * pthick; - athick= len_v2(mt); - dfac= pthick - (athick * 2); + mt[0] = mb[0] * pthick; + mt[1] = mb[1] * pthick; + athick = len_v2(mt); + dfac = pthick - (athick * 2); - if (((athick * 2.0f) < pthick) && (IS_EQF(athick, pthick)==0)) { + if (((athick * 2.0f) < pthick) && (IS_EQF(athick, pthick) == 0)) { mt[0] += (mb[0] * dfac); mt[1] += (mb[1] * dfac); } /* calculate points for start of segment */ - t0[0]= s0[0] - mt[0]; - t0[1]= s0[1] - mt[1]; - t1[0]= s0[0] + mt[0]; - t1[1]= s0[1] + mt[1]; + t0[0] = s0[0] - mt[0]; + t0[1] = s0[1] - mt[1]; + t1[0] = s0[0] + mt[0]; + t1[1] = s0[1] + mt[1]; /* draw this line twice (once for end of current segment, and once for start of next) */ glVertex2fv(t1); @@ -402,18 +402,18 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s } /* if last segment, also draw end of segment (defined as segment's normal) */ - if (i == totpoints-2) { + if (i == totpoints - 2) { /* for once, we use second point's pressure (otherwise it won't be drawn) */ - pthick= (pt2->pressure * thickness); + pthick = (pt2->pressure * thickness); /* calculate points for end of segment */ - mt[0]= m2[0] * pthick; - mt[1]= m2[1] * pthick; + mt[0] = m2[0] * pthick; + mt[1] = m2[1] * pthick; - t0[0]= s1[0] - mt[0]; - t0[1]= s1[1] - mt[1]; - t1[0]= s1[0] + mt[0]; - t1[1]= s1[1] + mt[1]; + t0[0] = s1[0] - mt[0]; + t0[1] = s1[1] - mt[1]; + t1[0] = s1[0] + mt[0]; + t1[1] = s1[1] + mt[1]; /* draw this line twice (once for end of stroke, and once for endcap)*/ glVertex2fv(t1); @@ -425,15 +425,15 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s /* draw end cap as last step * - make points slightly closer to center (about halfway across) */ - mt[0]= m2[0] * pthick * 0.5f; - mt[1]= m2[1] * pthick * 0.5f; - sc[0]= s1[0] + (m1[0] * pthick * 0.75f); - sc[1]= s1[1] + (m1[1] * pthick * 0.75f); - - t0[0]= sc[0] - mt[0]; - t0[1]= sc[1] - mt[1]; - t1[0]= sc[0] + mt[0]; - t1[1]= sc[1] + mt[1]; + mt[0] = m2[0] * pthick * 0.5f; + mt[1] = m2[1] * pthick * 0.5f; + sc[0] = s1[0] + (m1[0] * pthick * 0.75f); + sc[1] = s1[1] + (m1[1] * pthick * 0.75f); + + t0[0] = sc[0] - mt[0]; + t0[1] = sc[1] - mt[1]; + t1[0] = sc[0] + mt[0]; + t1[1] = sc[1] + mt[1]; glVertex2fv(t1); glVertex2fv(t0); @@ -452,19 +452,19 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s int i; glBegin(GL_POINTS); - for (i=0, pt=points; i < totpoints && pt; i++, pt++) { + for (i = 0, pt = points; i < totpoints && pt; i++, pt++) { if (sflag & GP_STROKE_2DSPACE) { glVertex2fv(&pt->x); } else if (sflag & GP_STROKE_2DIMAGE) { - const float x= (float)((pt->x * winx) + offsx); - const float y= (float)((pt->y * winy) + offsy); + const float x = (float)((pt->x * winx) + offsx); + const float y = (float)((pt->y * winy) + offsy); glVertex2f(x, y); } else { - const float x= (float)(pt->x / 100 * winx) + offsx; - const float y= (float)(pt->y / 100 * winy) + offsy; + const float x = (float)(pt->x / 100 * winx) + offsx; + const float y = (float)(pt->y / 100 * winy) + offsy; glVertex2f(x, y); } @@ -476,15 +476,15 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s /* ----- General Drawing ------ */ /* draw a set of strokes */ -static void gp_draw_strokes (bGPDframe *gpf, int offsx, int offsy, int winx, int winy, int dflag, - short debug, short lthick, float color[4]) +static void gp_draw_strokes(bGPDframe *gpf, int offsx, int offsy, int winx, int winy, int dflag, + short debug, short lthick, float color[4]) { bGPDstroke *gps; /* set color first (may need to reset it again later too) */ glColor4fv(color); - for (gps= gpf->strokes.first; gps; gps= gps->next) { + for (gps = gpf->strokes.first; gps; gps = gps->next) { /* check if stroke can be drawn - checks here generally fall into pairs */ if ((dflag & GP_DRAWDATA_ONLY3D) && !(gps->flag & GP_STROKE_3DSPACE)) continue; @@ -505,7 +505,7 @@ static void gp_draw_strokes (bGPDframe *gpf, int offsx, int offsy, int winx, int if (gps->totpoints == 1) gp_draw_stroke_point(gps->points, lthick, dflag, gps->flag, offsx, offsy, winx, winy); else if (dflag & GP_DRAWDATA_ONLY3D) { - const int no_xray= (dflag & GP_DRAWDATA_NO_XRAY); + const int no_xray = (dflag & GP_DRAWDATA_NO_XRAY); int mask_orig = 0; if (no_xray) { @@ -540,7 +540,7 @@ static void gp_draw_strokes (bGPDframe *gpf, int offsx, int offsy, int winx, int } /* draw grease-pencil datablock */ -static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy, int cfra, int dflag) +static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy, int cfra, int dflag) { bGPDlayer *gpl; @@ -555,11 +555,11 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy glEnable(GL_BLEND); /* loop over layers, drawing them */ - for (gpl= gpd->layers.first; gpl; gpl= gpl->next) { + for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { bGPDframe *gpf; short debug = (gpl->flag & GP_LAYER_DRAWDEBUG) ? 1 : 0; - short lthick= gpl->thickness; + short lthick = gpl->thickness; float color[4], tcolor[4]; /* don't draw layer if hidden */ @@ -567,7 +567,7 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy continue; /* get frame to draw */ - gpf= gpencil_layer_getframe(gpl, cfra, 0); + gpf = gpencil_layer_getframe(gpl, cfra, 0); if (gpf == NULL) continue; @@ -579,8 +579,8 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy glPointSize((float)(gpl->thickness + 2)); /* apply xray layer setting */ - if (gpl->flag & GP_LAYER_NO_XRAY) dflag |= GP_DRAWDATA_NO_XRAY; - else dflag &= ~GP_DRAWDATA_NO_XRAY; + if (gpl->flag & GP_LAYER_NO_XRAY) dflag |= GP_DRAWDATA_NO_XRAY; + else dflag &= ~GP_DRAWDATA_NO_XRAY; /* draw 'onionskins' (frame left + right) */ if (gpl->flag & GP_LAYER_ONIONSKIN) { @@ -590,11 +590,11 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy float fac; /* draw previous frames first */ - for (gf=gpf->prev; gf; gf=gf->prev) { + for (gf = gpf->prev; gf; gf = gf->prev) { /* check if frame is drawable */ if ((gpf->framenum - gf->framenum) <= gpl->gstep) { /* alpha decreases with distance from curframe index */ - fac= 1.0f - ((float)(gpf->framenum - gf->framenum) / (float)(gpl->gstep + 1)); + fac = 1.0f - ((float)(gpf->framenum - gf->framenum) / (float)(gpl->gstep + 1)); tcolor[3] = color[3] * fac * 0.66f; gp_draw_strokes(gf, offsx, offsy, winx, winy, dflag, debug, lthick, tcolor); } @@ -603,11 +603,11 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy } /* now draw next frames */ - for (gf= gpf->next; gf; gf=gf->next) { + for (gf = gpf->next; gf; gf = gf->next) { /* check if frame is drawable */ if ((gf->framenum - gpf->framenum) <= gpl->gstep) { /* alpha decreases with distance from curframe index */ - fac= 1.0f - ((float)(gf->framenum - gpf->framenum) / (float)(gpl->gstep + 1)); + fac = 1.0f - ((float)(gf->framenum - gpf->framenum) / (float)(gpl->gstep + 1)); tcolor[3] = color[3] * fac * 0.66f; gp_draw_strokes(gf, offsx, offsy, winx, winy, dflag, debug, lthick, tcolor); } @@ -636,14 +636,14 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy } /* draw the strokes already in active frame */ - tcolor[3]= color[3]; + tcolor[3] = color[3]; gp_draw_strokes(gpf, offsx, offsy, winx, winy, dflag, debug, lthick, tcolor); /* Check if may need to draw the active stroke cache, only if this layer is the active layer * that is being edited. (Stroke buffer is currently stored in gp-data) */ if (ED_gpencil_session_active() && (gpl->flag & GP_LAYER_ACTIVE) && - (gpf->flag & GP_FRAME_PAINT)) + (gpf->flag & GP_FRAME_PAINT)) { /* Buffer stroke needs to be drawn with a different linestyle to help differentiate them from normal strokes. */ gp_draw_stroke_buffer(gpd->sbuffer, gpd->sbuffer_size, lthick, dflag, gpd->sbuffer_sflag); @@ -671,16 +671,16 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy /* draw grease-pencil sketches to specified 2d-view that uses ibuf corrections */ void draw_gpencil_2dimage(bContext *C, ImBuf *ibuf) { - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= CTX_wm_region(C); - Scene *scene= CTX_data_scene(C); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); bGPdata *gpd; int offsx, offsy, sizex, sizey; int dflag = GP_DRAWDATA_NOSTATUS; /* check that we have grease-pencil stuff to draw */ if (ELEM(NULL, sa, ibuf)) return; - gpd= gpencil_data_get_active(C); // XXX + gpd = gpencil_data_get_active(C); // XXX if (gpd == NULL) return; /* calculate rect */ @@ -691,24 +691,24 @@ void draw_gpencil_2dimage(bContext *C, ImBuf *ibuf) /* just draw using standard scaling (settings here are currently ignored anyways) */ // FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled - offsx= 0; - offsy= 0; - sizex= ar->winx; - sizey= ar->winy; + offsx = 0; + offsy = 0; + sizex = ar->winx; + sizey = ar->winy; wmOrtho2(ar->v2d.cur.xmin, ar->v2d.cur.xmax, ar->v2d.cur.ymin, ar->v2d.cur.ymax); - dflag |= GP_DRAWDATA_ONLYV2D|GP_DRAWDATA_IEDITHACK; + dflag |= GP_DRAWDATA_ONLYV2D | GP_DRAWDATA_IEDITHACK; } - break; -#if 0 /* removed since 2.5x, needs to be added back */ + break; +#if 0 /* removed since 2.5x, needs to be added back */ case SPACE_SEQ: /* sequence */ { - SpaceSeq *sseq= (SpaceSeq *)sa->spacedata.first; + SpaceSeq *sseq = (SpaceSeq *)sa->spacedata.first; float zoom, zoomx, zoomy; /* calculate accessory values */ - zoom= (float)(SEQ_ZOOM_FAC(sseq->zoom)); + zoom = (float)(SEQ_ZOOM_FAC(sseq->zoom)); if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { /* XXX sequencer zoom should store it? */ zoomx = zoom; // * (G.scene->r.xasp / G.scene->r.yasp); @@ -718,20 +718,20 @@ void draw_gpencil_2dimage(bContext *C, ImBuf *ibuf) zoomx = zoomy = zoom; /* calculate transforms (Note: we use ibuf here, as we have it) */ - sizex= (int)(zoomx * ibuf->x); - sizey= (int)(zoomy * ibuf->y); - offsx= (int)( (ar->winx-sizex)/2 + sseq->xof ); - offsy= (int)( (ar->winy-sizey)/2 + sseq->yof ); + sizex = (int)(zoomx * ibuf->x); + sizey = (int)(zoomy * ibuf->y); + offsx = (int)( (ar->winx - sizex) / 2 + sseq->xof); + offsy = (int)( (ar->winy - sizey) / 2 + sseq->yof); dflag |= GP_DRAWDATA_ONLYI2D; } - break; + break; #endif default: /* for spacetype not yet handled */ - offsx= 0; - offsy= 0; - sizex= ar->winx; - sizey= ar->winy; + offsx = 0; + offsy = 0; + sizex = ar->winx; + sizey = ar->winy; dflag |= GP_DRAWDATA_ONLYI2D; break; @@ -747,15 +747,15 @@ void draw_gpencil_2dimage(bContext *C, ImBuf *ibuf) */ void draw_gpencil_view2d(bContext *C, short onlyv2d) { - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= CTX_wm_region(C); - Scene *scene= CTX_data_scene(C); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); bGPdata *gpd; int dflag = 0; /* check that we have grease-pencil stuff to draw */ if (sa == NULL) return; - gpd= gpencil_data_get_active(C); // XXX + gpd = gpencil_data_get_active(C); // XXX if (gpd == NULL) return; /* special hack for Image Editor */ @@ -764,7 +764,7 @@ void draw_gpencil_view2d(bContext *C, short onlyv2d) dflag |= GP_DRAWDATA_IEDITHACK; /* draw it! */ - if (onlyv2d) dflag |= (GP_DRAWDATA_ONLYV2D|GP_DRAWDATA_NOSTATUS); + if (onlyv2d) dflag |= (GP_DRAWDATA_ONLYV2D | GP_DRAWDATA_NOSTATUS); gp_draw_data(gpd, 0, 0, ar->winx, ar->winy, CFRA, dflag); } @@ -777,10 +777,10 @@ void draw_gpencil_view3d(Scene *scene, View3D *v3d, ARegion *ar, short only3d) bGPdata *gpd; int dflag = 0; rcti rect; - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; /* check that we have grease-pencil stuff to draw */ - gpd= gpencil_data_get_active_v3d(scene); // XXX + gpd = gpencil_data_get_active_v3d(scene); // XXX if (gpd == NULL) return; /* when rendering to the offscreen buffer we don't want to @@ -798,7 +798,7 @@ void draw_gpencil_view3d(Scene *scene, View3D *v3d, ARegion *ar, short only3d) } /* draw it! */ - if (only3d) dflag |= (GP_DRAWDATA_ONLY3D|GP_DRAWDATA_NOSTATUS); + if (only3d) dflag |= (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_NOSTATUS); gp_draw_data(gpd, rect.xmin, rect.ymin, rect.xmax, rect.ymax, CFRA, dflag); } diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c index b79516ed25e..9cc738b016e 100644 --- a/source/blender/editors/gpencil/editaction_gpencil.c +++ b/source/blender/editors/gpencil/editaction_gpencil.c @@ -54,9 +54,9 @@ /* ***************************************** */ /* NOTE ABOUT THIS FILE: - * This file contains code for editing Grease Pencil data in the Action Editor - * as a 'keyframes', so that a user can adjust the timing of Grease Pencil drawings. - * Therefore, this file mostly contains functions for selecting Grease-Pencil frames. + * This file contains code for editing Grease Pencil data in the Action Editor + * as a 'keyframes', so that a user can adjust the timing of Grease Pencil drawings. + * Therefore, this file mostly contains functions for selecting Grease-Pencil frames. */ /* ***************************************** */ /* Generics - Loopers */ @@ -71,7 +71,7 @@ short gplayer_frames_looper(bGPDlayer *gpl, Scene *scene, short (*gpf_cb)(bGPDfr return 0; /* do loop */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { /* execute callback */ if (gpf_cb(gpf, scene)) return 1; @@ -95,12 +95,12 @@ void gplayer_make_cfra_list(bGPDlayer *gpl, ListBase *elems, short onlysel) return; /* loop through gp-frames, adding */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { if ((onlysel == 0) || (gpf->flag & GP_FRAME_SELECT)) { - ce= MEM_callocN(sizeof(CfraElem), "CfraElem"); + ce = MEM_callocN(sizeof(CfraElem), "CfraElem"); - ce->cfra= (float)gpf->framenum; - ce->sel= (gpf->flag & GP_FRAME_SELECT) ? 1 : 0; + ce->cfra = (float)gpf->framenum; + ce->sel = (gpf->flag & GP_FRAME_SELECT) ? 1 : 0; BLI_addtail(elems, ce); } @@ -120,7 +120,7 @@ short is_gplayer_frame_selected(bGPDlayer *gpl) return 0; /* stop at the first one found */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { if (gpf->flag & GP_FRAME_SELECT) return 1; } @@ -130,7 +130,7 @@ short is_gplayer_frame_selected(bGPDlayer *gpl) } /* helper function - select gp-frame based on SELECT_* mode */ -static void gpframe_select (bGPDframe *gpf, short select_mode) +static void gpframe_select(bGPDframe *gpf, short select_mode) { if (gpf == NULL) return; @@ -158,7 +158,7 @@ void select_gpencil_frames(bGPDlayer *gpl, short select_mode) return; /* handle according to mode */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { gpframe_select(gpf, select_mode); } } @@ -183,7 +183,7 @@ void select_gpencil_frame(bGPDlayer *gpl, int selx, short select_mode) return; /* search through frames for a match */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { /* there should only be one frame with this frame-number */ if (gpf->framenum == selx) { gpframe_select(gpf, select_mode); @@ -201,7 +201,7 @@ void borderselect_gplayer_frames(bGPDlayer *gpl, float min, float max, short sel return; /* only select those frames which are in bounds */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { if (IN_RANGE(gpf->framenum, min, max)) gpframe_select(gpf, select_mode); } @@ -220,8 +220,8 @@ void delete_gplayer_frames(bGPDlayer *gpl) return; /* check for frames to delete */ - for (gpf= gpl->frames.first; gpf; gpf= gpfn) { - gpfn= gpf->next; + for (gpf = gpl->frames.first; gpf; gpf = gpfn) { + gpfn = gpf->next; if (gpf->flag & GP_FRAME_SELECT) gpencil_layer_delframe(gpl, gpf); @@ -238,15 +238,15 @@ void duplicate_gplayer_frames(bGPDlayer *gpl) return; /* duplicate selected frames */ - for (gpf= gpl->frames.first; gpf; gpf= gpfn) { - gpfn= gpf->next; + for (gpf = gpl->frames.first; gpf; gpf = gpfn) { + gpfn = gpf->next; /* duplicate this frame */ if (gpf->flag & GP_FRAME_SELECT) { bGPDframe *gpfd; /* duplicate frame, and deselect self */ - gpfd= gpencil_frame_duplicate(gpf); + gpfd = gpencil_frame_duplicate(gpf); gpf->flag &= ~GP_FRAME_SELECT; BLI_insertlinkafter(&gpl->frames, gpf, gpfd); @@ -267,15 +267,15 @@ void duplicate_gplayer_frames(bGPDlayer *gpl) /* globals for copy/paste data (like for other copy/paste buffers) */ ListBase gpcopybuf = {NULL, NULL}; -static int gpcopy_firstframe= 999999999; +static int gpcopy_firstframe = 999999999; /* This function frees any MEM_calloc'ed copy/paste buffer data */ void free_gpcopybuf() { free_gpencil_layers(&gpcopybuf); - gpcopybuf.first= gpcopybuf.last= NULL; - gpcopy_firstframe= 999999999; + gpcopybuf.first = gpcopybuf.last = NULL; + gpcopy_firstframe = 999999999; } /* This function adds data to the copy/paste buffer, freeing existing data first @@ -293,39 +293,39 @@ void copy_gpdata() free_gpcopybuf(); /* get data */ - data= get_action_context(&datatype); + data = get_action_context(&datatype); if (data == NULL) return; if (datatype != ACTCONT_GPENCIL) return; /* filter data */ - filter= (ACTFILTER_VISIBLE | ACTFILTER_SEL); + filter = (ACTFILTER_VISIBLE | ACTFILTER_SEL); actdata_filter(&act_data, filter, data, datatype); /* assume that each of these is an ipo-block */ - for (ale= act_data.first; ale; ale= ale->next) { + for (ale = act_data.first; ale; ale = ale->next) { bGPDlayer *gpls, *gpln; bGPDframe *gpf, *gpfn; /* get new layer to put into buffer */ - gpls= (bGPDlayer *)ale->data; - gpln= MEM_callocN(sizeof(bGPDlayer), "GPCopyPasteLayer"); + gpls = (bGPDlayer *)ale->data; + gpln = MEM_callocN(sizeof(bGPDlayer), "GPCopyPasteLayer"); - gpln->frames.first= gpln->frames.last= NULL; + gpln->frames.first = gpln->frames.last = NULL; BLI_strncpy(gpln->info, gpls->info, sizeof(gpln->info)); BLI_addtail(&gpcopybuf, gpln); /* loop over frames, and copy only selected frames */ - for (gpf= gpls->frames.first; gpf; gpf= gpf->next) { + for (gpf = gpls->frames.first; gpf; gpf = gpf->next) { /* if frame is selected, make duplicate it and its strokes */ if (gpf->flag & GP_FRAME_SELECT) { /* add frame to buffer */ - gpfn= gpencil_frame_duplicate(gpf); + gpfn = gpencil_frame_duplicate(gpf); BLI_addtail(&gpln->frames, gpfn); /* check if this is the earliest frame encountered so far */ if (gpf->framenum < gpcopy_firstframe) - gpcopy_firstframe= gpf->framenum; + gpcopy_firstframe = gpf->framenum; } } } @@ -347,7 +347,7 @@ void paste_gpdata(Scene *scene) short datatype; const int offset = (CFRA - gpcopy_firstframe); - short no_name= 0; + short no_name = 0; /* check if buffer is empty */ if (ELEM(NULL, gpcopybuf.first, gpcopybuf.last)) { @@ -356,27 +356,27 @@ void paste_gpdata(Scene *scene) } /* check if single channel in buffer (disregard names if so) */ if (gpcopybuf.first == gpcopybuf.last) - no_name= 1; + no_name = 1; /* get data */ - data= get_action_context(&datatype); + data = get_action_context(&datatype); if (data == NULL) return; if (datatype != ACTCONT_GPENCIL) return; /* filter data */ - filter= (ACTFILTER_VISIBLE | ACTFILTER_SEL | ACTFILTER_FOREDIT); + filter = (ACTFILTER_VISIBLE | ACTFILTER_SEL | ACTFILTER_FOREDIT); actdata_filter(&act_data, filter, data, datatype); /* from selected channels */ - for (ale= act_data.first; ale; ale= ale->next) { - bGPDlayer *gpld= (bGPDlayer *)ale->data; - bGPDlayer *gpls= NULL; + for (ale = act_data.first; ale; ale = ale->next) { + bGPDlayer *gpld = (bGPDlayer *)ale->data; + bGPDlayer *gpls = NULL; bGPDframe *gpfs, *gpf; /* find suitable layer from buffer to use to paste from */ - for (gpls= gpcopybuf.first; gpls; gpls= gpls->next) { + for (gpls = gpcopybuf.first; gpls; gpls = gpls->next) { /* check if layer name matches */ - if ((no_name) || (strcmp(gpls->info, gpld->info)==0)) + if ((no_name) || (strcmp(gpls->info, gpld->info) == 0)) break; } @@ -385,12 +385,12 @@ void paste_gpdata(Scene *scene) continue; /* add frames from buffer */ - for (gpfs= gpls->frames.first; gpfs; gpfs= gpfs->next) { + for (gpfs = gpls->frames.first; gpfs; gpfs = gpfs->next) { /* temporarily apply offset to buffer-frame while copying */ gpfs->framenum += offset; /* get frame to copy data into (if no frame returned, then just ignore) */ - gpf= gpencil_layer_getframe(gpld, gpfs->framenum, 1); + gpf = gpencil_layer_getframe(gpld, gpfs->framenum, 1); if (gpf) { bGPDstroke *gps, *gpsn; ScrArea *sa; @@ -404,12 +404,12 @@ void paste_gpdata(Scene *scene) * - we cannot just add a duplicate frame, as that would cause errors * - need to check for compatible types to minimise memory usage (copying 'junk' over) */ - for (gps= gpfs->strokes.first; gps; gps= gps->next) { + for (gps = gpfs->strokes.first; gps; gps = gps->next) { short stroke_ok; /* if there's an area, check that it supports this type of stroke */ if (sa) { - stroke_ok= 0; + stroke_ok = 0; /* check if spacetype supports this type of stroke * - NOTE: must sync this with gp_paint_initstroke() in gpencil.c @@ -417,30 +417,30 @@ void paste_gpdata(Scene *scene) switch (sa->spacetype) { case SPACE_VIEW3D: /* 3D-View: either screen-aligned or 3d-space */ if ((gps->flag == 0) || (gps->flag & GP_STROKE_3DSPACE)) - stroke_ok= 1; + stroke_ok = 1; break; case SPACE_NODE: /* Nodes Editor: either screen-aligned or view-aligned */ case SPACE_IMAGE: /* Image Editor: either screen-aligned or view\image-aligned */ case SPACE_CLIP: /* Image Editor: either screen-aligned or view\image-aligned */ if ((gps->flag == 0) || (gps->flag & GP_STROKE_2DSPACE)) - stroke_ok= 1; + stroke_ok = 1; break; case SPACE_SEQ: /* Sequence Editor: either screen-aligned or view-aligned */ if ((gps->flag == 0) || (gps->flag & GP_STROKE_2DIMAGE)) - stroke_ok= 1; + stroke_ok = 1; break; } } else - stroke_ok= 1; + stroke_ok = 1; /* if stroke is ok, we make a copy of this stroke and add to frame */ if (stroke_ok) { /* make a copy of stroke, then of its points array */ - gpsn= MEM_dupallocN(gps); - gpsn->points= MEM_dupallocN(gps->points); + gpsn = MEM_dupallocN(gps); + gpsn->points = MEM_dupallocN(gps->points); /* append stroke to frame */ BLI_addtail(&gpf->strokes, gpsn); @@ -467,32 +467,32 @@ void paste_gpdata(Scene *scene) /* -------------------------------------- */ /* Snap Tools */ -static short snap_gpf_nearest (bGPDframe *gpf, Scene *scene) +static short snap_gpf_nearest(bGPDframe *gpf, Scene *scene) { if (gpf->flag & GP_FRAME_SELECT) - gpf->framenum= (int)(floor(gpf->framenum+0.5)); + gpf->framenum = (int)(floor(gpf->framenum + 0.5)); return 0; } -static short snap_gpf_nearestsec (bGPDframe *gpf, Scene *scene) +static short snap_gpf_nearestsec(bGPDframe *gpf, Scene *scene) { float secf = (float)FPS; if (gpf->flag & GP_FRAME_SELECT) - gpf->framenum= (int)(floor(gpf->framenum/secf + 0.5f) * secf); + gpf->framenum = (int)(floor(gpf->framenum / secf + 0.5f) * secf); return 0; } -static short snap_gpf_cframe (bGPDframe *gpf, Scene *scene) +static short snap_gpf_cframe(bGPDframe *gpf, Scene *scene) { if (gpf->flag & GP_FRAME_SELECT) - gpf->framenum= (int)CFRA; + gpf->framenum = (int)CFRA; return 0; } -static short snap_gpf_nearmarker (bGPDframe *gpf, Scene *scene) +static short snap_gpf_nearmarker(bGPDframe *gpf, Scene *scene) { if (gpf->flag & GP_FRAME_SELECT) - gpf->framenum= (int)find_nearest_marker_time(&scene->markers, (float)gpf->framenum); + gpf->framenum = (int)find_nearest_marker_time(&scene->markers, (float)gpf->framenum); return 0; } @@ -522,43 +522,43 @@ void snap_gplayer_frames(bGPDlayer *gpl, Scene *scene, short mode) /* -------------------------------------- */ /* Mirror Tools */ -static short mirror_gpf_cframe (bGPDframe *gpf, Scene *scene) +static short mirror_gpf_cframe(bGPDframe *gpf, Scene *scene) { int diff; if (gpf->flag & GP_FRAME_SELECT) { - diff= CFRA - gpf->framenum; - gpf->framenum= CFRA; + diff = CFRA - gpf->framenum; + gpf->framenum = CFRA; } return 0; } -static short mirror_gpf_yaxis (bGPDframe *gpf, Scene *scene) +static short mirror_gpf_yaxis(bGPDframe *gpf, Scene *scene) { int diff; if (gpf->flag & GP_FRAME_SELECT) { - diff= -gpf->framenum; - gpf->framenum= diff; + diff = -gpf->framenum; + gpf->framenum = diff; } return 0; } -static short mirror_gpf_xaxis (bGPDframe *gpf, Scene *scene) +static short mirror_gpf_xaxis(bGPDframe *gpf, Scene *scene) { int diff; if (gpf->flag & GP_FRAME_SELECT) { - diff= -gpf->framenum; - gpf->framenum= diff; + diff = -gpf->framenum; + gpf->framenum = diff; } return 0; } -static short mirror_gpf_marker (bGPDframe *gpf, Scene *scene) +static short mirror_gpf_marker(bGPDframe *gpf, Scene *scene) { static TimeMarker *marker; static short initialized = 0; @@ -575,8 +575,8 @@ static short mirror_gpf_marker (bGPDframe *gpf, Scene *scene) if (gpf) { /* mirroring time */ if ((gpf->flag & GP_FRAME_SELECT) && (marker)) { - diff= (marker->frame - gpf->framenum); - gpf->framenum= (marker->frame + diff); + diff = (marker->frame - gpf->framenum); + gpf->framenum = (marker->frame + diff); } } else { @@ -588,9 +588,9 @@ static short mirror_gpf_marker (bGPDframe *gpf, Scene *scene) } else { /* try to find a marker */ - marker= ED_markers_get_first_selected(&scene->markers); + marker = ED_markers_get_first_selected(&scene->markers); if (marker) { - initialized= 1; + initialized = 1; } } } diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c index 263c842ed08..3a7e806c2ed 100644 --- a/source/blender/editors/gpencil/gpencil_buttons.c +++ b/source/blender/editors/gpencil/gpencil_buttons.c @@ -74,7 +74,7 @@ static void gp_ui_activelayer_cb(bContext *C, void *gpd, void *gpl) /* make sure the layer we want to remove is the active one */ gpencil_layer_setactive(gpd, gpl); - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); /* XXX please work! */ + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); /* XXX please work! */ } /* delete 'active' layer */ @@ -84,7 +84,7 @@ static void gp_ui_dellayer_cb(bContext *C, void *gpd, void *gpl) gpencil_layer_setactive(gpd, gpl); gpencil_layer_delactive(gpd); - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); /* XXX please work! */ + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); /* XXX please work! */ } @@ -133,7 +133,7 @@ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, cons uiItemR(sub, &ptr, "lock", 0, "", icon); /* when layer is locked or hidden, only draw header */ - if (gpl->flag & (GP_LAYER_LOCKED|GP_LAYER_HIDE)) { + if (gpl->flag & (GP_LAYER_LOCKED | GP_LAYER_HIDE)) { char name[256]; /* gpl->info is 128, but we need space for 'locked/hidden' as well */ /* visibility button (only if hidden but not locked!) */ @@ -197,8 +197,8 @@ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, cons /* color */ sub = uiLayoutColumn(col, 1); - uiItemR(sub, &ptr, "color", 0, "", ICON_NONE); - uiItemR(sub, &ptr, "alpha", UI_ITEM_R_SLIDER, NULL, ICON_NONE); + uiItemR(sub, &ptr, "color", 0, "", ICON_NONE); + uiItemR(sub, &ptr, "alpha", UI_ITEM_R_SLIDER, NULL, ICON_NONE); /* stroke thickness */ uiItemR(col, &ptr, "line_width", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -251,8 +251,8 @@ static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, Poin /* add new layer button - can be used even when no data, since it can add a new block too */ uiItemO(col, IFACE_("New Layer"), ICON_NONE, "GPENCIL_OT_layer_add"); row = uiLayoutRow(col, 1); - uiItemO(row, IFACE_("Delete Frame"), ICON_NONE, "GPENCIL_OT_active_frame_delete"); - uiItemO(row, IFACE_("Convert"), ICON_NONE, "GPENCIL_OT_convert"); + uiItemO(row, IFACE_("Delete Frame"), ICON_NONE, "GPENCIL_OT_active_frame_delete"); + uiItemO(row, IFACE_("Convert"), ICON_NONE, "GPENCIL_OT_convert"); /* sanity checks... */ if (gpd == NULL) @@ -266,29 +266,29 @@ static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, Poin /* draw gpd drawing settings first ------------------------------------- */ col = uiLayoutColumn(layout, 1); - /* label */ - uiItemL(col, IFACE_("Drawing Settings:"), ICON_NONE); + /* label */ + uiItemL(col, IFACE_("Drawing Settings:"), ICON_NONE); - /* check whether advanced 3D-View drawing space options can be used */ - if (is_v3d) { - if (gpd->flag & (GP_DATA_DEPTH_STROKE|GP_DATA_DEPTH_VIEW)) - v3d_stroke_opts = STROKE_OPTS_V3D_ON; - else - v3d_stroke_opts = STROKE_OPTS_V3D_OFF; - } + /* check whether advanced 3D-View drawing space options can be used */ + if (is_v3d) { + if (gpd->flag & (GP_DATA_DEPTH_STROKE | GP_DATA_DEPTH_VIEW)) + v3d_stroke_opts = STROKE_OPTS_V3D_ON; + else + v3d_stroke_opts = STROKE_OPTS_V3D_OFF; + } - /* drawing space options */ - row= uiLayoutRow(col, 1); - uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "VIEW", NULL, ICON_NONE); - uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "CURSOR", NULL, ICON_NONE); - row= uiLayoutRow(col, 1); - uiLayoutSetActive(row, v3d_stroke_opts); - uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "SURFACE", NULL, ICON_NONE); - uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "STROKE", NULL, ICON_NONE); - - row= uiLayoutRow(col, 0); - uiLayoutSetActive(row, v3d_stroke_opts==STROKE_OPTS_V3D_ON); - uiItemR(row, &gpd_ptr, "use_stroke_endpoints", 0, NULL, ICON_NONE); + /* drawing space options */ + row = uiLayoutRow(col, 1); + uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "VIEW", NULL, ICON_NONE); + uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "CURSOR", NULL, ICON_NONE); + row = uiLayoutRow(col, 1); + uiLayoutSetActive(row, v3d_stroke_opts); + uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "SURFACE", NULL, ICON_NONE); + uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "STROKE", NULL, ICON_NONE); + + row = uiLayoutRow(col, 0); + uiLayoutSetActive(row, v3d_stroke_opts == STROKE_OPTS_V3D_ON); + uiItemR(row, &gpd_ptr, "use_stroke_endpoints", 0, NULL, ICON_NONE); } diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 990b1acd321..9250d48a20c 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -77,10 +77,10 @@ /* Context Wrangling... */ /* Get pointer to active Grease Pencil datablock, and an RNA-pointer to trace back to whatever owns it */ -bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr) +bGPdata **gpencil_data_get_pointers(bContext *C, PointerRNA *ptr) { - Scene *scene= CTX_data_scene(C); - ScrArea *sa= CTX_wm_area(C); + Scene *scene = CTX_data_scene(C); + ScrArea *sa = CTX_wm_area(C); /* if there's an active area, check if the particular editor may * have defined any special Grease Pencil context for editing... @@ -89,7 +89,7 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr) switch (sa->spacetype) { case SPACE_VIEW3D: /* 3D-View */ { - Object *ob= CTX_data_active_object(C); + Object *ob = CTX_data_active_object(C); // TODO: we can include other data-types such as bones later if need be... @@ -100,11 +100,11 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr) return &ob->gpd; } } - break; + break; case SPACE_NODE: /* Nodes Editor */ { - SpaceNode *snode= (SpaceNode *)CTX_wm_space_data(C); + SpaceNode *snode = (SpaceNode *)CTX_wm_space_data(C); /* return the GP data for the active node block/node */ if (snode && snode->nodetree) { @@ -117,7 +117,7 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr) return NULL; } } - break; + break; case SPACE_SEQ: /* Sequencer */ { @@ -125,23 +125,23 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr) /* return the GP data for the active strips/image/etc. */ } - break; + break; case SPACE_IMAGE: /* Image/UV Editor */ { - SpaceImage *sima= (SpaceImage *)CTX_wm_space_data(C); + SpaceImage *sima = (SpaceImage *)CTX_wm_space_data(C); /* for now, Grease Pencil data is associated with the space... */ // XXX our convention for everything else is to link to data though... if (ptr) RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_SpaceImageEditor, sima, ptr); return &sima->gpd; } - break; + break; case SPACE_CLIP: /* Nodes Editor */ { - SpaceClip *sc= (SpaceClip *)CTX_wm_space_data(C); - MovieClip *clip= ED_space_clip(sc); + SpaceClip *sc = (SpaceClip *)CTX_wm_space_data(C); + MovieClip *clip = ED_space_clip(sc); if (clip) { /* for now, as long as there's a clip, default to using that in Clip Editor */ @@ -149,7 +149,7 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr) return &clip->gpd; } } - break; + break; default: /* unsupported space */ return NULL; @@ -162,16 +162,16 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr) } /* Get the active Grease Pencil datablock */ -bGPdata *gpencil_data_get_active (bContext *C) +bGPdata *gpencil_data_get_active(bContext *C) { - bGPdata **gpd_ptr= gpencil_data_get_pointers(C, NULL); + bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL); return (gpd_ptr) ? *(gpd_ptr) : NULL; } /* needed for offscreen rendering */ -bGPdata *gpencil_data_get_active_v3d (Scene *scene) +bGPdata *gpencil_data_get_active_v3d(Scene *scene) { - bGPdata *gpd= scene->basact ? scene->basact->object->gpd : NULL; + bGPdata *gpd = scene->basact ? scene->basact->object->gpd : NULL; return gpd ? gpd : scene->gpd; } @@ -179,7 +179,7 @@ bGPdata *gpencil_data_get_active_v3d (Scene *scene) /* Panel Operators */ /* poll callback for adding data/layers - special */ -static int gp_add_poll (bContext *C) +static int gp_add_poll(bContext *C) { /* the base line we have is that we have somewhere to add Grease Pencil data */ return gpencil_data_get_pointers(C, NULL) != NULL; @@ -188,9 +188,9 @@ static int gp_add_poll (bContext *C) /* ******************* Add New Data ************************ */ /* add new datablock - wrapper around API */ -static int gp_data_add_exec (bContext *C, wmOperator *op) +static int gp_data_add_exec(bContext *C, wmOperator *op) { - bGPdata **gpd_ptr= gpencil_data_get_pointers(C, NULL); + bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL); if (gpd_ptr == NULL) { BKE_report(op->reports, RPT_ERROR, "Nowhere for Grease Pencil data to go"); @@ -198,14 +198,14 @@ static int gp_data_add_exec (bContext *C, wmOperator *op) } else { /* decrement user count and add new datablock */ - bGPdata *gpd= (*gpd_ptr); + bGPdata *gpd = (*gpd_ptr); id_us_min(&gpd->id); - *gpd_ptr= gpencil_data_addnew("GPencil"); + *gpd_ptr = gpencil_data_addnew("GPencil"); } /* notifiers */ - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX need a nicer one that will work + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX need a nicer one that will work return OPERATOR_FINISHED; } @@ -216,7 +216,7 @@ void GPENCIL_OT_data_add(wmOperatorType *ot) ot->name = "Grease Pencil Add New"; ot->idname = "GPENCIL_OT_data_add"; ot->description = "Add new Grease Pencil datablock"; - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* callbacks */ ot->exec = gp_data_add_exec; @@ -226,9 +226,9 @@ void GPENCIL_OT_data_add(wmOperatorType *ot) /* ******************* Unlink Data ************************ */ /* poll callback for adding data/layers - special */ -static int gp_data_unlink_poll (bContext *C) +static int gp_data_unlink_poll(bContext *C) { - bGPdata **gpd_ptr= gpencil_data_get_pointers(C, NULL); + bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL); /* if we have access to some active data, make sure there's a datablock before enabling this */ return (gpd_ptr && *gpd_ptr); @@ -236,9 +236,9 @@ static int gp_data_unlink_poll (bContext *C) /* unlink datablock - wrapper around API */ -static int gp_data_unlink_exec (bContext *C, wmOperator *op) +static int gp_data_unlink_exec(bContext *C, wmOperator *op) { - bGPdata **gpd_ptr= gpencil_data_get_pointers(C, NULL); + bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL); if (gpd_ptr == NULL) { BKE_report(op->reports, RPT_ERROR, "Nowhere for Grease Pencil data to go"); @@ -246,14 +246,14 @@ static int gp_data_unlink_exec (bContext *C, wmOperator *op) } else { /* just unlink datablock now, decreasing its user count */ - bGPdata *gpd= (*gpd_ptr); + bGPdata *gpd = (*gpd_ptr); id_us_min(&gpd->id); - *gpd_ptr= NULL; + *gpd_ptr = NULL; } /* notifiers */ - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX need a nicer one that will work + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX need a nicer one that will work return OPERATOR_FINISHED; } @@ -264,7 +264,7 @@ void GPENCIL_OT_data_unlink(wmOperatorType *ot) ot->name = "Grease Pencil Unlink"; ot->idname = "GPENCIL_OT_data_unlink"; ot->description = "Unlink active Grease Pencil datablock"; - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* callbacks */ ot->exec = gp_data_unlink_exec; @@ -274,9 +274,9 @@ void GPENCIL_OT_data_unlink(wmOperatorType *ot) /* ******************* Add New Layer ************************ */ /* add new layer - wrapper around API */ -static int gp_layer_add_exec (bContext *C, wmOperator *op) +static int gp_layer_add_exec(bContext *C, wmOperator *op) { - bGPdata **gpd_ptr= gpencil_data_get_pointers(C, NULL); + bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL); /* if there's no existing Grease-Pencil data there, add some */ if (gpd_ptr == NULL) { @@ -284,13 +284,13 @@ static int gp_layer_add_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } if (*gpd_ptr == NULL) - *gpd_ptr= gpencil_data_addnew("GPencil"); + *gpd_ptr = gpencil_data_addnew("GPencil"); /* add new layer now */ gpencil_layer_addnew(*gpd_ptr); /* notifiers */ - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX please work! + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX please work! return OPERATOR_FINISHED; } @@ -301,7 +301,7 @@ void GPENCIL_OT_layer_add(wmOperatorType *ot) ot->name = "Add New Layer"; ot->idname = "GPENCIL_OT_layer_add"; ot->description = "Add new Grease Pencil layer for the active Grease Pencil datablock"; - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* callbacks */ ot->exec = gp_layer_add_exec; @@ -310,22 +310,22 @@ void GPENCIL_OT_layer_add(wmOperatorType *ot) /* ******************* Delete Active Frame ************************ */ -static int gp_actframe_delete_poll (bContext *C) +static int gp_actframe_delete_poll(bContext *C) { - bGPdata *gpd= gpencil_data_get_active(C); - bGPDlayer *gpl= gpencil_layer_getactive(gpd); + bGPdata *gpd = gpencil_data_get_active(C); + bGPDlayer *gpl = gpencil_layer_getactive(gpd); /* only if there's an active layer with an active frame */ return (gpl && gpl->actframe); } /* delete active frame - wrapper around API calls */ -static int gp_actframe_delete_exec (bContext *C, wmOperator *op) +static int gp_actframe_delete_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - bGPdata *gpd= gpencil_data_get_active(C); - bGPDlayer *gpl= gpencil_layer_getactive(gpd); - bGPDframe *gpf= gpencil_layer_getframe(gpl, CFRA, 0); + Scene *scene = CTX_data_scene(C); + bGPdata *gpd = gpencil_data_get_active(C); + bGPDlayer *gpl = gpencil_layer_getactive(gpd); + bGPDframe *gpf = gpencil_layer_getframe(gpl, CFRA, 0); /* if there's no existing Grease-Pencil data there, add some */ if (gpd == NULL) { @@ -341,7 +341,7 @@ static int gp_actframe_delete_exec (bContext *C, wmOperator *op) gpencil_layer_delframe(gpl, gpf); /* notifiers */ - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX please work! + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX please work! return OPERATOR_FINISHED; } @@ -352,7 +352,7 @@ void GPENCIL_OT_active_frame_delete(wmOperatorType *ot) ot->name = "Delete Active Frame"; ot->idname = "GPENCIL_OT_active_frame_delete"; ot->description = "Delete the active frame for the active Grease Pencil datablock"; - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* callbacks */ ot->exec = gp_actframe_delete_exec; @@ -380,35 +380,35 @@ static EnumPropertyItem prop_gpencil_convertmodes[] = { /* convert the coordinates from the given stroke point into 3d-coordinates * - assumes that the active space is the 3D-View */ -static void gp_strokepoint_convertcoords (bContext *C, bGPDstroke *gps, bGPDspoint *pt, float p3d[3], rctf *subrect) +static void gp_strokepoint_convertcoords(bContext *C, bGPDstroke *gps, bGPDspoint *pt, float p3d[3], rctf *subrect) { - Scene *scene= CTX_data_scene(C); - View3D *v3d= CTX_wm_view3d(C); - ARegion *ar= CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); + ARegion *ar = CTX_wm_region(C); if (gps->flag & GP_STROKE_3DSPACE) { /* directly use 3d-coordinates */ copy_v3_v3(p3d, &pt->x); } else { - float *fp= give_cursor(scene, v3d); + float *fp = give_cursor(scene, v3d); float mvalf[2]; /* get screen coordinate */ if (gps->flag & GP_STROKE_2DSPACE) { int mvali[2]; - View2D *v2d= &ar->v2d; - UI_view2d_view_to_region(v2d, pt->x, pt->y, mvali, mvali+1); + View2D *v2d = &ar->v2d; + UI_view2d_view_to_region(v2d, pt->x, pt->y, mvali, mvali + 1); VECCOPY2D(mvalf, mvali); } else { if (subrect) { - mvalf[0]= (((float)pt->x/100.0f) * (subrect->xmax - subrect->xmin)) + subrect->xmin; - mvalf[1]= (((float)pt->y/100.0f) * (subrect->ymax - subrect->ymin)) + subrect->ymin; + mvalf[0] = (((float)pt->x / 100.0f) * (subrect->xmax - subrect->xmin)) + subrect->xmin; + mvalf[1] = (((float)pt->y / 100.0f) * (subrect->ymax - subrect->ymin)) + subrect->ymin; } else { - mvalf[0]= (float)pt->x / 100.0f * ar->winx; - mvalf[1]= (float)pt->y / 100.0f * ar->winy; + mvalf[0] = (float)pt->x / 100.0f * ar->winx; + mvalf[1] = (float)pt->y / 100.0f * ar->winy; } } @@ -422,7 +422,7 @@ static void gp_strokepoint_convertcoords (bContext *C, bGPDstroke *gps, bGPDspoi /* --- */ /* convert stroke to 3d path */ -static void gp_stroke_to_path (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curve *cu, rctf *subrect) +static void gp_stroke_to_path(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curve *cu, rctf *subrect) { bGPDspoint *pt; Nurb *nu; @@ -432,16 +432,16 @@ static void gp_stroke_to_path (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cur /* create new 'nurb' within the curve */ nu = (Nurb *)MEM_callocN(sizeof(Nurb), "gpstroke_to_path(nurb)"); - nu->pntsu= gps->totpoints; - nu->pntsv= 1; - nu->orderu= gps->totpoints; - nu->flagu= CU_NURB_ENDPOINT; - nu->resolu= 32; + nu->pntsu = gps->totpoints; + nu->pntsv = 1; + nu->orderu = gps->totpoints; + nu->flagu = CU_NURB_ENDPOINT; + nu->resolu = 32; - nu->bp= (BPoint *)MEM_callocN(sizeof(BPoint)*gps->totpoints, "bpoints"); + nu->bp = (BPoint *)MEM_callocN(sizeof(BPoint) * gps->totpoints, "bpoints"); /* add points */ - for (i=0, pt=gps->points, bp=nu->bp; i < gps->totpoints; i++, pt++, bp++) { + for (i = 0, pt = gps->points, bp = nu->bp; i < gps->totpoints; i++, pt++, bp++) { float p3d[3]; /* get coordinates to add at */ @@ -449,7 +449,7 @@ static void gp_stroke_to_path (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cur copy_v3_v3(bp->vec, p3d); /* set settings */ - bp->f1= SELECT; + bp->f1 = SELECT; bp->radius = bp->weight = pt->pressure * gpl->thickness; } @@ -459,15 +459,15 @@ static void gp_stroke_to_path (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cur static int gp_camera_view_subrect(bContext *C, rctf *subrect) { - View3D *v3d= CTX_wm_view3d(C); - ARegion *ar= CTX_wm_region(C); + View3D *v3d = CTX_wm_view3d(C); + ARegion *ar = CTX_wm_region(C); if (v3d) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, subrect, TRUE); /* no shift */ return 1; } @@ -477,7 +477,7 @@ static int gp_camera_view_subrect(bContext *C, rctf *subrect) } /* convert stroke to 3d bezier */ -static void gp_stroke_to_bezier (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curve *cu, rctf *subrect) +static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curve *cu, rctf *subrect) { bGPDspoint *pt; Nurb *nu; @@ -488,31 +488,31 @@ static void gp_stroke_to_bezier (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, C /* create new 'nurb' within the curve */ nu = (Nurb *)MEM_callocN(sizeof(Nurb), "gpstroke_to_bezier(nurb)"); - nu->pntsu= gps->totpoints; - nu->resolu= 12; - nu->resolv= 12; - nu->type= CU_BEZIER; - nu->bezt = (BezTriple *)MEM_callocN(gps->totpoints*sizeof(BezTriple), "bezts"); + nu->pntsu = gps->totpoints; + nu->resolu = 12; + nu->resolv = 12; + nu->type = CU_BEZIER; + nu->bezt = (BezTriple *)MEM_callocN(gps->totpoints * sizeof(BezTriple), "bezts"); - tot= gps->totpoints; + tot = gps->totpoints; /* get initial coordinates */ - pt=gps->points; + pt = gps->points; if (tot) { gp_strokepoint_convertcoords(C, gps, pt, p3d_cur, subrect); if (tot > 1) { - gp_strokepoint_convertcoords(C, gps, pt+1, p3d_next, subrect); + gp_strokepoint_convertcoords(C, gps, pt + 1, p3d_next, subrect); } } /* add points */ - for (i=0, bezt=nu->bezt; i < tot; i++, pt++, bezt++) { + for (i = 0, bezt = nu->bezt; i < tot; i++, pt++, bezt++) { float h1[3], h2[3]; if (i) interp_v3_v3v3(h1, p3d_cur, p3d_prev, 0.3); else interp_v3_v3v3(h1, p3d_cur, p3d_next, -0.3); - if (i < tot-1) interp_v3_v3v3(h2, p3d_cur, p3d_next, 0.3); + if (i < tot - 1) interp_v3_v3v3(h2, p3d_cur, p3d_next, 0.3); else interp_v3_v3v3(h2, p3d_cur, p3d_prev, -0.3); copy_v3_v3(bezt->vec[0], h1); @@ -520,8 +520,8 @@ static void gp_stroke_to_bezier (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, C copy_v3_v3(bezt->vec[2], h2); /* set settings */ - bezt->h1= bezt->h2= HD_FREE; - bezt->f1= bezt->f2= bezt->f3= SELECT; + bezt->h1 = bezt->h2 = HD_FREE; + bezt->f1 = bezt->f2 = bezt->f3 = SELECT; bezt->radius = bezt->weight = pt->pressure * gpl->thickness * 0.1f; /* shift coord vects */ @@ -541,16 +541,16 @@ static void gp_stroke_to_bezier (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, C } /* convert a given grease-pencil layer to a 3d-curve representation (using current view if appropriate) */ -static void gp_layer_to_curve (bContext *C, bGPdata *gpd, bGPDlayer *gpl, short mode) +static void gp_layer_to_curve(bContext *C, bGPdata *gpd, bGPDlayer *gpl, short mode) { - Scene *scene= CTX_data_scene(C); - bGPDframe *gpf= gpencil_layer_getframe(gpl, CFRA, 0); + Scene *scene = CTX_data_scene(C); + bGPDframe *gpf = gpencil_layer_getframe(gpl, CFRA, 0); bGPDstroke *gps; Object *ob; Curve *cu; /* camera framing */ - rctf subrect, *subrect_ptr= NULL; + rctf subrect, *subrect_ptr = NULL; /* error checking */ if (ELEM3(NULL, gpd, gpl, gpf)) @@ -562,16 +562,16 @@ static void gp_layer_to_curve (bContext *C, bGPdata *gpd, bGPDlayer *gpl, short /* initialize camera framing */ if (gp_camera_view_subrect(C, &subrect)) { - subrect_ptr= &subrect; + subrect_ptr = &subrect; } /* init the curve object (remove rotation and get curve data from it) * - must clear transforms set on object, as those skew our results */ - ob= BKE_object_add(scene, OB_CURVE); + ob = BKE_object_add(scene, OB_CURVE); zero_v3(ob->loc); zero_v3(ob->rot); - cu= ob->data; + cu = ob->data; cu->flag |= CU_3D; /* rename object and curve to layer name */ @@ -579,7 +579,7 @@ static void gp_layer_to_curve (bContext *C, bGPdata *gpd, bGPDlayer *gpl, short rename_id((ID *)cu, gpl->info); /* add points to curve */ - for (gps= gpf->strokes.first; gps; gps= gps->next) { + for (gps = gpf->strokes.first; gps; gps = gps->next) { switch (mode) { case GP_STROKECONVERT_PATH: gp_stroke_to_path(C, gpl, gps, cu, subrect_ptr); @@ -596,22 +596,22 @@ static void gp_layer_to_curve (bContext *C, bGPdata *gpd, bGPDlayer *gpl, short /* --- */ -static int gp_convert_poll (bContext *C) +static int gp_convert_poll(bContext *C) { - bGPdata *gpd= gpencil_data_get_active(C); - ScrArea *sa= CTX_wm_area(C); - Scene *scene= CTX_data_scene(C); + bGPdata *gpd = gpencil_data_get_active(C); + ScrArea *sa = CTX_wm_area(C); + Scene *scene = CTX_data_scene(C); /* only if there's valid data, and the current view is 3D View */ return ((sa && sa->spacetype == SPACE_VIEW3D) && gpencil_layer_getactive(gpd) && (scene->obedit == NULL)); } -static int gp_convert_layer_exec (bContext *C, wmOperator *op) +static int gp_convert_layer_exec(bContext *C, wmOperator *op) { - bGPdata *gpd= gpencil_data_get_active(C); - bGPDlayer *gpl= gpencil_layer_getactive(gpd); - Scene *scene= CTX_data_scene(C); - int mode= RNA_enum_get(op->ptr, "type"); + bGPdata *gpd = gpencil_data_get_active(C); + bGPDlayer *gpl = gpencil_layer_getactive(gpd); + Scene *scene = CTX_data_scene(C); + int mode = RNA_enum_get(op->ptr, "type"); /* check if there's data to work with */ if (gpd == NULL) { @@ -622,8 +622,8 @@ static int gp_convert_layer_exec (bContext *C, wmOperator *op) gp_layer_to_curve(C, gpd, gpl, mode); /* notifiers */ - WM_event_add_notifier(C, NC_OBJECT|NA_ADDED, NULL); - WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); + WM_event_add_notifier(C, NC_OBJECT | NA_ADDED, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); /* done */ return OPERATOR_FINISHED; @@ -635,7 +635,7 @@ void GPENCIL_OT_convert(wmOperatorType *ot) ot->name = "Convert Grease Pencil"; ot->idname = "GPENCIL_OT_convert"; ot->description = "Convert the active Grease Pencil layer to a new Object"; - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* callbacks */ ot->invoke = WM_menu_invoke; @@ -643,7 +643,7 @@ void GPENCIL_OT_convert(wmOperatorType *ot) ot->poll = gp_convert_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", prop_gpencil_convertmodes, 0, "Type", ""); diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h index b88723d8a3c..28eb1355caf 100644 --- a/source/blender/editors/gpencil/gpencil_intern.h +++ b/source/blender/editors/gpencil/gpencil_intern.h @@ -77,18 +77,18 @@ void gpencil_undo_finish(void); typedef struct bActListElem { struct bActListElem *next, *prev; - void *data; /* source data this elem represents */ - int type; /* one of the ACTTYPE_* values */ - int flag; /* copy of elem's flags for quick access */ - int index; /* copy of adrcode where applicable */ + void *data; /* source data this elem represents */ + int type; /* one of the ACTTYPE_* values */ + int flag; /* copy of elem's flags for quick access */ + int index; /* copy of adrcode where applicable */ - void *key_data; /* motion data - ipo or ipo-curve */ - short datatype; /* type of motion data to expect */ + void *key_data; /* motion data - ipo or ipo-curve */ + short datatype; /* type of motion data to expect */ - struct bActionGroup *grp; /* action group that owns the channel */ + struct bActionGroup *grp; /* action group that owns the channel */ - void *owner; /* will either be an action channel or fake ipo-channel (for keys) */ - short ownertype; /* type of owner */ + void *owner; /* will either be an action channel or fake ipo-channel (for keys) */ + short ownertype; /* type of owner */ } bActListElem; /******************************************************* */ @@ -96,14 +96,14 @@ typedef struct bActListElem { /* filtering flags - under what circumstances should a channel be added */ typedef enum ACTFILTER_FLAGS { - ACTFILTER_VISIBLE = (1<<0), /* should channels be visible */ - ACTFILTER_SEL = (1<<1), /* should channels be selected */ - ACTFILTER_FOREDIT = (1<<2), /* does editable status matter */ - ACTFILTER_CHANNELS = (1<<3), /* do we only care that it is a channel */ - ACTFILTER_IPOKEYS = (1<<4), /* only channels referencing ipo's */ - ACTFILTER_ONLYICU = (1<<5), /* only reference ipo-curves */ - ACTFILTER_FORDRAWING = (1<<6), /* make list for interface drawing */ - ACTFILTER_ACTGROUPED = (1<<7) /* belongs to the active group */ + ACTFILTER_VISIBLE = (1 << 0), /* should channels be visible */ + ACTFILTER_SEL = (1 << 1), /* should channels be selected */ + ACTFILTER_FOREDIT = (1 << 2), /* does editable status matter */ + ACTFILTER_CHANNELS = (1 << 3), /* do we only care that it is a channel */ + ACTFILTER_IPOKEYS = (1 << 4), /* only channels referencing ipo's */ + ACTFILTER_ONLYICU = (1 << 5), /* only reference ipo-curves */ + ACTFILTER_FORDRAWING = (1 << 6), /* make list for interface drawing */ + ACTFILTER_ACTGROUPED = (1 << 7) /* belongs to the active group */ } ACTFILTER_FLAGS; /* Action Editor - Main Data types */ diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c index baa6999f552..7055eb3ee1b 100644 --- a/source/blender/editors/gpencil/gpencil_ops.c +++ b/source/blender/editors/gpencil/gpencil_ops.c @@ -54,18 +54,22 @@ void ED_keymap_gpencil(wmKeyConfig *keyconf) wmKeyMapItem *kmi; /* Draw */ - /* draw */ - kmi=WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, KM_PRESS, 0, DKEY); - RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW); - /* draw - straight lines */ - kmi=WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, KM_PRESS, KM_CTRL, DKEY); - RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW_STRAIGHT); - /* draw - poly lines */ - kmi=WM_keymap_add_item(keymap, "GPENCIL_OT_draw", RIGHTMOUSE, KM_PRESS, KM_CTRL, DKEY); - RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW_POLY); - /* erase */ - kmi=WM_keymap_add_item(keymap, "GPENCIL_OT_draw", RIGHTMOUSE, KM_PRESS, 0, DKEY); - RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_ERASER); + + /* draw */ + kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, KM_PRESS, 0, DKEY); + RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW); + + /* draw - straight lines */ + kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, KM_PRESS, KM_CTRL, DKEY); + RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW_STRAIGHT); + + /* draw - poly lines */ + kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", RIGHTMOUSE, KM_PRESS, KM_CTRL, DKEY); + RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW_POLY); + + /* erase */ + kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", RIGHTMOUSE, KM_PRESS, 0, DKEY); + RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_ERASER); } /* ****************************************** */ diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 9f9d941f523..b79c510efce 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -71,38 +71,38 @@ typedef struct tGPsdata { Scene *scene; /* current scene from context */ - wmWindow *win; /* window where painting originated */ - ScrArea *sa; /* area where painting originated */ + wmWindow *win; /* window where painting originated */ + ScrArea *sa; /* area where painting originated */ ARegion *ar; /* region where painting originated */ - View2D *v2d; /* needed for GP_STROKE_2DSPACE */ - rctf *subrect; /* for using the camera rect within the 3d view */ + View2D *v2d; /* needed for GP_STROKE_2DSPACE */ + rctf *subrect; /* for using the camera rect within the 3d view */ rctf subrect_data; #if 0 // XXX review this 2d image stuff... - ImBuf *ibuf; /* needed for GP_STROKE_2DIMAGE */ + ImBuf *ibuf; /* needed for GP_STROKE_2DIMAGE */ struct IBufViewSettings { - int offsx, offsy; /* offsets */ - int sizex, sizey; /* dimensions to use as scale-factor */ - } im2d_settings; /* needed for GP_STROKE_2DIMAGE */ + int offsx, offsy; /* offsets */ + int sizex, sizey; /* dimensions to use as scale-factor */ + } im2d_settings; /* needed for GP_STROKE_2DIMAGE */ #endif - PointerRNA ownerPtr;/* pointer to owner of gp-datablock */ - bGPdata *gpd; /* gp-datablock layer comes from */ - bGPDlayer *gpl; /* layer we're working on */ - bGPDframe *gpf; /* frame we're working on */ + PointerRNA ownerPtr; /* pointer to owner of gp-datablock */ + bGPdata *gpd; /* gp-datablock layer comes from */ + bGPDlayer *gpl; /* layer we're working on */ + bGPDframe *gpf; /* frame we're working on */ + + short status; /* current status of painting */ + short paintmode; /* mode for painting */ - short status; /* current status of painting */ - short paintmode; /* mode for painting */ + int mval[2]; /* current mouse-position */ + int mvalo[2]; /* previous recorded mouse-position */ - int mval[2]; /* current mouse-position */ - int mvalo[2]; /* previous recorded mouse-position */ + float pressure; /* current stylus pressure */ + float opressure; /* previous stylus pressure */ - float pressure; /* current stylus pressure */ - float opressure; /* previous stylus pressure */ - - short radius; /* radius of influence for eraser */ - short flags; /* flags that can get set during runtime */ + short radius; /* radius of influence for eraser */ + short flags; /* flags that can get set during runtime */ float imat[4][4]; /* inverted transformation matrix applying when converting coords from screen-space * to region space */ @@ -112,36 +112,36 @@ typedef struct tGPsdata { /* values for tGPsdata->status */ enum { - GP_STATUS_IDLING = 0, /* stroke isn't in progress yet */ - GP_STATUS_PAINTING, /* a stroke is in progress */ - GP_STATUS_ERROR, /* something wasn't correctly set up */ - GP_STATUS_DONE /* painting done */ + GP_STATUS_IDLING = 0, /* stroke isn't in progress yet */ + GP_STATUS_PAINTING, /* a stroke is in progress */ + GP_STATUS_ERROR, /* something wasn't correctly set up */ + GP_STATUS_DONE /* painting done */ }; /* Return flags for adding points to stroke buffer */ enum { - GP_STROKEADD_INVALID = -2, /* error occurred - insufficient info to do so */ - GP_STROKEADD_OVERFLOW = -1, /* error occurred - cannot fit any more points */ - GP_STROKEADD_NORMAL, /* point was successfully added */ - GP_STROKEADD_FULL /* cannot add any more points to buffer */ + GP_STROKEADD_INVALID = -2, /* error occurred - insufficient info to do so */ + GP_STROKEADD_OVERFLOW = -1, /* error occurred - cannot fit any more points */ + GP_STROKEADD_NORMAL, /* point was successfully added */ + GP_STROKEADD_FULL /* cannot add any more points to buffer */ }; /* Runtime flags */ enum { - GP_PAINTFLAG_FIRSTRUN = (1<<0), /* operator just started */ - GP_PAINTFLAG_STROKEADDED = (1<<1) /* stroke was already added during draw session */ + GP_PAINTFLAG_FIRSTRUN = (1 << 0), /* operator just started */ + GP_PAINTFLAG_STROKEADDED = (1 << 1) /* stroke was already added during draw session */ }; /* ------ */ /* maximum sizes of gp-session buffer */ -#define GP_STROKE_BUFFER_MAX 5000 +#define GP_STROKE_BUFFER_MAX 5000 /* Macros for accessing sensitivity thresholds... */ - /* minimum number of pixels mouse should move before new point created */ -#define MIN_MANHATTEN_PX (U.gp_manhattendist) - /* minimum length of new segment before new point can be added */ -#define MIN_EUCLIDEAN_PX (U.gp_euclideandist) +/* minimum number of pixels mouse should move before new point created */ +#define MIN_MANHATTEN_PX (U.gp_manhattendist) +/* minimum length of new segment before new point can be added */ +#define MIN_EUCLIDEAN_PX (U.gp_euclideandist) /* ------ */ /* Forward defines for some functions... */ @@ -152,7 +152,7 @@ static void gp_session_validatebuffer(tGPsdata *p); /* Context Wrangling... */ /* check if context is suitable for drawing */ -static int gpencil_draw_poll (bContext *C) +static int gpencil_draw_poll(bContext *C) { if (ED_operator_regionactive(C)) { /* check if current context can support GPencil data */ @@ -175,9 +175,9 @@ static int gpencil_draw_poll (bContext *C) } /* check if projecting strokes into 3d-geometry in the 3D-View */ -static int gpencil_project_check (tGPsdata *p) +static int gpencil_project_check(tGPsdata *p) { - bGPdata *gpd= p->gpd; + bGPdata *gpd = p->gpd; return ((gpd->sbuffer_sflag & GP_STROKE_3DSPACE) && (p->gpd->flag & (GP_DATA_DEPTH_VIEW | GP_DATA_DEPTH_STROKE))); } @@ -187,18 +187,18 @@ static int gpencil_project_check (tGPsdata *p) /* Utilities --------------------------------- */ /* get the reference point for stroke-point conversions */ -static void gp_get_3d_reference (tGPsdata *p, float vec[3]) +static void gp_get_3d_reference(tGPsdata *p, float vec[3]) { - View3D *v3d= p->sa->spacedata.first; - float *fp= give_cursor(p->scene, v3d); + View3D *v3d = p->sa->spacedata.first; + float *fp = give_cursor(p->scene, v3d); /* the reference point used depends on the owner... */ #if 0 // XXX: disabled for now, since we can't draw relative to the owner yet if (p->ownerPtr.type == &RNA_Object) { - Object *ob= (Object *)p->ownerPtr.data; + Object *ob = (Object *)p->ownerPtr.data; /* active Object - * - use relative distance of 3D-cursor from object center + * - use relative distance of 3D-cursor from object center */ sub_v3_v3v3(vec, fp, ob->loc); } @@ -213,10 +213,10 @@ static void gp_get_3d_reference (tGPsdata *p, float vec[3]) /* Stroke Editing ---------------------------- */ /* check if the current mouse position is suitable for adding a new point */ -static short gp_stroke_filtermval (tGPsdata *p, const int mval[2], int pmval[2]) +static short gp_stroke_filtermval(tGPsdata *p, const int mval[2], int pmval[2]) { - int dx= abs(mval[0] - pmval[0]); - int dy= abs(mval[1] - pmval[1]); + int dx = abs(mval[0] - pmval[0]); + int dy = abs(mval[1] - pmval[1]); /* if buffer is empty, just let this go through (i.e. so that dots will work) */ if (p->gpd->sbuffer_size == 0) @@ -232,7 +232,7 @@ static short gp_stroke_filtermval (tGPsdata *p, const int mval[2], int pmval[2]) * - prevents points being added too densely * - distance here doesn't use sqrt to prevent slowness... we should still be safe from overflows though */ - else if ((dx*dx + dy*dy) > MIN_EUCLIDEAN_PX*MIN_EUCLIDEAN_PX) + else if ((dx * dx + dy * dy) > MIN_EUCLIDEAN_PX * MIN_EUCLIDEAN_PX) return 1; /* mouse 'didn't move' */ @@ -242,9 +242,9 @@ static short gp_stroke_filtermval (tGPsdata *p, const int mval[2], int pmval[2]) /* convert screen-coordinates to buffer-coordinates */ // XXX this method needs a total overhaul! -static void gp_stroke_convertcoords (tGPsdata *p, const int mval[2], float out[3], float *depth) +static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3], float *depth) { - bGPdata *gpd= p->gpd; + bGPdata *gpd = p->gpd; /* in 3d-space - pt->x/y/z are 3 side-by-side floats */ if (gpd->sbuffer_sflag & GP_STROKE_3DSPACE) { @@ -292,14 +292,14 @@ static void gp_stroke_convertcoords (tGPsdata *p, const int mval[2], float out[3 /* get stored settings * - assume that these have been set already (there are checks that set sane 'defaults' just in case) */ - sizex= p->im2d_settings.sizex; - sizey= p->im2d_settings.sizey; - offsx= p->im2d_settings.offsx; - offsy= p->im2d_settings.offsy; + sizex = p->im2d_settings.sizex; + sizey = p->im2d_settings.sizey; + offsx = p->im2d_settings.offsx; + offsy = p->im2d_settings.offsy; /* calculate new points */ - out[0]= (float)(mval[0] - offsx) / (float)sizex; - out[1]= (float)(mval[1] - offsy) / (float)sizey; + out[0] = (float)(mval[0] - offsx) / (float)sizex; + out[1] = (float)(mval[1] - offsy) / (float)sizey; } #endif @@ -310,16 +310,16 @@ static void gp_stroke_convertcoords (tGPsdata *p, const int mval[2], float out[3 out[1] = (float)(mval[1]) / (float)(p->ar->winy) * 100; } else { /* camera view, use subrect */ - out[0]= ((mval[0] - p->subrect->xmin) / ((p->subrect->xmax - p->subrect->xmin))) * 100; - out[1]= ((mval[1] - p->subrect->ymin) / ((p->subrect->ymax - p->subrect->ymin))) * 100; + out[0] = ((mval[0] - p->subrect->xmin) / ((p->subrect->xmax - p->subrect->xmin))) * 100; + out[1] = ((mval[1] - p->subrect->ymin) / ((p->subrect->ymax - p->subrect->ymin))) * 100; } } } /* add current stroke-point to buffer (returns whether point was successfully added) */ -static short gp_stroke_addpoint (tGPsdata *p, const int mval[2], float pressure) +static short gp_stroke_addpoint(tGPsdata *p, const int mval[2], float pressure) { - bGPdata *gpd= p->gpd; + bGPdata *gpd = p->gpd; tGPspoint *pt; /* check painting mode */ @@ -327,11 +327,11 @@ static short gp_stroke_addpoint (tGPsdata *p, const int mval[2], float pressure) /* straight lines only - i.e. only store start and end point in buffer */ if (gpd->sbuffer_size == 0) { /* first point in buffer (start point) */ - pt= (tGPspoint *)(gpd->sbuffer); + pt = (tGPspoint *)(gpd->sbuffer); /* store settings */ copy_v2_v2_int(&pt->x, mval); - pt->pressure= pressure; + pt->pressure = pressure; /* increment buffer size */ gpd->sbuffer_size++; @@ -340,18 +340,18 @@ static short gp_stroke_addpoint (tGPsdata *p, const int mval[2], float pressure) /* normally, we just reset the endpoint to the latest value * - assume that pointers for this are always valid... */ - pt= ((tGPspoint *)(gpd->sbuffer) + 1); + pt = ((tGPspoint *)(gpd->sbuffer) + 1); /* store settings */ copy_v2_v2_int(&pt->x, mval); - pt->pressure= pressure; + pt->pressure = pressure; /* if this is just the second point we've added, increment the buffer size * so that it will be drawn properly... * otherwise, just leave it alone, otherwise we get problems */ if (gpd->sbuffer_size != 2) - gpd->sbuffer_size= 2; + gpd->sbuffer_size = 2; } /* can keep carrying on this way :) */ @@ -363,11 +363,11 @@ static short gp_stroke_addpoint (tGPsdata *p, const int mval[2], float pressure) return GP_STROKEADD_OVERFLOW; /* get pointer to destination point */ - pt= ((tGPspoint *)(gpd->sbuffer) + gpd->sbuffer_size); + pt = ((tGPspoint *)(gpd->sbuffer) + gpd->sbuffer_size); /* store settings */ copy_v2_v2_int(&pt->x, mval); - pt->pressure= pressure; + pt->pressure = pressure; /* increment counters */ gpd->sbuffer_size++; @@ -380,43 +380,43 @@ static short gp_stroke_addpoint (tGPsdata *p, const int mval[2], float pressure) } else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) { /* get pointer to destination point */ - pt= (tGPspoint *)(gpd->sbuffer); + pt = (tGPspoint *)(gpd->sbuffer); /* store settings */ copy_v2_v2_int(&pt->x, mval); - pt->pressure= pressure; + pt->pressure = pressure; /* if there's stroke for this poly line session add (or replace last) point * to stroke. This allows to draw lines more interactively (see new segment * during mouse slide, i.e.) */ if (p->flags & GP_PAINTFLAG_STROKEADDED) { - bGPDstroke *gps= p->gpf->strokes.last; + bGPDstroke *gps = p->gpf->strokes.last; bGPDspoint *pts; /* first time point is adding to temporary buffer -- need to allocate new point in stroke */ if (gpd->sbuffer_size == 0) { - gps->points = MEM_reallocN(gps->points, sizeof(bGPDspoint)*(gps->totpoints+1)); + gps->points = MEM_reallocN(gps->points, sizeof(bGPDspoint) * (gps->totpoints + 1)); gps->totpoints++; } - pts = &gps->points[gps->totpoints-1]; + pts = &gps->points[gps->totpoints - 1]; /* special case for poly lines: normally, depth is needed only when creating new stroke from buffer, * but poly lines are converting to stroke instantly, so initialize depth buffer before converting coordinates */ if (gpencil_project_check(p)) { - View3D *v3d= p->sa->spacedata.first; + View3D *v3d = p->sa->spacedata.first; view3d_region_operator_needs_opengl(p->win, p->ar); - ED_view3d_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1:0); + ED_view3d_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1 : 0); } /* convert screen-coordinates to appropriate coordinates (and store them) */ gp_stroke_convertcoords(p, &pt->x, &pts->x, NULL); /* copy pressure */ - pts->pressure= pt->pressure; + pts->pressure = pt->pressure; } /* increment counters */ @@ -438,11 +438,11 @@ typedef struct tGpSmoothCo { } tGpSmoothCo; /* smooth a stroke (in buffer) before storing it */ -static void gp_stroke_smooth (tGPsdata *p) +static void gp_stroke_smooth(tGPsdata *p) { - bGPdata *gpd= p->gpd; + bGPdata *gpd = p->gpd; tGpSmoothCo *smoothArray, *spc; - int i=0, cmx=gpd->sbuffer_size; + int i = 0, cmx = gpd->sbuffer_size; /* only smooth if smoothing is enabled, and we're not doing a straight line */ if (!(U.gp_settings & GP_PAINT_DOSMOOTH) || ELEM(p->paintmode, GP_PAINTMODE_DRAW_STRAIGHT, GP_PAINTMODE_DRAW_POLY)) @@ -453,23 +453,23 @@ static void gp_stroke_smooth (tGPsdata *p) return; /* create a temporary smoothing coordinates buffer, use to store calculated values to prevent sequential error */ - smoothArray = MEM_callocN(sizeof(tGpSmoothCo)*cmx, "gp_stroke_smooth smoothArray"); + smoothArray = MEM_callocN(sizeof(tGpSmoothCo) * cmx, "gp_stroke_smooth smoothArray"); /* first pass: calculate smoothing coordinates using weighted-averages */ - for (i=0, spc=smoothArray; i < gpd->sbuffer_size; i++, spc++) { - const tGPspoint *pc= (((tGPspoint *)gpd->sbuffer) + i); - const tGPspoint *pb= (i-1 > 0)?(pc-1):(pc); - const tGPspoint *pa= (i-2 > 0)?(pc-2):(pb); - const tGPspoint *pd= (i+1 < cmx)?(pc+1):(pc); - const tGPspoint *pe= (i+2 < cmx)?(pc+2):(pd); + for (i = 0, spc = smoothArray; i < gpd->sbuffer_size; i++, spc++) { + const tGPspoint *pc = (((tGPspoint *)gpd->sbuffer) + i); + const tGPspoint *pb = (i - 1 > 0) ? (pc - 1) : (pc); + const tGPspoint *pa = (i - 2 > 0) ? (pc - 2) : (pb); + const tGPspoint *pd = (i + 1 < cmx) ? (pc + 1) : (pc); + const tGPspoint *pe = (i + 2 < cmx) ? (pc + 2) : (pd); - spc->x= (int)(0.1*pa->x + 0.2*pb->x + 0.4*pc->x + 0.2*pd->x + 0.1*pe->x); - spc->y= (int)(0.1*pa->y + 0.2*pb->y + 0.4*pc->y + 0.2*pd->y + 0.1*pe->y); + spc->x = (int)(0.1 * pa->x + 0.2 * pb->x + 0.4 * pc->x + 0.2 * pd->x + 0.1 * pe->x); + spc->y = (int)(0.1 * pa->y + 0.2 * pb->y + 0.4 * pc->y + 0.2 * pd->y + 0.1 * pe->y); } /* second pass: apply smoothed coordinates */ - for (i=0, spc=smoothArray; i < gpd->sbuffer_size; i++, spc++) { - tGPspoint *pc= (((tGPspoint *)gpd->sbuffer) + i); + for (i = 0, spc = smoothArray; i < gpd->sbuffer_size; i++, spc++) { + tGPspoint *pc = (((tGPspoint *)gpd->sbuffer) + i); copy_v2_v2_int(&pc->x, &spc->x); } @@ -482,12 +482,12 @@ static void gp_stroke_smooth (tGPsdata *p) * - applies a reverse Chaikin filter * - code adapted from etch-a-ton branch (editarmature_sketch.c) */ -static void gp_stroke_simplify (tGPsdata *p) +static void gp_stroke_simplify(tGPsdata *p) { - bGPdata *gpd= p->gpd; - tGPspoint *old_points= (tGPspoint *)gpd->sbuffer; - short num_points= gpd->sbuffer_size; - short flag= gpd->sbuffer_sflag; + bGPdata *gpd = p->gpd; + tGPspoint *old_points = (tGPspoint *)gpd->sbuffer; + short num_points = gpd->sbuffer_size; + short flag = gpd->sbuffer_sflag; short i, j; /* only simplify if simplification is enabled, and we're not doing a straight line */ @@ -502,7 +502,7 @@ static void gp_stroke_simplify (tGPsdata *p) * - firstly set sbuffer to NULL, so a new one is allocated * - secondly, reset flag after, as it gets cleared auto */ - gpd->sbuffer= NULL; + gpd->sbuffer = NULL; gp_session_validatebuffer(p); gpd->sbuffer_sflag = flag; @@ -522,19 +522,19 @@ static void gp_stroke_simplify (tGPsdata *p) int mco[2]; /* initialize values */ - co[0]= 0; - co[1]= 0; + co[0] = 0; + co[1] = 0; pressure = 0; /* using macro, calculate new point */ GP_SIMPLIFY_AVPOINT(j, -0.25f); - GP_SIMPLIFY_AVPOINT(j+1, 0.75f); - GP_SIMPLIFY_AVPOINT(j+2, 0.75f); - GP_SIMPLIFY_AVPOINT(j+3, -0.25f); + GP_SIMPLIFY_AVPOINT(j + 1, 0.75f); + GP_SIMPLIFY_AVPOINT(j + 2, 0.75f); + GP_SIMPLIFY_AVPOINT(j + 3, -0.25f); /* set values for adding */ - mco[0]= (int)co[0]; - mco[1]= (int)co[1]; + mco[0] = (int)co[0]; + mco[1] = (int)co[1]; /* ignore return values on this... assume to be ok for now */ gp_stroke_addpoint(p, mco, pressure); @@ -549,9 +549,9 @@ static void gp_stroke_simplify (tGPsdata *p) /* make a new stroke from the buffer data */ -static void gp_stroke_newfrombuffer (tGPsdata *p) +static void gp_stroke_newfrombuffer(tGPsdata *p) { - bGPdata *gpd= p->gpd; + bGPdata *gpd = p->gpd; bGPDstroke *gps; bGPDspoint *pt; tGPspoint *ptc; @@ -563,7 +563,7 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) * - drawing straight-lines only requires the endpoints */ if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) - totelem = (gpd->sbuffer_size >= 2) ? 2: gpd->sbuffer_size; + totelem = (gpd->sbuffer_size >= 2) ? 2 : gpd->sbuffer_size; else totelem = gpd->sbuffer_size; @@ -583,77 +583,77 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) } /* allocate memory for a new stroke */ - gps= MEM_callocN(sizeof(bGPDstroke), "gp_stroke"); + gps = MEM_callocN(sizeof(bGPDstroke), "gp_stroke"); /* copy appropriate settings for stroke */ - gps->totpoints= totelem; - gps->thickness= p->gpl->thickness; - gps->flag= gpd->sbuffer_sflag; + gps->totpoints = totelem; + gps->thickness = p->gpl->thickness; + gps->flag = gpd->sbuffer_sflag; /* allocate enough memory for a continuous array for storage points */ - gps->points= MEM_callocN(sizeof(bGPDspoint)*gps->totpoints, "gp_stroke_points"); + gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); /* set pointer to first non-initialized point */ - pt= gps->points + (gps->totpoints - totelem); + pt = gps->points + (gps->totpoints - totelem); /* copy points from the buffer to the stroke */ if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) { /* straight lines only -> only endpoints */ { /* first point */ - ptc= gpd->sbuffer; + ptc = gpd->sbuffer; /* convert screen-coordinates to appropriate coordinates (and store them) */ gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL); /* copy pressure */ - pt->pressure= ptc->pressure; + pt->pressure = ptc->pressure; pt++; } if (totelem == 2) { /* last point if applicable */ - ptc= ((tGPspoint *)gpd->sbuffer) + (gpd->sbuffer_size - 1); + ptc = ((tGPspoint *)gpd->sbuffer) + (gpd->sbuffer_size - 1); /* convert screen-coordinates to appropriate coordinates (and store them) */ gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL); /* copy pressure */ - pt->pressure= ptc->pressure; + pt->pressure = ptc->pressure; } } else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) { /* first point */ - ptc= gpd->sbuffer; + ptc = gpd->sbuffer; /* convert screen-coordinates to appropriate coordinates (and store them) */ gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL); /* copy pressure */ - pt->pressure= ptc->pressure; + pt->pressure = ptc->pressure; } else { - float *depth_arr= NULL; + float *depth_arr = NULL; /* get an array of depths, far depths are blended */ if (gpencil_project_check(p)) { - int mval[2], mval_prev[2]= {0}; + int mval[2], mval_prev[2] = {0}; int interp_depth = 0; int found_depth = 0; - depth_arr= MEM_mallocN(sizeof(float) * gpd->sbuffer_size, "depth_points"); + depth_arr = MEM_mallocN(sizeof(float) * gpd->sbuffer_size, "depth_points"); - for (i=0, ptc=gpd->sbuffer; i < gpd->sbuffer_size; i++, ptc++, pt++) { + for (i = 0, ptc = gpd->sbuffer; i < gpd->sbuffer_size; i++, ptc++, pt++) { copy_v2_v2_int(mval, &ptc->x); - if ((ED_view3d_autodist_depth(p->ar, mval, depth_margin, depth_arr+i) == 0) && - (i && (ED_view3d_autodist_depth_seg(p->ar, mval, mval_prev, depth_margin + 1, depth_arr+i) == 0)) - ) { - interp_depth= TRUE; + if ((ED_view3d_autodist_depth(p->ar, mval, depth_margin, depth_arr + i) == 0) && + (i && (ED_view3d_autodist_depth_seg(p->ar, mval, mval_prev, depth_margin + 1, depth_arr + i) == 0))) + { + interp_depth = TRUE; } else { - found_depth= TRUE; + found_depth = TRUE; } copy_v2_v2_int(mval_prev, mval); @@ -661,7 +661,7 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) if (found_depth == FALSE) { /* eeh... not much we can do.. :/, ignore depth in this case, use the 3D cursor */ - for (i=gpd->sbuffer_size-1; i >= 0; i--) + for (i = gpd->sbuffer_size - 1; i >= 0; i--) depth_arr[i] = 0.9999f; } else { @@ -670,23 +670,23 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) int first_valid = 0; int last_valid = 0; - for (i=0; i < gpd->sbuffer_size; i++) { + for (i = 0; i < gpd->sbuffer_size; i++) { if (depth_arr[i] != FLT_MAX) break; } - first_valid= i; + first_valid = i; - for (i=gpd->sbuffer_size-1; i >= 0; i--) { + for (i = gpd->sbuffer_size - 1; i >= 0; i--) { if (depth_arr[i] != FLT_MAX) break; } - last_valid= i; + last_valid = i; /* invalidate non-endpoints, so only blend between first and last */ - for (i=first_valid+1; i < last_valid; i++) - depth_arr[i]= FLT_MAX; + for (i = first_valid + 1; i < last_valid; i++) + depth_arr[i] = FLT_MAX; - interp_depth= TRUE; + interp_depth = TRUE; } if (interp_depth) { @@ -696,15 +696,15 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) } - pt= gps->points; + pt = gps->points; /* convert all points (normal behavior) */ - for (i=0, ptc=gpd->sbuffer; i < gpd->sbuffer_size && ptc; i++, ptc++, pt++) { + for (i = 0, ptc = gpd->sbuffer; i < gpd->sbuffer_size && ptc; i++, ptc++, pt++) { /* convert screen-coordinates to appropriate coordinates (and store them) */ - gp_stroke_convertcoords(p, &ptc->x, &pt->x, depth_arr ? depth_arr+i:NULL); + gp_stroke_convertcoords(p, &ptc->x, &pt->x, depth_arr ? depth_arr + i : NULL); /* copy pressure */ - pt->pressure= ptc->pressure; + pt->pressure = ptc->pressure; } if (depth_arr) @@ -720,9 +720,9 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) /* --- 'Eraser' for 'Paint' Tool ------ */ /* eraser tool - remove segment from stroke/split stroke (after lasso inside) */ -static short gp_stroke_eraser_splitdel (bGPDframe *gpf, bGPDstroke *gps, int i) +static short gp_stroke_eraser_splitdel(bGPDframe *gpf, bGPDstroke *gps, int i) { - bGPDspoint *pt_tmp= gps->points; + bGPDspoint *pt_tmp = gps->points; bGPDstroke *gsn = NULL; /* if stroke only had two points, get rid of stroke */ @@ -739,8 +739,8 @@ static short gp_stroke_eraser_splitdel (bGPDframe *gpf, bGPDstroke *gps, int i) else if (i == gps->totpoints - 2) { /* allocate new points array, and assign most of the old stroke there */ gps->totpoints--; - gps->points= MEM_callocN(sizeof(bGPDspoint)*gps->totpoints, "gp_stroke_points"); - memcpy(gps->points, pt_tmp, sizeof(bGPDspoint)*gps->totpoints); + gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); + memcpy(gps->points, pt_tmp, sizeof(bGPDspoint) * gps->totpoints); /* free temp buffer */ MEM_freeN(pt_tmp); @@ -753,8 +753,8 @@ static short gp_stroke_eraser_splitdel (bGPDframe *gpf, bGPDstroke *gps, int i) else if (i == 0) { /* allocate new points array, and assign most of the old stroke there */ gps->totpoints--; - gps->points= MEM_callocN(sizeof(bGPDspoint)*gps->totpoints, "gp_stroke_points"); - memcpy(gps->points, pt_tmp + 1, sizeof(bGPDspoint)*gps->totpoints); + gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); + memcpy(gps->points, pt_tmp + 1, sizeof(bGPDspoint) * gps->totpoints); /* free temp buffer */ MEM_freeN(pt_tmp); @@ -766,18 +766,18 @@ static short gp_stroke_eraser_splitdel (bGPDframe *gpf, bGPDstroke *gps, int i) /* segment occurs in 'middle' of stroke, so split */ else { /* duplicate stroke, and assign 'later' data to that stroke */ - gsn= MEM_dupallocN(gps); - gsn->prev= gsn->next= NULL; + gsn = MEM_dupallocN(gps); + gsn->prev = gsn->next = NULL; BLI_insertlinkafter(&gpf->strokes, gps, gsn); - gsn->totpoints= gps->totpoints - i; - gsn->points= MEM_callocN(sizeof(bGPDspoint)*gsn->totpoints, "gp_stroke_points"); - memcpy(gsn->points, pt_tmp + i, sizeof(bGPDspoint)*gsn->totpoints); + gsn->totpoints = gps->totpoints - i; + gsn->points = MEM_callocN(sizeof(bGPDspoint) * gsn->totpoints, "gp_stroke_points"); + memcpy(gsn->points, pt_tmp + i, sizeof(bGPDspoint) * gsn->totpoints); /* adjust existing stroke */ - gps->totpoints= i; - gps->points= MEM_callocN(sizeof(bGPDspoint)*gps->totpoints, "gp_stroke_points"); - memcpy(gps->points, pt_tmp, sizeof(bGPDspoint)*i); + gps->totpoints = i; + gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); + memcpy(gps->points, pt_tmp, sizeof(bGPDspoint) * i); /* free temp buffer */ MEM_freeN(pt_tmp); @@ -788,7 +788,7 @@ static short gp_stroke_eraser_splitdel (bGPDframe *gpf, bGPDstroke *gps, int i) } /* eraser tool - check if part of stroke occurs within last segment drawn by eraser */ -static short gp_stroke_eraser_strokeinside (int mval[], int UNUSED(mvalo[]), short rad, short x0, short y0, short x1, short y1) +static short gp_stroke_eraser_strokeinside(int mval[], int UNUSED(mvalo[]), short rad, short x0, short y0, short x1, short y1) { /* simple within-radius check for now */ if (edge_inside_circle(mval[0], mval[1], rad, x0, y0, x1, y1)) @@ -800,10 +800,10 @@ static short gp_stroke_eraser_strokeinside (int mval[], int UNUSED(mvalo[]), sho /* eraser tool - evaluation per stroke */ // TODO: this could really do with some optimization (KD-Tree/BVH?) -static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], short rad, rcti *rect, bGPDframe *gpf, bGPDstroke *gps) +static void gp_stroke_eraser_dostroke(tGPsdata *p, int mval[], int mvalo[], short rad, rcti *rect, bGPDframe *gpf, bGPDstroke *gps) { bGPDspoint *pt1, *pt2; - int x0=0, y0=0, x1=0, y1=0; + int x0 = 0, y0 = 0, x1 = 0, y1 = 0; int xyval[2]; int i; @@ -817,8 +817,8 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho /* get coordinates */ if (gps->flag & GP_STROKE_3DSPACE) { project_int(p->ar, &gps->points->x, xyval); - x0= xyval[0]; - y0= xyval[1]; + x0 = xyval[0]; + y0 = xyval[1]; } else if (gps->flag & GP_STROKE_2DSPACE) { UI_view2d_view_to_region(p->v2d, gps->points->x, gps->points->y, &x0, &y0); @@ -828,31 +828,31 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho int offsx, offsy, sizex, sizey; /* get stored settings */ - sizex= p->im2d_settings.sizex; - sizey= p->im2d_settings.sizey; - offsx= p->im2d_settings.offsx; - offsy= p->im2d_settings.offsy; + sizex = p->im2d_settings.sizex; + sizey = p->im2d_settings.sizey; + offsx = p->im2d_settings.offsx; + offsy = p->im2d_settings.offsy; /* calculate new points */ - x0= (int)((gps->points->x * sizex) + offsx); - y0= (int)((gps->points->y * sizey) + offsy); + x0 = (int)((gps->points->x * sizex) + offsx); + y0 = (int)((gps->points->y * sizey) + offsy); } #endif else { if (p->subrect == NULL) { /* normal 3D view */ - x0= (int)(gps->points->x / 100 * p->ar->winx); - y0= (int)(gps->points->y / 100 * p->ar->winy); + x0 = (int)(gps->points->x / 100 * p->ar->winx); + y0 = (int)(gps->points->y / 100 * p->ar->winy); } else { /* camera view, use subrect */ - x0= (int)((gps->points->x / 100) * (p->subrect->xmax - p->subrect->xmin)) + p->subrect->xmin; - y0= (int)((gps->points->y / 100) * (p->subrect->ymax - p->subrect->ymin)) + p->subrect->ymin; + x0 = (int)((gps->points->x / 100) * (p->subrect->xmax - p->subrect->xmin)) + p->subrect->xmin; + y0 = (int)((gps->points->y / 100) * (p->subrect->ymax - p->subrect->ymin)) + p->subrect->ymin; } } /* do boundbox check first */ if (BLI_in_rcti(rect, x0, y0)) { /* only check if point is inside */ - if ( ((x0-mval[0])*(x0-mval[0]) + (y0-mval[1])*(y0-mval[1])) <= rad*rad ) { + if ( ((x0 - mval[0]) * (x0 - mval[0]) + (y0 - mval[1]) * (y0 - mval[1])) <= rad * rad) { /* free stroke */ MEM_freeN(gps->points); BLI_freelinkN(&gpf->strokes, gps); @@ -861,22 +861,22 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho } else { /* loop over the points in the stroke, checking for intersections - * - an intersection will require the stroke to be split + * - an intersection will require the stroke to be split */ - for (i=0; (i+1) < gps->totpoints; i++) { + for (i = 0; (i + 1) < gps->totpoints; i++) { /* get points to work with */ - pt1= gps->points + i; - pt2= gps->points + i + 1; + pt1 = gps->points + i; + pt2 = gps->points + i + 1; /* get coordinates */ if (gps->flag & GP_STROKE_3DSPACE) { project_int(p->ar, &pt1->x, xyval); - x0= xyval[0]; - y0= xyval[1]; + x0 = xyval[0]; + y0 = xyval[1]; project_int(p->ar, &pt2->x, xyval); - x1= xyval[0]; - y1= xyval[1]; + x1 = xyval[0]; + y1 = xyval[1]; } else if (gps->flag & GP_STROKE_2DSPACE) { UI_view2d_view_to_region(p->v2d, pt1->x, pt1->y, &x0, &y0); @@ -888,31 +888,31 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho int offsx, offsy, sizex, sizey; /* get stored settings */ - sizex= p->im2d_settings.sizex; - sizey= p->im2d_settings.sizey; - offsx= p->im2d_settings.offsx; - offsy= p->im2d_settings.offsy; + sizex = p->im2d_settings.sizex; + sizey = p->im2d_settings.sizey; + offsx = p->im2d_settings.offsx; + offsy = p->im2d_settings.offsy; /* calculate new points */ - x0= (int)((pt1->x * sizex) + offsx); - y0= (int)((pt1->y * sizey) + offsy); + x0 = (int)((pt1->x * sizex) + offsx); + y0 = (int)((pt1->y * sizey) + offsy); - x1= (int)((pt2->x * sizex) + offsx); - y1= (int)((pt2->y * sizey) + offsy); + x1 = (int)((pt2->x * sizex) + offsx); + y1 = (int)((pt2->y * sizey) + offsy); } #endif else { if (p->subrect == NULL) { /* normal 3D view */ - x0= (int)(pt1->x / 100 * p->ar->winx); - y0= (int)(pt1->y / 100 * p->ar->winy); - x1= (int)(pt2->x / 100 * p->ar->winx); - y1= (int)(pt2->y / 100 * p->ar->winy); + x0 = (int)(pt1->x / 100 * p->ar->winx); + y0 = (int)(pt1->y / 100 * p->ar->winy); + x1 = (int)(pt2->x / 100 * p->ar->winx); + y1 = (int)(pt2->y / 100 * p->ar->winy); } else { /* camera view, use subrect */ - x0= (int)((pt1->x / 100) * (p->subrect->xmax - p->subrect->xmin)) + p->subrect->xmin; - y0= (int)((pt1->y / 100) * (p->subrect->ymax - p->subrect->ymin)) + p->subrect->ymin; - x1= (int)((pt2->x / 100) * (p->subrect->xmax - p->subrect->xmin)) + p->subrect->xmin; - y1= (int)((pt2->y / 100) * (p->subrect->ymax - p->subrect->ymin)) + p->subrect->ymin; + x0 = (int)((pt1->x / 100) * (p->subrect->xmax - p->subrect->xmin)) + p->subrect->xmin; + y0 = (int)((pt1->y / 100) * (p->subrect->ymax - p->subrect->ymin)) + p->subrect->ymin; + x1 = (int)((pt2->x / 100) * (p->subrect->xmax - p->subrect->xmin)) + p->subrect->xmin; + y1 = (int)((pt2->y / 100) * (p->subrect->ymax - p->subrect->ymin)) + p->subrect->ymin; } } @@ -920,7 +920,7 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho if (BLI_in_rcti(rect, x0, y0) || BLI_in_rcti(rect, x1, y1)) { /* check if point segment of stroke had anything to do with * eraser region (either within stroke painted, or on its lines) - * - this assumes that linewidth is irrelevant + * - this assumes that linewidth is irrelevant */ if (gp_stroke_eraser_strokeinside(mval, mvalo, rad, x0, y0, x1, y1)) { /* if function returns true, break this loop (as no more point to check) */ @@ -933,9 +933,9 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho } /* erase strokes which fall under the eraser strokes */ -static void gp_stroke_doeraser (tGPsdata *p) +static void gp_stroke_doeraser(tGPsdata *p) { - bGPDframe *gpf= p->gpf; + bGPDframe *gpf = p->gpf; bGPDstroke *gps, *gpn; rcti rect; @@ -946,8 +946,8 @@ static void gp_stroke_doeraser (tGPsdata *p) rect.ymax = p->mval[1] + p->radius; /* loop over strokes, checking segments for intersections */ - for (gps= gpf->strokes.first; gps; gps= gpn) { - gpn= gps->next; + for (gps = gpf->strokes.first; gps; gps = gpn) { + gpn = gps->next; gp_stroke_eraser_dostroke(p, p->mval, p->mvalo, p->radius, &rect, gpf, gps); } } @@ -956,45 +956,45 @@ static void gp_stroke_doeraser (tGPsdata *p) /* Sketching Operator */ /* clear the session buffers (call this before AND after a paint operation) */ -static void gp_session_validatebuffer (tGPsdata *p) +static void gp_session_validatebuffer(tGPsdata *p) { - bGPdata *gpd= p->gpd; + bGPdata *gpd = p->gpd; /* clear memory of buffer (or allocate it if starting a new session) */ if (gpd->sbuffer) { //printf("\t\tGP - reset sbuffer\n"); - memset(gpd->sbuffer, 0, sizeof(tGPspoint)*GP_STROKE_BUFFER_MAX); + memset(gpd->sbuffer, 0, sizeof(tGPspoint) * GP_STROKE_BUFFER_MAX); } else { //printf("\t\tGP - allocate sbuffer\n"); - gpd->sbuffer= MEM_callocN(sizeof(tGPspoint)*GP_STROKE_BUFFER_MAX, "gp_session_strokebuffer"); + gpd->sbuffer = MEM_callocN(sizeof(tGPspoint) * GP_STROKE_BUFFER_MAX, "gp_session_strokebuffer"); } /* reset indices */ gpd->sbuffer_size = 0; /* reset flags */ - gpd->sbuffer_sflag= 0; + gpd->sbuffer_sflag = 0; } /* (re)init new painting data */ -static int gp_session_initdata (bContext *C, tGPsdata *p) +static int gp_session_initdata(bContext *C, tGPsdata *p) { bGPdata **gpd_ptr = NULL; - ScrArea *curarea= CTX_wm_area(C); - ARegion *ar= CTX_wm_region(C); + ScrArea *curarea = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); /* make sure the active view (at the starting time) is a 3d-view */ if (curarea == NULL) { - p->status= GP_STATUS_ERROR; + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: No active view for painting\n"); return 0; } /* pass on current scene and window */ - p->scene= CTX_data_scene(C); - p->win= CTX_wm_window(C); + p->scene = CTX_data_scene(C); + p->win = CTX_wm_window(C); unit_m4(p->imat); @@ -1008,11 +1008,11 @@ static int gp_session_initdata (bContext *C, tGPsdata *p) /* set current area * - must verify that region data is 3D-view (and not something else) */ - p->sa= curarea; - p->ar= ar; + p->sa = curarea; + p->ar = ar; if (ar->regiondata == NULL) { - p->status= GP_STATUS_ERROR; + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: 3D-View active region doesn't have any region data, so cannot be drawable\n"); return 0; @@ -1020,118 +1020,118 @@ static int gp_session_initdata (bContext *C, tGPsdata *p) #if 0 // XXX will this sort of antiquated stuff be restored? /* check that gpencil data is allowed to be drawn */ - if ((v3d->flag2 & V3D_DISPGP)==0) { - p->status= GP_STATUS_ERROR; + if ((v3d->flag2 & V3D_DISPGP) == 0) { + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: In active view, Grease Pencil not shown\n"); return 0; } #endif } - break; + break; case SPACE_NODE: { //SpaceNode *snode= curarea->spacedata.first; /* set current area */ - p->sa= curarea; - p->ar= ar; - p->v2d= &ar->v2d; + p->sa = curarea; + p->ar = ar; + p->v2d = &ar->v2d; #if 0 // XXX will this sort of antiquated stuff be restored? /* check that gpencil data is allowed to be drawn */ - if ((snode->flag & SNODE_DISPGP)==0) { - p->status= GP_STATUS_ERROR; + if ((snode->flag & SNODE_DISPGP) == 0) { + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: In active view, Grease Pencil not shown\n"); return 0; } #endif } - break; + break; #if 0 // XXX these other spaces will come over time... case SPACE_SEQ: { - SpaceSeq *sseq= curarea->spacedata.first; + SpaceSeq *sseq = curarea->spacedata.first; /* set current area */ - p->sa= curarea; - p->ar= ar; - p->v2d= &ar->v2d; + p->sa = curarea; + p->ar = ar; + p->v2d = &ar->v2d; /* check that gpencil data is allowed to be drawn */ if (sseq->mainb == SEQ_DRAW_SEQUENCE) { - p->status= GP_STATUS_ERROR; + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: In active view (sequencer), active mode doesn't support Grease Pencil\n"); return 0; } - if ((sseq->flag & SEQ_DRAW_GPENCIL)==0) { - p->status= GP_STATUS_ERROR; + if ((sseq->flag & SEQ_DRAW_GPENCIL) == 0) { + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: In active view, Grease Pencil not shown\n"); return 0; } } - break; + break; #endif case SPACE_IMAGE: { //SpaceImage *sima= curarea->spacedata.first; /* set the current area */ - p->sa= curarea; - p->ar= ar; - p->v2d= &ar->v2d; + p->sa = curarea; + p->ar = ar; + p->v2d = &ar->v2d; //p->ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser); #if 0 // XXX disabled for now /* check that gpencil data is allowed to be drawn */ - if ((sima->flag & SI_DISPGP)==0) { - p->status= GP_STATUS_ERROR; + if ((sima->flag & SI_DISPGP) == 0) { + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: In active view, Grease Pencil not shown\n"); return 0; } #endif } - break; + break; case SPACE_CLIP: { - SpaceClip *sc= curarea->spacedata.first; + SpaceClip *sc = curarea->spacedata.first; /* set the current area */ - p->sa= curarea; - p->ar= ar; - p->v2d= &ar->v2d; + p->sa = curarea; + p->ar = ar; + p->v2d = &ar->v2d; //p->ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser); invert_m4_m4(p->imat, sc->unistabmat); /* custom color for new layer */ - p->custom_color[0]= 1.0f; - p->custom_color[1]= 0.0f; - p->custom_color[2]= 0.5f; - p->custom_color[3]= 0.9f; + p->custom_color[0] = 1.0f; + p->custom_color[1] = 0.0f; + p->custom_color[2] = 0.5f; + p->custom_color[3] = 0.9f; } - break; + break; /* unsupported views */ default: { - p->status= GP_STATUS_ERROR; + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: Active view not appropriate for Grease Pencil drawing\n"); return 0; } - break; + break; } /* get gp-data */ - gpd_ptr= gpencil_data_get_pointers(C, &p->ownerPtr); + gpd_ptr = gpencil_data_get_pointers(C, &p->ownerPtr); if (gpd_ptr == NULL) { - p->status= GP_STATUS_ERROR; + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: Current context doesn't allow for any Grease Pencil data\n"); return 0; @@ -1139,11 +1139,11 @@ static int gp_session_initdata (bContext *C, tGPsdata *p) else { /* if no existing GPencil block exists, add one */ if (*gpd_ptr == NULL) - *gpd_ptr= gpencil_data_addnew("GPencil"); - p->gpd= *gpd_ptr; + *gpd_ptr = gpencil_data_addnew("GPencil"); + p->gpd = *gpd_ptr; } - if (ED_gpencil_session_active()==0) { + if (ED_gpencil_session_active() == 0) { /* initialize undo stack, * also, existing undo stack would make buffer drawn */ gpencil_undo_init(p->gpd); @@ -1154,20 +1154,20 @@ static int gp_session_initdata (bContext *C, tGPsdata *p) #if 0 /* set 'default' im2d_settings just in case something that uses this doesn't set it */ - p->im2d_settings.sizex= 1; - p->im2d_settings.sizey= 1; + p->im2d_settings.sizex = 1; + p->im2d_settings.sizey = 1; #endif return 1; } /* init new painting session */ -static tGPsdata *gp_session_initpaint (bContext *C) +static tGPsdata *gp_session_initpaint(bContext *C) { tGPsdata *p = NULL; /* create new context data */ - p= MEM_callocN(sizeof(tGPsdata), "GPencil Drawing Data"); + p = MEM_callocN(sizeof(tGPsdata), "GPencil Drawing Data"); gp_session_initdata(C, p); @@ -1176,9 +1176,9 @@ static tGPsdata *gp_session_initpaint (bContext *C) } /* cleanup after a painting session */ -static void gp_session_cleanup (tGPsdata *p) +static void gp_session_cleanup(tGPsdata *p) { - bGPdata *gpd= (p) ? p->gpd : NULL; + bGPdata *gpd = (p) ? p->gpd : NULL; /* error checking */ if (gpd == NULL) @@ -1188,36 +1188,36 @@ static void gp_session_cleanup (tGPsdata *p) if (gpd->sbuffer) { //printf("\t\tGP - free sbuffer\n"); MEM_freeN(gpd->sbuffer); - gpd->sbuffer= NULL; + gpd->sbuffer = NULL; } /* clear flags */ - gpd->sbuffer_size= 0; - gpd->sbuffer_sflag= 0; + gpd->sbuffer_size = 0; + gpd->sbuffer_sflag = 0; } /* init new stroke */ -static void gp_paint_initstroke (tGPsdata *p, short paintmode) +static void gp_paint_initstroke(tGPsdata *p, short paintmode) { /* get active layer (or add a new one if non-existent) */ - p->gpl= gpencil_layer_getactive(p->gpd); + p->gpl = gpencil_layer_getactive(p->gpd); if (p->gpl == NULL) { - p->gpl= gpencil_layer_addnew(p->gpd); + p->gpl = gpencil_layer_addnew(p->gpd); if (p->custom_color[3]) copy_v3_v3(p->gpl->color, p->custom_color); } if (p->gpl->flag & GP_LAYER_LOCKED) { - p->status= GP_STATUS_ERROR; + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: Cannot paint on locked layer\n"); return; } /* get active frame (add a new one if not matching frame) */ - p->gpf= gpencil_layer_getframe(p->gpl, p->scene->r.cfra, 1); + p->gpf = gpencil_layer_getframe(p->gpl, p->scene->r.cfra, 1); if (p->gpf == NULL) { - p->status= GP_STATUS_ERROR; + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: No frame created (gpencil_paint_init)\n"); return; @@ -1226,7 +1226,7 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) p->gpf->flag |= GP_FRAME_PAINT; /* set 'eraser' for this stroke if using eraser */ - p->paintmode= paintmode; + p->paintmode = paintmode; if (p->paintmode == GP_PAINTMODE_ERASER) p->gpd->sbuffer_sflag |= GP_STROKE_ERASER; @@ -1237,13 +1237,13 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) /* when drawing in the camera view, in 2D space, set the subrect */ if (!(p->gpd->flag & GP_DATA_VIEWALIGN)) { if (p->sa->spacetype == SPACE_VIEW3D) { - View3D *v3d= p->sa->spacedata.first; - RegionView3D *rv3d= p->ar->regiondata; + View3D *v3d = p->sa->spacedata.first; + RegionView3D *rv3d = p->ar->regiondata; /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { ED_view3d_calc_camera_border(p->scene, p->ar, v3d, rv3d, &p->subrect_data, TRUE); /* no shift */ - p->subrect= &p->subrect_data; + p->subrect = &p->subrect_data; } } } @@ -1253,7 +1253,7 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) switch (p->sa->spacetype) { case SPACE_VIEW3D: { - RegionView3D *rv3d= p->ar->regiondata; + RegionView3D *rv3d = p->ar->regiondata; float rvec[3]; /* get reference point for 3d space placement */ @@ -1262,17 +1262,17 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) p->gpd->sbuffer_sflag |= GP_STROKE_3DSPACE; } - break; + break; case SPACE_NODE: { p->gpd->sbuffer_sflag |= GP_STROKE_2DSPACE; } - break; + break; #if 0 // XXX other spacetypes to be restored in due course case SPACE_SEQ: { - SpaceSeq *sseq= (SpaceSeq *)p->sa->spacedata.first; + SpaceSeq *sseq = (SpaceSeq *)p->sa->spacedata.first; int rectx, recty; float zoom, zoomx, zoomy; @@ -1280,7 +1280,7 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) p->gpd->sbuffer_sflag |= GP_STROKE_2DIMAGE; /* calculate zoom factor */ - zoom= (float)(SEQ_ZOOM_FAC(sseq->zoom)); + zoom = (float)(SEQ_ZOOM_FAC(sseq->zoom)); if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { zoomx = zoom * (p->scene->r.xasp / p->scene->r.yasp); zoomy = zoom; @@ -1293,20 +1293,20 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) * as it is too messy getting the ibuf (and could be too slow). This should be * a reasonable for most cases anyway. */ - rectx= (p->scene->r.size * p->scene->r.xsch) / 100; - recty= (p->scene->r.size * p->scene->r.ysch) / 100; + rectx = (p->scene->r.size * p->scene->r.xsch) / 100; + recty = (p->scene->r.size * p->scene->r.ysch) / 100; /* set offset and scale values for opertations to use */ - p->im2d_settings.sizex= (int)(zoomx * rectx); - p->im2d_settings.sizey= (int)(zoomy * recty); - p->im2d_settings.offsx= (int)((p->sa->winx-p->im2d_settings.sizex)/2 + sseq->xof); - p->im2d_settings.offsy= (int)((p->sa->winy-p->im2d_settings.sizey)/2 + sseq->yof); + p->im2d_settings.sizex = (int)(zoomx * rectx); + p->im2d_settings.sizey = (int)(zoomy * recty); + p->im2d_settings.offsx = (int)((p->sa->winx - p->im2d_settings.sizex) / 2 + sseq->xof); + p->im2d_settings.offsy = (int)((p->sa->winy - p->im2d_settings.sizey) / 2 + sseq->yof); } - break; + break; #endif case SPACE_IMAGE: { - SpaceImage *sima= (SpaceImage *)p->sa->spacedata.first; + SpaceImage *sima = (SpaceImage *)p->sa->spacedata.first; /* only set these flags if the image editor doesn't have an image active, * otherwise user will be confused by strokes not appearing after they're drawn @@ -1321,29 +1321,29 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) else p->gpd->sbuffer_sflag |= GP_STROKE_2DSPACE; } - break; + break; case SPACE_CLIP: { p->gpd->sbuffer_sflag |= GP_STROKE_2DSPACE; } - break; + break; } } } /* finish off a stroke (clears buffer, but doesn't finish the paint operation) */ -static void gp_paint_strokeend (tGPsdata *p) +static void gp_paint_strokeend(tGPsdata *p) { /* for surface sketching, need to set the right OpenGL context stuff so that * the conversions will project the values correctly... */ if (gpencil_project_check(p)) { - View3D *v3d= p->sa->spacedata.first; + View3D *v3d = p->sa->spacedata.first; /* need to restore the original projection settings before packing up */ view3d_region_operator_needs_opengl(p->win, p->ar); - ED_view3d_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1:0); + ED_view3d_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1 : 0); } /* check if doing eraser or not */ @@ -1363,7 +1363,7 @@ static void gp_paint_strokeend (tGPsdata *p) } /* finish off stroke painting operation */ -static void gp_paint_cleanup (tGPsdata *p) +static void gp_paint_cleanup(tGPsdata *p) { /* p->gpd==NULL happens when stroke failed to initialize, * for example. when GP is hidden in current space (sergey) */ @@ -1379,9 +1379,9 @@ static void gp_paint_cleanup (tGPsdata *p) /* ------------------------------- */ -static void gpencil_draw_exit (bContext *C, wmOperator *op) +static void gpencil_draw_exit(bContext *C, wmOperator *op) { - tGPsdata *p= op->customdata; + tGPsdata *p = op->customdata; /* clear undo stack */ gpencil_undo_finish(); @@ -1405,10 +1405,10 @@ static void gpencil_draw_exit (bContext *C, wmOperator *op) MEM_freeN(p); } - op->customdata= NULL; + op->customdata = NULL; } -static int gpencil_draw_cancel (bContext *C, wmOperator *op) +static int gpencil_draw_cancel(bContext *C, wmOperator *op) { /* this is just a wrapper around exit() */ gpencil_draw_exit(C, op); @@ -1418,13 +1418,13 @@ static int gpencil_draw_cancel (bContext *C, wmOperator *op) /* ------------------------------- */ -static int gpencil_draw_init (bContext *C, wmOperator *op) +static int gpencil_draw_init(bContext *C, wmOperator *op) { tGPsdata *p; - int paintmode= RNA_enum_get(op->ptr, "mode"); + int paintmode = RNA_enum_get(op->ptr, "mode"); /* check context */ - p= op->customdata= gp_session_initpaint(C); + p = op->customdata = gp_session_initpaint(C); if ((p == NULL) || (p->status == GP_STATUS_ERROR)) { /* something wasn't set correctly in context */ gpencil_draw_exit(C, op); @@ -1439,7 +1439,7 @@ static int gpencil_draw_init (bContext *C, wmOperator *op) } /* radius for eraser circle is defined in userprefs now */ - p->radius= U.gp_eraser; + p->radius = U.gp_eraser; /* everything is now setup ok */ return 1; @@ -1448,7 +1448,7 @@ static int gpencil_draw_init (bContext *C, wmOperator *op) /* ------------------------------- */ /* update UI indicators of status, including cursor and header prints */ -static void gpencil_draw_status_indicators (tGPsdata *p) +static void gpencil_draw_status_indicators(tGPsdata *p) { /* header prints */ switch (p->status) { @@ -1488,7 +1488,7 @@ static void gpencil_draw_status_indicators (tGPsdata *p) /* ------------------------------- */ /* create a new stroke point at the point indicated by the painting context */ -static void gpencil_draw_apply (wmOperator *op, tGPsdata *p) +static void gpencil_draw_apply(wmOperator *op, tGPsdata *p) { /* handle drawing/erasing -> test for erasing first */ if (p->paintmode == GP_PAINTMODE_ERASER) { @@ -1496,14 +1496,14 @@ static void gpencil_draw_apply (wmOperator *op, tGPsdata *p) gp_stroke_doeraser(p); /* store used values */ - p->mvalo[0]= p->mval[0]; - p->mvalo[1]= p->mval[1]; - p->opressure= p->pressure; + p->mvalo[0] = p->mval[0]; + p->mvalo[1] = p->mval[1]; + p->opressure = p->pressure; } /* only add current point to buffer if mouse moved (even though we got an event, it might be just noise) */ else if (gp_stroke_filtermval(p, p->mval, p->mvalo)) { /* try to add point */ - short ok= gp_stroke_addpoint(p, p->mval, p->pressure); + short ok = gp_stroke_addpoint(p, p->mval, p->pressure); /* handle errors while adding point */ if ((ok == GP_STROKEADD_FULL) || (ok == GP_STROKEADD_OVERFLOW)) { @@ -1525,43 +1525,43 @@ static void gpencil_draw_apply (wmOperator *op, tGPsdata *p) } /* store used values */ - p->mvalo[0]= p->mval[0]; - p->mvalo[1]= p->mval[1]; - p->opressure= p->pressure; + p->mvalo[0] = p->mval[0]; + p->mvalo[1] = p->mval[1]; + p->opressure = p->pressure; } } /* handle draw event */ -static void gpencil_draw_apply_event (wmOperator *op, wmEvent *event) +static void gpencil_draw_apply_event(wmOperator *op, wmEvent *event) { - tGPsdata *p= op->customdata; + tGPsdata *p = op->customdata; PointerRNA itemptr; float mousef[2]; - int tablet=0; + int tablet = 0; /* convert from window-space to area-space mouse coordintes */ // NOTE: float to ints conversions, +1 factor is probably used to ensure a bit more accurate rounding... - p->mval[0]= event->mval[0] + 1; - p->mval[1]= event->mval[1] + 1; + p->mval[0] = event->mval[0] + 1; + p->mval[1] = event->mval[1] + 1; /* handle pressure sensitivity (which is supplied by tablets) */ if (event->custom == EVT_DATA_TABLET) { - wmTabletData *wmtab= event->customdata; + wmTabletData *wmtab = event->customdata; - tablet= (wmtab->Active != EVT_TABLET_NONE); - p->pressure= wmtab->Pressure; + tablet = (wmtab->Active != EVT_TABLET_NONE); + p->pressure = wmtab->Pressure; //if (wmtab->Active == EVT_TABLET_ERASER) - // TODO... this should get caught by the keymaps which call drawing in the first place + // TODO... this should get caught by the keymaps which call drawing in the first place } else - p->pressure= 1.0f; + p->pressure = 1.0f; /* fill in stroke data (not actually used directly by gpencil_draw_apply) */ RNA_collection_add(op->ptr, "stroke", &itemptr); - mousef[0]= p->mval[0]; - mousef[1]= p->mval[1]; + mousef[0] = p->mval[0]; + mousef[1] = p->mval[1]; RNA_float_set_array(&itemptr, "mouse", mousef); RNA_float_set(&itemptr, "pressure", p->pressure); RNA_boolean_set(&itemptr, "is_start", (p->flags & GP_PAINTFLAG_FIRSTRUN)); @@ -1570,9 +1570,9 @@ static void gpencil_draw_apply_event (wmOperator *op, wmEvent *event) if (p->flags & GP_PAINTFLAG_FIRSTRUN) { p->flags &= ~GP_PAINTFLAG_FIRSTRUN; - p->mvalo[0]= p->mval[0]; - p->mvalo[1]= p->mval[1]; - p->opressure= p->pressure; + p->mvalo[0] = p->mval[0]; + p->mvalo[1] = p->mval[1]; + p->opressure = p->pressure; /* special exception here for too high pressure values on first touch in * windows for some tablets, then we just skip first touch .. @@ -1591,7 +1591,7 @@ static void gpencil_draw_apply_event (wmOperator *op, wmEvent *event) /* ------------------------------- */ /* operator 'redo' (i.e. after changing some properties, but also for repeat last) */ -static int gpencil_draw_exec (bContext *C, wmOperator *op) +static int gpencil_draw_exec(bContext *C, wmOperator *op) { tGPsdata *p = NULL; @@ -1604,14 +1604,14 @@ static int gpencil_draw_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else - p= op->customdata; + p = op->customdata; //printf("\tGP - Start redrawing stroke\n"); /* loop over the stroke RNA elements recorded (i.e. progress of mouse movement), * setting the relevant values in context at each step, then applying */ - RNA_BEGIN (op->ptr, itemptr, "stroke") + RNA_BEGIN(op->ptr, itemptr, "stroke") { float mousef[2]; @@ -1621,7 +1621,7 @@ static int gpencil_draw_exec (bContext *C, wmOperator *op) RNA_float_get_array(&itemptr, "mouse", mousef); p->mval[0] = (int)mousef[0]; p->mval[1] = (int)mousef[1]; - p->pressure= RNA_float_get(&itemptr, "pressure"); + p->pressure = RNA_float_get(&itemptr, "pressure"); if (RNA_boolean_get(&itemptr, "is_start")) { /* if first-run flag isn't set already (i.e. not true first stroke), @@ -1638,9 +1638,9 @@ static int gpencil_draw_exec (bContext *C, wmOperator *op) if (p->flags & GP_PAINTFLAG_FIRSTRUN) { p->flags &= ~GP_PAINTFLAG_FIRSTRUN; - p->mvalo[0]= p->mval[0]; - p->mvalo[1]= p->mval[1]; - p->opressure= p->pressure; + p->mvalo[0] = p->mval[0]; + p->mvalo[1] = p->mval[1]; + p->opressure = p->pressure; } /* apply this data as necessary now (as per usual) */ @@ -1654,7 +1654,7 @@ static int gpencil_draw_exec (bContext *C, wmOperator *op) gpencil_draw_exit(C, op); /* refreshes */ - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX need a nicer one that will work + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX need a nicer one that will work /* done */ return OPERATOR_FINISHED; @@ -1663,10 +1663,10 @@ static int gpencil_draw_exec (bContext *C, wmOperator *op) /* ------------------------------- */ /* start of interactive drawing part of operator */ -static int gpencil_draw_invoke (bContext *C, wmOperator *op, wmEvent *event) +static int gpencil_draw_invoke(bContext *C, wmOperator *op, wmEvent *event) { tGPsdata *p = NULL; - wmWindow *win= CTX_wm_window(C); + wmWindow *win = CTX_wm_window(C); if (G.debug & G_DEBUG) printf("GPencil - Starting Drawing\n"); @@ -1680,7 +1680,7 @@ static int gpencil_draw_invoke (bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_CANCELLED; } else - p= op->customdata; + p = op->customdata; // TODO: set any additional settings that we can take from the events? // TODO? if tablet is erasing, force eraser to be on? @@ -1694,7 +1694,7 @@ static int gpencil_draw_invoke (bContext *C, wmOperator *op, wmEvent *event) /* set cursor */ if (p->paintmode == GP_PAINTMODE_ERASER) - WM_cursor_modal(win, BC_CROSSCURSOR); // XXX need a better cursor + WM_cursor_modal(win, BC_CROSSCURSOR); // XXX need a better cursor else WM_cursor_modal(win, BC_PAINTBRUSHCURSOR); @@ -1705,7 +1705,7 @@ static int gpencil_draw_invoke (bContext *C, wmOperator *op, wmEvent *event) if (event->type) { /* hotkey invoked - start drawing */ //printf("\tGP - set first spot\n"); - p->status= GP_STATUS_PAINTING; + p->status = GP_STATUS_PAINTING; /* handle the initial drawing - i.e. for just doing a simple dot */ gpencil_draw_apply_event(op, event); @@ -1715,7 +1715,7 @@ static int gpencil_draw_invoke (bContext *C, wmOperator *op, wmEvent *event) //printf("\tGP - hotkey invoked... waiting for click-drag\n"); } - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL, NULL); + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL, NULL); /* add a modal handler for this operator, so that we can then draw continuous strokes */ WM_event_add_modal_handler(C, op); return OPERATOR_RUNNING_MODAL; @@ -1724,11 +1724,11 @@ static int gpencil_draw_invoke (bContext *C, wmOperator *op, wmEvent *event) /* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */ static int gpencil_area_exists(bContext *C, ScrArea *satest) { - bScreen *sc= CTX_wm_screen(C); + bScreen *sc = CTX_wm_screen(C); ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { - if (sa==satest) + for (sa = sc->areabase.first; sa; sa = sa->next) { + if (sa == satest) return 1; } @@ -1737,14 +1737,14 @@ static int gpencil_area_exists(bContext *C, ScrArea *satest) static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) { - tGPsdata *p= op->customdata; + tGPsdata *p = op->customdata; /* we must check that we're still within the area that we're set up to work from * otherwise we could crash (see bug #20586) */ if (CTX_wm_area(C) != p->sa) { printf("\t\t\tGP - wrong area execution abort!\n"); - p->status= GP_STATUS_ERROR; + p->status = GP_STATUS_ERROR; } //printf("\t\tGP - start stroke\n"); @@ -1757,14 +1757,14 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) gp_paint_initstroke(p, p->paintmode); if (p->status != GP_STATUS_ERROR) - p->status= GP_STATUS_PAINTING; + p->status = GP_STATUS_PAINTING; return op->customdata; } static void gpencil_stroke_end(wmOperator *op) { - tGPsdata *p= op->customdata; + tGPsdata *p = op->customdata; gp_paint_cleanup(p); @@ -1772,17 +1772,17 @@ static void gpencil_stroke_end(wmOperator *op) gp_session_cleanup(p); - p->status= GP_STATUS_IDLING; + p->status = GP_STATUS_IDLING; - p->gpd= NULL; - p->gpl= NULL; - p->gpf= NULL; + p->gpd = NULL; + p->gpl = NULL; + p->gpf = NULL; } /* events handling during interactive drawing part of operator */ -static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) +static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event) { - tGPsdata *p= op->customdata; + tGPsdata *p = op->customdata; int estate = OPERATOR_PASS_THROUGH; /* default exit state - not handled, so let others have a share of the pie */ // if (event->type == NDOF_MOTION) @@ -1803,7 +1803,7 @@ static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) if (ELEM4(event->type, RETKEY, PADENTER, ESCKEY, SPACEKEY)) { /* exit() ends the current stroke before cleaning up */ //printf("\t\tGP - end of paint op + end of stroke\n"); - p->status= GP_STATUS_DONE; + p->status = GP_STATUS_DONE; estate = OPERATOR_FINISHED; } @@ -1811,7 +1811,7 @@ static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) if (ELEM(event->type, LEFTMOUSE, RIGHTMOUSE)) { /* if painting, end stroke */ if (p->status == GP_STATUS_PAINTING) { - int sketch= 0; + int sketch = 0; /* basically, this should be mouse-button up = end stroke * BUT what happens next depends on whether we 'painting sessions' is enabled */ @@ -1828,17 +1828,17 @@ static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) estate = OPERATOR_RUNNING_MODAL; /* stroke could be smoothed, send notifier to refresh screen */ - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); } else { //printf("\t\tGP - end of stroke + op\n"); - p->status= GP_STATUS_DONE; + p->status = GP_STATUS_DONE; estate = OPERATOR_FINISHED; } } else if (event->val == KM_PRESS) { /* not painting, so start stroke (this should be mouse-button down) */ - p= gpencil_stroke_begin(C, op); + p = gpencil_stroke_begin(C, op); if (p->status == GP_STATUS_ERROR) { estate = OPERATOR_CANCELLED; @@ -1878,8 +1878,8 @@ static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) } /* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */ - if (0==gpencil_area_exists(C, p->sa)) - estate= OPERATOR_CANCELLED; + if (0 == gpencil_area_exists(C, p->sa)) + estate = OPERATOR_CANCELLED; else /* update status indicators - cursor, header, etc. */ gpencil_draw_status_indicators(p); @@ -1889,14 +1889,14 @@ static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) case OPERATOR_FINISHED: /* one last flush before we're done */ gpencil_draw_exit(C, op); - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX need a nicer one that will work + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX need a nicer one that will work break; case OPERATOR_CANCELLED: gpencil_draw_exit(C, op); break; - case OPERATOR_RUNNING_MODAL|OPERATOR_PASS_THROUGH: + case OPERATOR_RUNNING_MODAL | OPERATOR_PASS_THROUGH: /* event doesn't need to be handled */ //printf("unhandled event -> %d (mmb? = %d | mmv? = %d)\n", event->type, event->type == MIDDLEMOUSE, event->type==MOUSEMOVE); break; @@ -1931,7 +1931,7 @@ void GPENCIL_OT_draw(wmOperatorType *ot) ot->poll = gpencil_draw_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* settings for drawing */ RNA_def_enum(ot->srna, "mode", prop_gpencil_drawmodes, 0, "Mode", "Way to interpret mouse movements"); diff --git a/source/blender/editors/gpencil/gpencil_undo.c b/source/blender/editors/gpencil/gpencil_undo.c index 916b4fff561..61f7e1bb86f 100644 --- a/source/blender/editors/gpencil/gpencil_undo.c +++ b/source/blender/editors/gpencil/gpencil_undo.c @@ -46,7 +46,7 @@ #include "gpencil_intern.h" -#define MAXUNDONAME 64 +#define MAXUNDONAME 64 typedef struct bGPundonode { struct bGPundonode *next, *prev; @@ -65,25 +65,25 @@ int ED_gpencil_session_active(void) int ED_undo_gpencil_step(bContext *C, int step, const char *name) { - bGPdata **gpd_ptr= NULL, *new_gpd= NULL; + bGPdata **gpd_ptr = NULL, *new_gpd = NULL; - gpd_ptr= gpencil_data_get_pointers(C, NULL); + gpd_ptr = gpencil_data_get_pointers(C, NULL); - if (step==1) { /* undo */ + if (step == 1) { /* undo */ //printf("\t\tGP - undo step\n"); if (cur_node->prev) { if (!name || strcmp(cur_node->name, name) == 0) { - cur_node= cur_node->prev; - new_gpd= cur_node->gpd; + cur_node = cur_node->prev; + new_gpd = cur_node->gpd; } } } - else if (step==-1) { + else if (step == -1) { //printf("\t\tGP - redo step\n"); if (cur_node->next) { if (!name || strcmp(cur_node->name, name) == 0) { - cur_node= cur_node->next; - new_gpd= cur_node->gpd; + cur_node = cur_node->next; + new_gpd = cur_node->gpd; } } } @@ -91,24 +91,24 @@ int ED_undo_gpencil_step(bContext *C, int step, const char *name) if (new_gpd) { if (gpd_ptr) { if (*gpd_ptr) { - bGPdata *gpd= *gpd_ptr; + bGPdata *gpd = *gpd_ptr; bGPDlayer *gpl, *gpld; free_gpencil_layers(&gpd->layers); /* copy layers */ - gpd->layers.first= gpd->layers.last= NULL; + gpd->layers.first = gpd->layers.last = NULL; - for (gpl= new_gpd->layers.first; gpl; gpl= gpl->next) { + for (gpl = new_gpd->layers.first; gpl; gpl = gpl->next) { /* make a copy of source layer and its data */ - gpld= gpencil_layer_duplicate(gpl); + gpld = gpencil_layer_duplicate(gpl); BLI_addtail(&gpd->layers, gpld); } } } } - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -126,41 +126,41 @@ void gpencil_undo_push(bGPdata *gpd) if (cur_node) { /* remove all un-done nodes from stack */ - undo_node= cur_node->next; + undo_node = cur_node->next; while (undo_node) { - bGPundonode *next_node= undo_node->next; + bGPundonode *next_node = undo_node->next; BKE_gpencil_free(undo_node->gpd); MEM_freeN(undo_node->gpd); BLI_freelinkN(&undo_nodes, undo_node); - undo_node= next_node; + undo_node = next_node; } } /* create new undo node */ - undo_node= MEM_callocN(sizeof(bGPundonode), "gpencil undo node"); - undo_node->gpd= gpencil_data_duplicate(gpd); + undo_node = MEM_callocN(sizeof(bGPundonode), "gpencil undo node"); + undo_node->gpd = gpencil_data_duplicate(gpd); - cur_node= undo_node; + cur_node = undo_node; BLI_addtail(&undo_nodes, undo_node); } void gpencil_undo_finish(void) { - bGPundonode *undo_node= undo_nodes.first; + bGPundonode *undo_node = undo_nodes.first; while (undo_node) { BKE_gpencil_free(undo_node->gpd); MEM_freeN(undo_node->gpd); - undo_node= undo_node->next; + undo_node = undo_node->next; } BLI_freelistN(&undo_nodes); - cur_node= NULL; + cur_node = NULL; } diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index c7fb523dcba..0c13b5de02e 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -509,9 +509,9 @@ static void ui_draw_linkline(uiLinkLine *line, int hilightActiveLines) rect.xmax = (line->to->x1 + line->to->x2) / 2.0f; rect.ymax = (line->to->y1 + line->to->y2) / 2.0f; - if(line->flag & UI_SELECT) - glColor3ub(100,100,100); - else if(hilightActiveLines && ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE))) + if (line->flag & UI_SELECT) + glColor3ub(100, 100, 100); + else if (hilightActiveLines && ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE))) UI_ThemeColor(TH_TEXT_HI); else glColor3ub(0, 0, 0); @@ -528,9 +528,9 @@ static void ui_draw_links(uiBlock *block) // As we go, remember if we see any active or selected lines. int foundselectline = 0; int foundactiveline = 0; - for (but=block->buttons.first; but; but=but->next) { - if(but->type==LINK && but->link) { - for (line=but->link->lines.first; line; line=line->next) { + for (but = block->buttons.first; but; but = but->next) { + if (but->type == LINK && but->link) { + for (line = but->link->lines.first; line; line = line->next) { if (!(line->from->flag & UI_ACTIVE) && !(line->to->flag & UI_ACTIVE)) ui_draw_linkline(line, 0); else @@ -545,9 +545,9 @@ static void ui_draw_links(uiBlock *block) // Draw any active lines (lines with either button being hovered over). // Do this last so they appear on top of inactive lines. if (foundactiveline) { - for (but=block->buttons.first; but; but=but->next) { - if(but->type==LINK && but->link) { - for (line=but->link->lines.first; line; line=line->next) { + for (but = block->buttons.first; but; but = but->next) { + if (but->type == LINK && but->link) { + for (line = but->link->lines.first; line; line = line->next) { if ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE)) ui_draw_linkline(line, !foundselectline); } diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index a0935e7abdd..9e073055fc3 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -99,48 +99,48 @@ typedef enum { } uiWidgetTypeEnum; /* panel limits */ -#define UI_PANEL_MINX 100 -#define UI_PANEL_MINY 70 +#define UI_PANEL_MINX 100 +#define UI_PANEL_MINY 70 /* uiBut->flag */ -#define UI_SELECT 1 /* use when the button is pressed */ -#define UI_SCROLLED 2 /* temp hidden, scrolled away */ -#define UI_ACTIVE 4 -#define UI_HAS_ICON 8 -#define UI_TEXTINPUT 16 -#define UI_HIDDEN 32 +#define UI_SELECT 1 /* use when the button is pressed */ +#define UI_SCROLLED 2 /* temp hidden, scrolled away */ +#define UI_ACTIVE 4 +#define UI_HAS_ICON 8 +#define UI_TEXTINPUT 16 +#define UI_HIDDEN 32 /* warn: rest of uiBut->flag in UI_interface.h */ /* internal panel drawing defines */ -#define PNL_GRID (UI_UNIT_Y / 5) /* 4 default */ -#define PNL_HEADER (UI_UNIT_Y + 4) /* 24 default */ +#define PNL_GRID (UI_UNIT_Y / 5) /* 4 default */ +#define PNL_HEADER (UI_UNIT_Y + 4) /* 24 default */ /* panel->flag */ -#define PNL_SELECT 1 -#define PNL_CLOSEDX 2 -#define PNL_CLOSEDY 4 -#define PNL_CLOSED 6 +#define PNL_SELECT 1 +#define PNL_CLOSEDX 2 +#define PNL_CLOSEDY 4 +#define PNL_CLOSED 6 /*#define PNL_TABBED 8*/ /*UNUSED*/ -#define PNL_OVERLAP 16 +#define PNL_OVERLAP 16 /* Button text selection: * extension direction, selextend, inside ui_do_but_TEX */ -#define EXTEND_LEFT 1 -#define EXTEND_RIGHT 2 +#define EXTEND_LEFT 1 +#define EXTEND_RIGHT 2 /* for scope resize zone */ -#define SCOPE_RESIZE_PAD 9 +#define SCOPE_RESIZE_PAD 9 -typedef struct uiLinkLine { /* only for draw/edit */ +typedef struct uiLinkLine { /* only for draw/edit */ struct uiLinkLine *next, *prev; struct uiBut *from, *to; short flag, pad; } uiLinkLine; typedef struct { - void **poin; /* pointer to original pointer */ - void ***ppoin; /* pointer to original pointer-array */ - short *totlink; /* if pointer-array, here is the total */ + void **poin; /* pointer to original pointer */ + void ***ppoin; /* pointer to original pointer-array */ + short *totlink; /* if pointer-array, here is the total */ short maxlink, pad; short fromcode, tocode; @@ -178,8 +178,8 @@ struct uiBut { /* not ysed yet, was used in 2.4x for ui_draw_pulldown_round & friends */ #if 0 - void (*embossfunc)(int , int , float, float, float, float, float, int); - void (*sliderfunc)(int , float, float, float, float, float, float, int); + void (*embossfunc)(int, int, float, float, float, float, float, int); + void (*sliderfunc)(int, float, float, float, float, float, float, int); #endif uiButCompleteFunc autocomplete_func; @@ -245,7 +245,7 @@ struct uiBut { void *editcoba; void *editcumap; - /* pointer back */ + /* pointer back */ uiBlock *block; }; @@ -268,7 +268,7 @@ struct uiBlock { float minx, miny, maxx, maxy; float aspect; - int puphash; // popup menu hash for memory + int puphash; /* popup menu hash for memory */ uiButHandleFunc func; void *func_arg1; @@ -303,27 +303,27 @@ struct uiBlock { const char *lockstr; char lock; - char active; // to keep blocks while drawing and free them afterwards - char tooltipdisabled; // to avoid tooltip after click - char endblock; // uiEndBlock done? + char active; // to keep blocks while drawing and free them afterwards + char tooltipdisabled; // to avoid tooltip after click + char endblock; // uiEndBlock done? - float xofs, yofs; // offset to parent button - int dobounds, mx, my; // for doing delayed - int bounds, minbounds; // for doing delayed + float xofs, yofs; // offset to parent button + int dobounds, mx, my; // for doing delayed + int bounds, minbounds; // for doing delayed - rctf safety; // pulldowns, to detect outside, can differ per case how it is created - ListBase saferct; // uiSafetyRct list + rctf safety; // pulldowns, to detect outside, can differ per case how it is created + ListBase saferct; // uiSafetyRct list - uiPopupBlockHandle *handle; // handle + uiPopupBlockHandle *handle; // handle - struct wmOperator *ui_operator;// use so presets can find the operator, - // across menus and from nested popups which fail for operator context. + struct wmOperator *ui_operator; // use so presets can find the operator, + // across menus and from nested popups which fail for operator context. - void *evil_C; // XXX hack for dynamic operator enums + void *evil_C; // XXX hack for dynamic operator enums - struct UnitSettings *unit; // unit system, used a lot for numeric buttons so include here rather then fetching through the scene every time. - float _hsv[3]; // XXX, only access via ui_block_hsv_get() - char color_profile; // color profile for correcting linear colors for display + struct UnitSettings *unit; // unit system, used a lot for numeric buttons so include here rather then fetching through the scene every time. + float _hsv[3]; // XXX, only access via ui_block_hsv_get() + char color_profile; // color profile for correcting linear colors for display }; typedef struct uiSafetyRct { @@ -425,12 +425,12 @@ void ui_searchbox_apply(uiBut *but, struct ARegion *ar); void ui_searchbox_free(struct bContext *C, struct ARegion *ar); void ui_but_search_test(uiBut *but); -typedef uiBlock* (*uiBlockHandleCreateFunc)(struct bContext *C, struct uiPopupBlockHandle *handle, void *arg1); +typedef uiBlock * (*uiBlockHandleCreateFunc)(struct bContext *C, struct uiPopupBlockHandle *handle, void *arg1); uiPopupBlockHandle *ui_popup_block_create(struct bContext *C, struct ARegion *butregion, uiBut *but, - uiBlockCreateFunc create_func, uiBlockHandleCreateFunc handle_create_func, void *arg); + uiBlockCreateFunc create_func, uiBlockHandleCreateFunc handle_create_func, void *arg); uiPopupBlockHandle *ui_popup_menu_create(struct bContext *C, struct ARegion *butregion, uiBut *but, - uiMenuCreateFunc create_func, void *arg, char *str); + uiMenuCreateFunc create_func, void *arg, char *str); void ui_popup_block_free(struct bContext *C, uiPopupBlockHandle *handle); @@ -466,14 +466,14 @@ extern int ui_button_is_active(struct ARegion *ar); void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3); void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy, float rad); void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect); -uiWidgetColors* ui_tooltip_get_theme(void); -void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock *block, rcti *rect); +uiWidgetColors *ui_tooltip_get_theme(void); +void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock * block, rcti * rect); void ui_draw_search_back(struct uiStyle *style, uiBlock *block, rcti *rect); -int ui_link_bezier_points(rcti *rect, float coord_array[][2], int resol); +int ui_link_bezier_points(rcti * rect, float coord_array[][2], int resol); void ui_draw_link_bezier(rcti *rect); extern void ui_draw_but(const struct bContext *C, ARegion *ar, struct uiStyle *style, uiBut *but, rcti *rect); - /* theme color init */ +/* theme color init */ struct ThemeUI; void ui_widget_color_init(struct ThemeUI *tui); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 3c913b26dec..28ceabdd344 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -857,7 +857,7 @@ void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char PointerRNA ptr; PropertyRNA *prop; - UI_OPERATOR_ERROR_RET(ot, opname, return); + UI_OPERATOR_ERROR_RET(ot, opname, return ); WM_operator_properties_create_ptr(&ptr, ot); @@ -888,7 +888,7 @@ void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char EnumPropertyItem *item; int value, free; - UI_OPERATOR_ERROR_RET(ot, opname, return); + UI_OPERATOR_ERROR_RET(ot, opname, return ); WM_operator_properties_create_ptr(&ptr, ot); @@ -926,7 +926,7 @@ void uiItemBooleanO(uiLayout *layout, const char *name, int icon, const char *op wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - UI_OPERATOR_ERROR_RET(ot, opname, return); + UI_OPERATOR_ERROR_RET(ot, opname, return ); WM_operator_properties_create_ptr(&ptr, ot); RNA_boolean_set(&ptr, propname, value); @@ -939,7 +939,7 @@ void uiItemIntO(uiLayout *layout, const char *name, int icon, const char *opname wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - UI_OPERATOR_ERROR_RET(ot, opname, return); + UI_OPERATOR_ERROR_RET(ot, opname, return ); WM_operator_properties_create_ptr(&ptr, ot); RNA_int_set(&ptr, propname, value); @@ -952,7 +952,7 @@ void uiItemFloatO(uiLayout *layout, const char *name, int icon, const char *opna wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - UI_OPERATOR_ERROR_RET(ot, opname, return); + UI_OPERATOR_ERROR_RET(ot, opname, return ); WM_operator_properties_create_ptr(&ptr, ot); RNA_float_set(&ptr, propname, value); @@ -965,7 +965,7 @@ void uiItemStringO(uiLayout *layout, const char *name, int icon, const char *opn wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - UI_OPERATOR_ERROR_RET(ot, opname, return); + UI_OPERATOR_ERROR_RET(ot, opname, return ); WM_operator_properties_create_ptr(&ptr, ot); RNA_string_set(&ptr, propname, value); @@ -1611,7 +1611,7 @@ void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname, wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ MenuItemLevel *lvl; - UI_OPERATOR_ERROR_RET(ot, opname, return); + UI_OPERATOR_ERROR_RET(ot, opname, return ); if (!ot->srna) { ui_item_disabled(layout, opname); @@ -2726,8 +2726,8 @@ void uiLayoutSetContextPointer(uiLayout *layout, const char *name, PointerRNA *p void uiLayoutContextCopy(uiLayout *layout, bContextStore *context) { - uiBlock *block= layout->root->block; - layout->context= CTX_store_add_all(&block->contexts, context); + uiBlock *block = layout->root->block; + layout->context = CTX_store_add_all(&block->contexts, context); } diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index 1653a084bf2..ed51f53eb03 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -67,24 +67,24 @@ /* This function is used to free all MetaElems from MetaBall */ void free_editMball(Object *obedit) { - MetaBall *mb = (MetaBall*)obedit->data; + MetaBall *mb = (MetaBall *)obedit->data; - mb->editelems= NULL; - mb->lastelem= NULL; + mb->editelems = NULL; + mb->lastelem = NULL; } /* This function is called, when MetaBall Object is * switched from object mode to edit mode */ void make_editMball(Object *obedit) { - MetaBall *mb = (MetaBall*)obedit->data; - MetaElem *ml;/*, *newml;*/ + MetaBall *mb = (MetaBall *)obedit->data; + MetaElem *ml; /*, *newml;*/ - ml= mb->elems.first; + ml = mb->elems.first; while (ml) { if (ml->flag & SELECT) mb->lastelem = ml; - ml= ml->next; + ml = ml->next; } mb->editelems = &mb->elems; @@ -100,22 +100,22 @@ void load_editMball(Object *UNUSED(obedit)) /* Add metaelem primitive to metaball object (which is in edit mode) */ MetaElem *add_metaball_primitive(bContext *C, float mat[4][4], int type, int UNUSED(newname)) { - Object *obedit= CTX_data_edit_object(C); - MetaBall *mball = (MetaBall*)obedit->data; + Object *obedit = CTX_data_edit_object(C); + MetaBall *mball = (MetaBall *)obedit->data; MetaElem *ml; /* Deselect all existing metaelems */ - ml= mball->editelems->first; + ml = mball->editelems->first; while (ml) { ml->flag &= ~SELECT; - ml= ml->next; + ml = ml->next; } - ml= BKE_mball_element_add(mball, type); + ml = BKE_mball_element_add(mball, type); copy_v3_v3(&ml->x, mat[3]); ml->flag |= SELECT; - mball->lastelem= ml; + mball->lastelem = ml; return ml; } @@ -125,12 +125,12 @@ MetaElem *add_metaball_primitive(bContext *C, float mat[4][4], int type, int UNU static int mball_select_all_exec(bContext *C, wmOperator *op) { //Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - MetaBall *mb = (MetaBall*)obedit->data; + Object *obedit = CTX_data_edit_object(C); + MetaBall *mb = (MetaBall *)obedit->data; MetaElem *ml; int action = RNA_enum_get(op->ptr, "action"); - ml= mb->editelems->first; + ml = mb->editelems->first; if (ml) { if (action == SEL_TOGGLE) { action = SEL_SELECT; @@ -139,26 +139,26 @@ static int mball_select_all_exec(bContext *C, wmOperator *op) action = SEL_DESELECT; break; } - ml= ml->next; + ml = ml->next; } } - ml= mb->editelems->first; + ml = mb->editelems->first; while (ml) { switch (action) { - case SEL_SELECT: - ml->flag |= SELECT; - break; - case SEL_DESELECT: - ml->flag &= ~SELECT; - break; - case SEL_INVERT: - ml->flag ^= SELECT; - break; + case SEL_SELECT: + ml->flag |= SELECT; + break; + case SEL_DESELECT: + ml->flag &= ~SELECT; + break; + case SEL_INVERT: + ml->flag ^= SELECT; + break; } - ml= ml->next; + ml = ml->next; } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, mb); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb); } return OPERATOR_FINISHED; @@ -176,7 +176,7 @@ void MBALL_OT_select_all(wmOperatorType *ot) ot->poll = ED_operator_editmball; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_select_all(ot); } @@ -186,16 +186,16 @@ void MBALL_OT_select_all(wmOperatorType *ot) /* Random metaball selection */ static int select_random_metaelems_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - MetaBall *mb = (MetaBall*)obedit->data; + Object *obedit = CTX_data_edit_object(C); + MetaBall *mb = (MetaBall *)obedit->data; MetaElem *ml; - float percent= RNA_float_get(op->ptr, "percent"); + float percent = RNA_float_get(op->ptr, "percent"); if (percent == 0.0f) return OPERATOR_CANCELLED; - ml= mb->editelems->first; - BLI_srand(BLI_rand()); /* Random seed */ + ml = mb->editelems->first; + BLI_srand(BLI_rand()); /* Random seed */ /* Stupid version of random selection. Should be improved. */ while (ml) { @@ -203,10 +203,10 @@ static int select_random_metaelems_exec(bContext *C, wmOperator *op) ml->flag |= SELECT; else ml->flag &= ~SELECT; - ml= ml->next; + ml = ml->next; } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, mb); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb); return OPERATOR_FINISHED; } @@ -225,7 +225,7 @@ void MBALL_OT_select_random_metaelems(struct wmOperatorType *ot) ot->poll = ED_operator_editmball; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float_percentage(ot->srna, "percent", 0.5f, 0.0f, 1.0f, "Percent", "Percentage of metaelems to select randomly", 0.0001f, 1.0f); @@ -236,22 +236,22 @@ void MBALL_OT_select_random_metaelems(struct wmOperatorType *ot) /* Duplicate selected MetaElements */ static int duplicate_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - MetaBall *mb = (MetaBall*)obedit->data; + Object *obedit = CTX_data_edit_object(C); + MetaBall *mb = (MetaBall *)obedit->data; MetaElem *ml, *newml; - ml= mb->editelems->last; + ml = mb->editelems->last; if (ml) { while (ml) { if (ml->flag & SELECT) { - newml= MEM_dupallocN(ml); + newml = MEM_dupallocN(ml); BLI_addtail(mb->editelems, newml); - mb->lastelem= newml; + mb->lastelem = newml; ml->flag &= ~SELECT; } - ml= ml->prev; + ml = ml->prev; } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, mb); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, mb); DAG_id_tag_update(obedit->data, 0); } @@ -260,7 +260,7 @@ static int duplicate_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) static int duplicate_metaelems_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - int retv= duplicate_metaelems_exec(C, op); + int retv = duplicate_metaelems_exec(C, op); if (retv == OPERATOR_FINISHED) { RNA_enum_set(op->ptr, "mode", TFM_TRANSLATION); @@ -284,7 +284,7 @@ void MBALL_OT_duplicate_metaelems(wmOperatorType *ot) ot->poll = ED_operator_editmball; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* to give to transform */ RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", ""); @@ -295,22 +295,22 @@ void MBALL_OT_duplicate_metaelems(wmOperatorType *ot) /* Delete all selected MetaElems (not MetaBall) */ static int delete_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - MetaBall *mb= (MetaBall*)obedit->data; + Object *obedit = CTX_data_edit_object(C); + MetaBall *mb = (MetaBall *)obedit->data; MetaElem *ml, *next; - ml= mb->editelems->first; + ml = mb->editelems->first; if (ml) { while (ml) { - next= ml->next; + next = ml->next; if (ml->flag & SELECT) { - if (mb->lastelem==ml) mb->lastelem= NULL; + if (mb->lastelem == ml) mb->lastelem = NULL; BLI_remlink(mb->editelems, ml); MEM_freeN(ml); } - ml= next; + ml = next; } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, mb); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, mb); DAG_id_tag_update(obedit->data, 0); } @@ -329,7 +329,7 @@ void MBALL_OT_delete_metaelems(wmOperatorType *ot) ot->poll = ED_operator_editmball; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /***************************** Hide operator *****************************/ @@ -337,20 +337,20 @@ void MBALL_OT_delete_metaelems(wmOperatorType *ot) /* Hide selected MetaElems */ static int hide_metaelems_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - MetaBall *mb= (MetaBall*)obedit->data; + Object *obedit = CTX_data_edit_object(C); + MetaBall *mb = (MetaBall *)obedit->data; MetaElem *ml; - const int invert= RNA_boolean_get(op->ptr, "unselected") ? SELECT : 0; + const int invert = RNA_boolean_get(op->ptr, "unselected") ? SELECT : 0; - ml= mb->editelems->first; + ml = mb->editelems->first; if (ml) { while (ml) { if ((ml->flag & SELECT) != invert) ml->flag |= MB_HIDE; - ml= ml->next; + ml = ml->next; } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, mb); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, mb); DAG_id_tag_update(obedit->data, 0); } @@ -369,7 +369,7 @@ void MBALL_OT_hide_metaelems(wmOperatorType *ot) ot->poll = ED_operator_editmball; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected"); @@ -380,18 +380,18 @@ void MBALL_OT_hide_metaelems(wmOperatorType *ot) /* Unhide all edited MetaElems */ static int reveal_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - MetaBall *mb= (MetaBall*)obedit->data; + Object *obedit = CTX_data_edit_object(C); + MetaBall *mb = (MetaBall *)obedit->data; MetaElem *ml; - ml= mb->editelems->first; + ml = mb->editelems->first; if (ml) { while (ml) { ml->flag &= ~MB_HIDE; - ml= ml->next; + ml = ml->next; } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, mb); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, mb); DAG_id_tag_update(obedit->data, 0); } @@ -410,69 +410,69 @@ void MBALL_OT_reveal_metaelems(wmOperatorType *ot) ot->poll = ED_operator_editmball; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* Select MetaElement with mouse click (user can select radius circle or * stiffness circle) */ int mouse_mball(bContext *C, const int mval[2], int extend) { - static MetaElem *startelem=NULL; - Object *obedit= CTX_data_edit_object(C); + static MetaElem *startelem = NULL; + Object *obedit = CTX_data_edit_object(C); ViewContext vc; - MetaBall *mb = (MetaBall*)obedit->data; - MetaElem *ml, *act=NULL; + MetaBall *mb = (MetaBall *)obedit->data; + MetaElem *ml, *act = NULL; int a, hits; - unsigned int buffer[4*MAXPICKBUF]; + unsigned int buffer[4 * MAXPICKBUF]; rcti rect; view3d_set_viewcontext(C, &vc); - rect.xmin = mval[0]-12; - rect.xmax = mval[0]+12; - rect.ymin = mval[1]-12; - rect.ymax = mval[1]+12; + rect.xmin = mval[0] - 12; + rect.xmax = mval[0] + 12; + rect.ymin = mval[1] - 12; + rect.ymax = mval[1] + 12; - hits= view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect); + hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect); /* does startelem exist? */ - ml= mb->editelems->first; + ml = mb->editelems->first; while (ml) { - if (ml==startelem) break; - ml= ml->next; + if (ml == startelem) break; + ml = ml->next; } - if (ml==NULL) startelem= mb->editelems->first; + if (ml == NULL) startelem = mb->editelems->first; - if (hits>0) { - ml= startelem; + if (hits > 0) { + ml = startelem; while (ml) { - for (a=0; aselcol1==buffer[ 4 * a + 3 ]) { + if (ml->selcol1 == buffer[4 * a + 3]) { ml->flag |= MB_SCALE_RAD; - act= ml; + act = ml; } - if (ml->selcol2==buffer[ 4 * a + 3 ]) { + if (ml->selcol2 == buffer[4 * a + 3]) { ml->flag &= ~MB_SCALE_RAD; - act= ml; + act = ml; } } if (act) break; - ml= ml->next; - if (ml==NULL) ml= mb->editelems->first; - if (ml==startelem) break; + ml = ml->next; + if (ml == NULL) ml = mb->editelems->first; + if (ml == startelem) break; } /* When some metaelem was found, then it is necessary to select or * deselect it. */ if (act) { - if (extend==0) { + if (extend == 0) { /* Deselect all existing metaelems */ - ml= mb->editelems->first; + ml = mb->editelems->first; while (ml) { ml->flag &= ~SELECT; - ml= ml->next; + ml = ml->next; } /* Select only metaelem clicked on */ act->flag |= SELECT; @@ -483,9 +483,9 @@ int mouse_mball(bContext *C, const int mval[2], int extend) else act->flag |= SELECT; } - mb->lastelem= act; + mb->lastelem = act; - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, mb); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb); return 1; } @@ -502,54 +502,54 @@ static void freeMetaElemlist(ListBase *lb) { MetaElem *ml, *next; - if (lb==NULL) return; + if (lb == NULL) return; - ml= lb->first; + ml = lb->first; while (ml) { - next= ml->next; + next = ml->next; BLI_remlink(lb, ml); MEM_freeN(ml); - ml= next; + ml = next; } - lb->first= lb->last= NULL; + lb->first = lb->last = NULL; } static void undoMball_to_editMball(void *lbu, void *lbe, void *UNUSED(obe)) { - ListBase *lb= lbu; - ListBase *editelems= lbe; + ListBase *lb = lbu; + ListBase *editelems = lbe; MetaElem *ml, *newml; freeMetaElemlist(editelems); /* copy 'undo' MetaElems to 'edit' MetaElems */ - ml= lb->first; + ml = lb->first; while (ml) { - newml= MEM_dupallocN(ml); + newml = MEM_dupallocN(ml); BLI_addtail(editelems, newml); - ml= ml->next; + ml = ml->next; } } static void *editMball_to_undoMball(void *lbe, void *UNUSED(obe)) { - ListBase *editelems= lbe; + ListBase *editelems = lbe; ListBase *lb; MetaElem *ml, *newml; /* allocate memory for undo ListBase */ - lb= MEM_callocN(sizeof(ListBase), "listbase undo"); - lb->first= lb->last= NULL; + lb = MEM_callocN(sizeof(ListBase), "listbase undo"); + lb->first = lb->last = NULL; /* copy contents of current ListBase to the undo ListBase */ - ml= editelems->first; + ml = editelems->first; while (ml) { - newml= MEM_dupallocN(ml); + newml = MEM_dupallocN(ml); BLI_addtail(lb, newml); - ml= ml->next; + ml = ml->next; } return lb; @@ -558,7 +558,7 @@ static void *editMball_to_undoMball(void *lbe, void *UNUSED(obe)) /* free undo ListBase of MetaElems */ static void free_undoMball(void *lbv) { - ListBase *lb= lbv; + ListBase *lb = lbv; freeMetaElemlist(lb); MEM_freeN(lb); @@ -566,8 +566,8 @@ static void free_undoMball(void *lbv) static ListBase *metaball_get_editelems(Object *ob) { - if (ob && ob->type==OB_MBALL) { - struct MetaBall *mb= (struct MetaBall*)ob->data; + if (ob && ob->type == OB_MBALL) { + struct MetaBall *mb = (struct MetaBall *)ob->data; return mb->editelems; } return NULL; @@ -576,7 +576,7 @@ static ListBase *metaball_get_editelems(Object *ob) static void *get_data(bContext *C) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); return metaball_get_editelems(obedit); } diff --git a/source/blender/editors/metaball/mball_ops.c b/source/blender/editors/metaball/mball_ops.c index 5d019cc49d9..1c77eba2019 100644 --- a/source/blender/editors/metaball/mball_ops.c +++ b/source/blender/editors/metaball/mball_ops.c @@ -75,9 +75,9 @@ void ED_keymap_metaball(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MBALL_OT_duplicate_metaelems", DKEY, KM_PRESS, KM_SHIFT, 0); kmi = WM_keymap_add_item(keymap, "MBALL_OT_select_all", AKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); kmi = WM_keymap_add_item(keymap, "MBALL_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); - RNA_enum_set(kmi->ptr, "action", SEL_INVERT); + RNA_enum_set(kmi->ptr, "action", SEL_INVERT); ED_object_generic_keymap(keyconf, keymap, 3); } diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index 43a4a9a1de9..9e44d5207c0 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -73,15 +73,15 @@ static void time_draw_sfra_efra(Scene *scene, View2D *v2d) */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); - glColor4f(0.0f, 0.0f, 0.0f, 0.4f); + glColor4f(0.0f, 0.0f, 0.0f, 0.4f); - if (PSFRA < PEFRA) { - glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax); - glRectf((float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); - } - else { - glRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); - } + if (PSFRA < PEFRA) { + glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax); + glRectf((float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); + } + else { + glRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); + } glDisable(GL_BLEND); UI_ThemeColorShade(TH_BACK, -60); @@ -90,14 +90,14 @@ static void time_draw_sfra_efra(Scene *scene, View2D *v2d) fdrawline((float)PEFRA, v2d->cur.ymin, (float)PEFRA, v2d->cur.ymax); } -#define CACHE_DRAW_HEIGHT 3.0f +#define CACHE_DRAW_HEIGHT 3.0f static void time_draw_cache(SpaceTime *stime, Object *ob) { PTCacheID *pid; ListBase pidlist; SpaceTimeCache *stc = stime->caches.first; - float yoffs=0.f; + float yoffs = 0.f; if (!(stime->cache_display & TIME_CACHE_DISPLAY) || (!ob)) return; @@ -106,27 +106,27 @@ static void time_draw_cache(SpaceTime *stime, Object *ob) /* iterate over pointcaches on the active object, * add spacetimecache and vertex array for each */ - for (pid=pidlist.first; pid; pid=pid->next) { + for (pid = pidlist.first; pid; pid = pid->next) { float col[4], *fp; int i, sta = pid->cache->startframe, end = pid->cache->endframe; - int len = (end - sta + 1)*4; + int len = (end - sta + 1) * 4; switch (pid->type) { case PTCACHE_TYPE_SOFTBODY: if (!(stime->cache_display & TIME_CACHE_SOFTBODY)) continue; break; case PTCACHE_TYPE_PARTICLES: - if (!(stime->cache_display & TIME_CACHE_PARTICLES)) continue; + if (!(stime->cache_display & TIME_CACHE_PARTICLES)) continue; break; case PTCACHE_TYPE_CLOTH: - if (!(stime->cache_display & TIME_CACHE_CLOTH)) continue; + if (!(stime->cache_display & TIME_CACHE_CLOTH)) continue; break; case PTCACHE_TYPE_SMOKE_DOMAIN: case PTCACHE_TYPE_SMOKE_HIGHRES: - if (!(stime->cache_display & TIME_CACHE_SMOKE)) continue; + if (!(stime->cache_display & TIME_CACHE_SMOKE)) continue; break; case PTCACHE_TYPE_DYNAMICPAINT: - if (!(stime->cache_display & TIME_CACHE_DYNAMICPAINT)) continue; + if (!(stime->cache_display & TIME_CACHE_DYNAMICPAINT)) continue; break; } @@ -134,7 +134,7 @@ static void time_draw_cache(SpaceTime *stime, Object *ob) continue; /* make sure we have stc with correct array length */ - if (stc == NULL || MEM_allocN_len(stc->array) != len*2*sizeof(float)) { + if (stc == NULL || MEM_allocN_len(stc->array) != len * 2 * sizeof(float)) { if (stc) { MEM_freeN(stc->array); } @@ -143,59 +143,59 @@ static void time_draw_cache(SpaceTime *stime, Object *ob) BLI_addtail(&stime->caches, stc); } - stc->array = MEM_callocN(len*2*sizeof(float), "SpaceTimeCache array"); + stc->array = MEM_callocN(len * 2 * sizeof(float), "SpaceTimeCache array"); } /* fill the vertex array with a quad for each cached frame */ - for (i=sta, fp=stc->array; i<=end; i++) { - if (pid->cache->cached_frames[i-sta]) { - fp[0] = (float)i-0.5f; + for (i = sta, fp = stc->array; i <= end; i++) { + if (pid->cache->cached_frames[i - sta]) { + fp[0] = (float)i - 0.5f; fp[1] = 0.0; - fp+=2; + fp += 2; - fp[0] = (float)i-0.5f; + fp[0] = (float)i - 0.5f; fp[1] = 1.0; - fp+=2; + fp += 2; - fp[0] = (float)i+0.5f; + fp[0] = (float)i + 0.5f; fp[1] = 1.0; - fp+=2; + fp += 2; - fp[0] = (float)i+0.5f; + fp[0] = (float)i + 0.5f; fp[1] = 0.0; - fp+=2; + fp += 2; } } glPushMatrix(); - glTranslatef(0.0, (float)V2D_SCROLL_HEIGHT+yoffs, 0.0); + glTranslatef(0.0, (float)V2D_SCROLL_HEIGHT + yoffs, 0.0); glScalef(1.0, CACHE_DRAW_HEIGHT, 0.0); switch (pid->type) { case PTCACHE_TYPE_SOFTBODY: - col[0] = 1.0; col[1] = 0.4; col[2] = 0.02; + col[0] = 1.0; col[1] = 0.4; col[2] = 0.02; col[3] = 0.1; break; case PTCACHE_TYPE_PARTICLES: - col[0] = 1.0; col[1] = 0.1; col[2] = 0.02; + col[0] = 1.0; col[1] = 0.1; col[2] = 0.02; col[3] = 0.1; break; case PTCACHE_TYPE_CLOTH: - col[0] = 0.1; col[1] = 0.1; col[2] = 0.75; + col[0] = 0.1; col[1] = 0.1; col[2] = 0.75; col[3] = 0.1; break; case PTCACHE_TYPE_SMOKE_DOMAIN: case PTCACHE_TYPE_SMOKE_HIGHRES: - col[0] = 0.2; col[1] = 0.2; col[2] = 0.2; + col[0] = 0.2; col[1] = 0.2; col[2] = 0.2; col[3] = 0.1; break; case PTCACHE_TYPE_DYNAMICPAINT: - col[0] = 1.0; col[1] = 0.1; col[2] = 0.75; + col[0] = 1.0; col[1] = 0.1; col[2] = 0.75; col[3] = 0.1; break; default: BLI_assert(0); - col[0] = 1.0; col[1] = 0.0; col[2] = 1.0; + col[0] = 1.0; col[1] = 0.0; col[2] = 1.0; col[3] = 0.1; } glColor4fv(col); @@ -206,13 +206,13 @@ static void time_draw_cache(SpaceTime *stime, Object *ob) col[3] = 0.4f; if (pid->cache->flag & PTCACHE_BAKED) { - col[0] -= 0.4f; col[1] -= 0.4f; col[2] -= 0.4f; + col[0] -= 0.4f; col[1] -= 0.4f; col[2] -= 0.4f; } glColor4fv(col); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, 0, stc->array); - glDrawArrays(GL_QUADS, 0, (fp-stc->array)/2); + glDrawArrays(GL_QUADS, 0, (fp - stc->array) / 2); glDisableClientState(GL_VERTEX_ARRAY); glDisable(GL_BLEND); @@ -240,7 +240,7 @@ static void time_cache_free(SpaceTime *stime) { SpaceTimeCache *stc; - for (stc= stime->caches.first; stc; stc=stc->next) { + for (stc = stime->caches.first; stc; stc = stc->next) { if (stc->array) { MEM_freeN(stc->array); stc->array = NULL; @@ -257,9 +257,9 @@ static void time_cache_refresh(SpaceTime *stime) } /* helper function - find actkeycolumn that occurs on cframe, or the nearest one if not found */ -static ActKeyColumn *time_cfra_find_ak (ActKeyColumn *ak, float cframe) +static ActKeyColumn *time_cfra_find_ak(ActKeyColumn *ak, float cframe) { - ActKeyColumn *akn= NULL; + ActKeyColumn *akn = NULL; /* sanity checks */ if (ak == NULL) @@ -267,9 +267,9 @@ static ActKeyColumn *time_cfra_find_ak (ActKeyColumn *ak, float cframe) /* check if this is a match, or whether it is in some subtree */ if (cframe < ak->cfra) - akn= time_cfra_find_ak(ak->left, cframe); + akn = time_cfra_find_ak(ak->left, cframe); else if (cframe > ak->cfra) - akn= time_cfra_find_ak(ak->right, cframe); + akn = time_cfra_find_ak(ak->right, cframe); /* if no match found (or found match), just use the current one */ if (akn == NULL) @@ -281,7 +281,7 @@ static ActKeyColumn *time_cfra_find_ak (ActKeyColumn *ak, float cframe) /* helper for time_draw_keyframes() */ static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel) { - bDopeSheet ads= {NULL}; + bDopeSheet ads = {NULL}; DLRBT_Tree keys; ActKeyColumn *ak; @@ -311,13 +311,13 @@ static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel) * - draw within a single GL block to be faster */ glBegin(GL_LINES); - for ( ak=time_cfra_find_ak(keys.root, v2d->cur.xmin); - (ak) && (ak->cfra <= v2d->cur.xmax); - ak=ak->next ) - { - glVertex2f(ak->cfra, v2d->tot.ymin); - glVertex2f(ak->cfra, v2d->tot.ymax); - } + for (ak = time_cfra_find_ak(keys.root, v2d->cur.xmin); + (ak) && (ak->cfra <= v2d->cur.xmax); + ak = ak->next) + { + glVertex2f(ak->cfra, v2d->tot.ymin); + glVertex2f(ak->cfra, v2d->tot.ymax); + } glEnd(); // GL_LINES /* free temp stuff */ @@ -327,25 +327,25 @@ static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel) /* draw keyframe lines for timeline */ static void time_draw_keyframes(const bContext *C, SpaceTime *stime, ARegion *ar) { - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - View2D *v2d= &ar->v2d; - short onlysel= (stime->flag & TIME_ONLYACTSEL); + Scene *scene = CTX_data_scene(C); + Object *ob = CTX_data_active_object(C); + View2D *v2d = &ar->v2d; + short onlysel = (stime->flag & TIME_ONLYACTSEL); /* draw scene keyframes first * - don't try to do this when only drawing active/selected data keyframes, * since this can become quite slow */ - if (scene && onlysel==0) { + if (scene && onlysel == 0) { /* set draw color */ glColor3ub(0xDD, 0xA7, 0x00); time_draw_idblock_keyframes(v2d, (ID *)scene, onlysel); } /* draw keyframes from selected objects - * - only do the active object if in posemode (i.e. showing only keyframes for the bones) - * OR the onlysel flag was set, which means that only active object's keyframes should - * be considered + * - only do the active object if in posemode (i.e. showing only keyframes for the bones) + * OR the onlysel flag was set, which means that only active object's keyframes should + * be considered */ glColor3ub(0xDD, 0xD7, 0x00); @@ -357,14 +357,14 @@ static void time_draw_keyframes(const bContext *C, SpaceTime *stime, ARegion *ar short active_done = 0; /* draw keyframes from all selected objects */ - CTX_DATA_BEGIN (C, Object*, obsel, selected_objects) + CTX_DATA_BEGIN (C, Object *, obsel, selected_objects) { /* last arg is 0, since onlysel doesn't apply here... */ time_draw_idblock_keyframes(v2d, (ID *)obsel, 0); /* if this object is the active one, set flag so that we don't draw again */ if (obsel == ob) - active_done= 1; + active_done = 1; } CTX_DATA_END; @@ -379,7 +379,7 @@ static void time_draw_keyframes(const bContext *C, SpaceTime *stime, ARegion *ar static void time_refresh(const bContext *UNUSED(C), ScrArea *sa) { /* find the main timeline region and refresh cache display*/ - ARegion *ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); if (ar) { SpaceTime *stime = (SpaceTime *)sa->spacedata.first; time_cache_refresh(stime); @@ -410,19 +410,19 @@ static void time_listener(ScrArea *sa, wmNotifier *wmn) ED_area_tag_refresh(sa); break; case ND_FRAME_RANGE: - { - ARegion *ar; - Scene *scene = wmn->reference; + { + ARegion *ar; + Scene *scene = wmn->reference; - for (ar= sa->regionbase.first; ar; ar= ar->next) { - if (ar->regiontype==RGN_TYPE_WINDOW) { - ar->v2d.tot.xmin = (float)(SFRA - 4); - ar->v2d.tot.xmax = (float)(EFRA + 4); - break; - } + for (ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar->regiontype == RGN_TYPE_WINDOW) { + ar->v2d.tot.xmin = (float)(SFRA - 4); + ar->v2d.tot.xmax = (float)(EFRA + 4); + break; } } - break; + } + break; } case NC_SPACE: switch (wmn->data) { @@ -456,13 +456,13 @@ static void time_main_area_init(wmWindowManager *wm, ARegion *ar) static void time_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - Scene *scene= CTX_data_scene(C); - SpaceTime *stime= CTX_wm_space_time(C); + Scene *scene = CTX_data_scene(C); + SpaceTime *stime = CTX_wm_space_time(C); Object *obact = CTX_data_active_object(C); - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; View2DGrid *grid; View2DScrollers *scrollers; - int unit, flag=0; + int unit, flag = 0; /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); @@ -471,9 +471,9 @@ static void time_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_ortho(v2d); /* grid */ - unit= (stime->flag & TIME_DRAWFRAMES)? V2D_UNIT_FRAMES: V2D_UNIT_SECONDS; - grid= UI_view2d_grid_calc(scene, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); - UI_view2d_grid_draw(v2d, grid, (V2D_VERTICAL_LINES|V2D_VERTICAL_AXIS)); + unit = (stime->flag & TIME_DRAWFRAMES) ? V2D_UNIT_FRAMES : V2D_UNIT_SECONDS; + grid = UI_view2d_grid_calc(scene, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); + UI_view2d_grid_draw(v2d, grid, (V2D_VERTICAL_LINES | V2D_VERTICAL_AXIS)); UI_view2d_grid_free(grid); /* start and end frame */ @@ -481,8 +481,8 @@ static void time_main_area_draw(const bContext *C, ARegion *ar) /* current frame */ flag = DRAWCFRA_WIDE; /* this is only really needed on frames where there's a keyframe, but this will do... */ - if ((stime->flag & TIME_DRAWFRAMES)==0) flag |= DRAWCFRA_UNIT_SECONDS; - if (stime->flag & TIME_CFRA_NUM) flag |= DRAWCFRA_SHOW_NUMBOX; + if ((stime->flag & TIME_DRAWFRAMES) == 0) flag |= DRAWCFRA_UNIT_SECONDS; + if (stime->flag & TIME_CFRA_NUM) flag |= DRAWCFRA_SHOW_NUMBOX; ANIM_draw_cfra(C, v2d, flag); UI_view2d_view_ortho(v2d); @@ -501,7 +501,7 @@ static void time_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -528,7 +528,7 @@ static void time_main_area_listener(ARegion *ar, wmNotifier *wmn) case ND_KEYINGSET: case ND_RENDER_OPTIONS: ED_region_tag_redraw(ar); - break; + break; } } } @@ -551,7 +551,7 @@ static void time_header_area_listener(ARegion *ar, wmNotifier *wmn) /* context changes */ switch (wmn->category) { case NC_SCREEN: - if (wmn->data==ND_ANIMPLAY) + if (wmn->data == ND_ANIMPLAY) ED_region_tag_redraw(ar); break; @@ -563,7 +563,7 @@ static void time_header_area_listener(ARegion *ar, wmNotifier *wmn) case ND_KEYINGSET: case ND_RENDER_OPTIONS: ED_region_tag_redraw(ar); - break; + break; } case NC_SPACE: @@ -577,57 +577,57 @@ static void time_header_area_listener(ARegion *ar, wmNotifier *wmn) static SpaceLink *time_new(const bContext *C) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); ARegion *ar; SpaceTime *stime; - stime= MEM_callocN(sizeof(SpaceTime), "inittime"); + stime = MEM_callocN(sizeof(SpaceTime), "inittime"); - stime->spacetype= SPACE_TIME; + stime->spacetype = SPACE_TIME; stime->flag |= TIME_DRAWFRAMES; /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for time"); + ar = MEM_callocN(sizeof(ARegion), "header for time"); BLI_addtail(&stime->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_BOTTOM; + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_BOTTOM; /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for time"); + ar = MEM_callocN(sizeof(ARegion), "main area for time"); BLI_addtail(&stime->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; + ar->regiontype = RGN_TYPE_WINDOW; ar->v2d.tot.xmin = (float)(SFRA - 4); ar->v2d.tot.ymin = 0.0f; ar->v2d.tot.xmax = (float)(EFRA + 4); ar->v2d.tot.ymax = 50.0f; - ar->v2d.cur= ar->v2d.tot; + ar->v2d.cur = ar->v2d.tot; - ar->v2d.min[0]= 1.0f; - ar->v2d.min[1]= 50.0f; + ar->v2d.min[0] = 1.0f; + ar->v2d.min[1] = 50.0f; - ar->v2d.max[0]= MAXFRAMEF; - ar->v2d.max[1]= 50.0; + ar->v2d.max[0] = MAXFRAMEF; + ar->v2d.max[1] = 50.0; - ar->v2d.minzoom= 0.1f; - ar->v2d.maxzoom= 10.0; + ar->v2d.minzoom = 0.1f; + ar->v2d.maxzoom = 10.0; - ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL); ar->v2d.align |= V2D_ALIGN_NO_NEG_Y; ar->v2d.keepofs |= V2D_LOCKOFS_Y; ar->v2d.keepzoom |= V2D_LOCKZOOM_Y; - return (SpaceLink*)stime; + return (SpaceLink *)stime; } /* not spacelink itself */ static void time_free(SpaceLink *sl) { - SpaceTime *stime= (SpaceTime *)sl; + SpaceTime *stime = (SpaceTime *)sl; time_cache_free(stime); } @@ -636,20 +636,20 @@ static void time_free(SpaceLink *sl) /* validate spacedata, add own area level handlers */ static void time_init(wmWindowManager *UNUSED(wm), ScrArea *sa) { - SpaceTime *stime= (SpaceTime *)sa->spacedata.first; + SpaceTime *stime = (SpaceTime *)sa->spacedata.first; time_cache_free(stime); /* enable all cache display */ stime->cache_display |= TIME_CACHE_DISPLAY; - stime->cache_display |= (TIME_CACHE_SOFTBODY|TIME_CACHE_PARTICLES); - stime->cache_display |= (TIME_CACHE_CLOTH|TIME_CACHE_SMOKE|TIME_CACHE_DYNAMICPAINT); + stime->cache_display |= (TIME_CACHE_SOFTBODY | TIME_CACHE_PARTICLES); + stime->cache_display |= (TIME_CACHE_CLOTH | TIME_CACHE_SMOKE | TIME_CACHE_DYNAMICPAINT); } static SpaceLink *time_duplicate(SpaceLink *sl) { - SpaceTime *stime= (SpaceTime *)sl; - SpaceTime *stimen= MEM_dupallocN(stime); + SpaceTime *stime = (SpaceTime *)sl; + SpaceTime *stimen = MEM_dupallocN(stime); stimen->caches.first = stimen->caches.last = NULL; @@ -660,41 +660,41 @@ static SpaceLink *time_duplicate(SpaceLink *sl) /* it defines all callbacks to maintain spaces */ void ED_spacetype_time(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype time"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype time"); ARegionType *art; - st->spaceid= SPACE_TIME; + st->spaceid = SPACE_TIME; strncpy(st->name, "Timeline", BKE_ST_MAXNAME); - st->new= time_new; - st->free= time_free; - st->init= time_init; - st->duplicate= time_duplicate; - st->operatortypes= time_operatortypes; - st->keymap= NULL; - st->listener= time_listener; - st->refresh= time_refresh; + st->new = time_new; + st->free = time_free; + st->init = time_init; + st->duplicate = time_duplicate; + st->operatortypes = time_operatortypes; + st->keymap = NULL; + st->listener = time_listener; + st->refresh = time_refresh; /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype time region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype time region"); art->regionid = RGN_TYPE_WINDOW; - art->keymapflag= ED_KEYMAP_VIEW2D|ED_KEYMAP_MARKERS|ED_KEYMAP_ANIMATION|ED_KEYMAP_FRAMES; + art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES; - art->init= time_main_area_init; - art->draw= time_main_area_draw; - art->listener= time_main_area_listener; - art->keymap= time_keymap; + art->init = time_main_area_init; + art->draw = time_main_area_draw; + art->listener = time_main_area_listener; + art->keymap = time_keymap; BLI_addhead(&st->regiontypes, art); /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype time region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype time region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; - art->init= time_header_area_init; - art->draw= time_header_area_draw; - art->listener= time_header_area_listener; + art->init = time_header_area_init; + art->draw = time_header_area_draw; + art->listener = time_header_area_listener; BLI_addhead(&st->regiontypes, art); BKE_spacetype_register(st); diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c index 1c1f7a69865..189c8bfc7d0 100644 --- a/source/blender/editors/space_time/time_ops.c +++ b/source/blender/editors/space_time/time_ops.c @@ -47,35 +47,35 @@ #include "time_intern.h" /* ****************** Start/End Frame Operators *******************************/ -static int time_set_sfra_exec (bContext *C, wmOperator *UNUSED(op)) +static int time_set_sfra_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); int frame; if (scene == NULL) return OPERATOR_CANCELLED; - frame= CFRA; + frame = CFRA; /* if Preview Range is defined, set the 'start' frame for that */ if (PRVRANGEON) - scene->r.psfra= frame; + scene->r.psfra = frame; else - scene->r.sfra= frame; + scene->r.sfra = frame; if (PEFRA < frame) { if (PRVRANGEON) - scene->r.pefra= frame; + scene->r.pefra = frame; else - scene->r.efra= frame; + scene->r.efra = frame; } - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); return OPERATOR_FINISHED; } -static void TIME_OT_start_frame_set (wmOperatorType *ot) +static void TIME_OT_start_frame_set(wmOperatorType *ot) { /* identifiers */ ot->name = "Set Start Frame"; @@ -87,39 +87,39 @@ static void TIME_OT_start_frame_set (wmOperatorType *ot) ot->poll = ED_operator_timeline_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int time_set_efra_exec (bContext *C, wmOperator *UNUSED(op)) +static int time_set_efra_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); int frame; if (scene == NULL) return OPERATOR_CANCELLED; - frame= CFRA; + frame = CFRA; /* if Preview Range is defined, set the 'end' frame for that */ if (PRVRANGEON) - scene->r.pefra= frame; + scene->r.pefra = frame; else - scene->r.efra= frame; + scene->r.efra = frame; if (PSFRA > frame) { if (PRVRANGEON) - scene->r.psfra= frame; + scene->r.psfra = frame; else - scene->r.sfra= frame; + scene->r.sfra = frame; } - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); return OPERATOR_FINISHED; } -static void TIME_OT_end_frame_set (wmOperatorType *ot) +static void TIME_OT_end_frame_set(wmOperatorType *ot) { /* identifiers */ ot->name = "Set End Frame"; @@ -131,16 +131,16 @@ static void TIME_OT_end_frame_set (wmOperatorType *ot) ot->poll = ED_operator_timeline_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************ View All Operator *******************************/ -static int time_view_all_exec (bContext *C, wmOperator *UNUSED(op)) +static int time_view_all_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); - View2D *v2d= (ar) ? &ar->v2d : NULL; + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); + View2D *v2d = (ar) ? &ar->v2d : NULL; float extra; if (ELEM(NULL, scene, ar)) @@ -151,7 +151,7 @@ static int time_view_all_exec (bContext *C, wmOperator *UNUSED(op)) v2d->cur.xmax = (float)PEFRA; /* we need an extra "buffer" factor on either side so that the endpoints are visible */ - extra= 0.01f * (v2d->cur.xmax - v2d->cur.xmin); + extra = 0.01f * (v2d->cur.xmax - v2d->cur.xmin); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; @@ -161,7 +161,7 @@ static int time_view_all_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -static void TIME_OT_view_all (wmOperatorType *ot) +static void TIME_OT_view_all(wmOperatorType *ot) { /* identifiers */ ot->name = "View All"; @@ -173,7 +173,7 @@ static void TIME_OT_view_all (wmOperatorType *ot) ot->poll = ED_operator_timeline_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************** registration **********************************/