diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-24 10:38:07 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-24 10:38:07 +0400 |
commit | ab4a2aaf4a4b2b4e416aa1f113b30362cbe0dec3 (patch) | |
tree | 81af4c18519181490074508dbe9a8d515eab634f /source/blender/editors/space_image | |
parent | 5a90ea77bc1333efe4e1e54984a080550ed3f707 (diff) |
style cleanup: follow style guide for formatting of if/for/while loops, and else if's
Diffstat (limited to 'source/blender/editors/space_image')
-rw-r--r-- | source/blender/editors/space_image/image_buttons.c | 148 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_draw.c | 126 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 318 | ||||
-rw-r--r-- | source/blender/editors/space_image/space_image.c | 96 |
4 files changed, 345 insertions, 343 deletions
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 054d342ce4b..dbee8f207ec 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -101,15 +101,15 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf, str[0]= 0; - if(ima==NULL) return; + if (ima==NULL) return; - if(ibuf==NULL) { + if (ibuf==NULL) { ofs+= sprintf(str, "Can't Load Image"); } else { - if(ima->source==IMA_SRC_MOVIE) { + if (ima->source==IMA_SRC_MOVIE) { ofs+= sprintf(str, "Movie"); - if(ima->anim) + if (ima->anim) ofs+= sprintf(str+ofs, "%d frs", IMB_anim_get_duration(ima->anim, IMB_TC_RECORD_RUN)); } else @@ -117,34 +117,34 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf, ofs+= sprintf(str+ofs, ": size %d x %d,", ibuf->x, ibuf->y); - if(ibuf->rect_float) { - if(ibuf->channels!=4) { + if (ibuf->rect_float) { + if (ibuf->channels!=4) { ofs+= sprintf(str+ofs, "%d float channel(s)", ibuf->channels); } - else if(ibuf->planes == R_IMF_PLANES_RGBA) + else if (ibuf->planes == R_IMF_PLANES_RGBA) ofs+= sprintf(str+ofs, " RGBA float"); else ofs+= sprintf(str+ofs, " RGB float"); } else { - if(ibuf->planes == R_IMF_PLANES_RGBA) + if (ibuf->planes == R_IMF_PLANES_RGBA) ofs+= sprintf(str+ofs, " RGBA byte"); else ofs+= sprintf(str+ofs, " RGB byte"); } - if(ibuf->zbuf || ibuf->zbuf_float) + if (ibuf->zbuf || ibuf->zbuf_float) ofs+= sprintf(str+ofs, " + Z"); - if(ima->source==IMA_SRC_SEQUENCE) { + if (ima->source==IMA_SRC_SEQUENCE) { char *file= BLI_last_slash(ibuf->name); - if(file==NULL) file= ibuf->name; + if (file==NULL) file= ibuf->name; else file++; ofs+= sprintf(str+ofs, ", %s", file); } } /* the frame number, even if we cant */ - if(ima->source==IMA_SRC_SEQUENCE) { + if (ima->source==IMA_SRC_SEQUENCE) { /* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */ const int framenr= BKE_image_user_get_frame(iuser, CFRA, 0); ofs+= sprintf(str+ofs, ", Frame: %d", framenr); @@ -158,10 +158,10 @@ struct ImageUser *ntree_get_active_iuser(bNodeTree *ntree) { bNode *node; - if(ntree) - for(node= ntree->nodes.first; node; node= node->next) - if( ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) - if(node->flag & NODE_DO_OUTPUT) + if (ntree) + for (node= ntree->nodes.first; node; node= node->next) + if ( ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) + if (node->flag & NODE_DO_OUTPUT) return node->storage; return NULL; } @@ -196,8 +196,8 @@ static void image_panel_curves(const bContext *C, Panel *pa) ibuf= ED_space_image_acquire_buffer(sima, &lock); - if(ibuf) { - if(sima->cumap==NULL) + if (ibuf) { + if (sima->cumap==NULL) sima->cumap= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); /* curvemap black/white levels only works for RGBA */ @@ -220,12 +220,12 @@ void image_preview_event(int event) { int exec= 0; - if(event==0) { + if (event==0) { G.scene->r.scemode &= ~R_COMP_CROP; exec= 1; } else { - if(image_preview_active(curarea, NULL, NULL)) { + if (image_preview_active(curarea, NULL, NULL)) { G.scene->r.scemode |= R_COMP_CROP; exec= 1; } @@ -233,7 +233,7 @@ void image_preview_event(int event) G.scene->r.scemode &= ~R_COMP_CROP; } - if(exec && G.scene->nodetree) { + if (exec && G.scene->nodetree) { /* should work when no node editor in screen..., so we execute right away */ ntreeCompositTagGenerators(G.scene->nodetree); @@ -267,7 +267,7 @@ static void preview_cb(struct ScrArea *sa, struct uiBlock *block) int winy= (G.scene->r.size*G.scene->r.ysch)/100; int mval[2]; - if(G.scene->r.mode & R_BORDER) { + if (G.scene->r.mode & R_BORDER) { winx*= (G.scene->r.border.xmax - G.scene->r.border.xmin); winy*= (G.scene->r.border.ymax - G.scene->r.border.ymin); } @@ -308,14 +308,14 @@ static int is_preview_allowed(ScrArea *cur) ScrArea *sa; /* check if another areawindow has preview set */ - for(sa=G.curscreen->areabase.first; sa; sa= sa->next) { - if(sa!=cur && sa->spacetype==SPACE_IMAGE) { - if(image_preview_active(sa, NULL, NULL)) + for (sa=G.curscreen->areabase.first; sa; sa= sa->next) { + if (sa!=cur && sa->spacetype==SPACE_IMAGE) { + if (image_preview_active(sa, NULL, NULL)) return 0; } } /* check image type */ - if(sima->image==NULL || sima->image->type!=IMA_TYPE_COMPOSITE) + if (sima->image==NULL || sima->image->type!=IMA_TYPE_COMPOSITE) return 0; return 1; @@ -328,7 +328,7 @@ static void image_panel_preview(ScrArea *sa, short cntrl) // IMAGE_HANDLER_PREVI SpaceImage *sima= sa->spacedata.first; int ofsx, ofsy; - if(is_preview_allowed(sa)==0) { + if (is_preview_allowed(sa)==0) { rem_blockhandler(sa, IMAGE_HANDLER_PREVIEW); G.scene->r.scemode &= ~R_COMP_CROP; /* quite weak */ return; @@ -340,7 +340,7 @@ static void image_panel_preview(ScrArea *sa, short cntrl) // IMAGE_HANDLER_PREVI ofsx= -150+(sa->winx/2)/sima->blockscale; ofsy= -100+(sa->winy/2)/sima->blockscale; - if(uiNewPanel(C, ar, block, "Preview", "Image", ofsx, ofsy, 300, 200)==0) return; + if (uiNewPanel(C, ar, block, "Preview", "Image", ofsx, ofsy, 300, 200)==0) return; uiBlockSetDrawExtraFunc(block, preview_cb); @@ -360,7 +360,7 @@ static char *slot_menu(void) strcpy(str, "Slot %t"); a= strlen(str); - for(slot=0; slot<IMA_MAX_RENDER_SLOT; slot++) + for (slot=0; slot<IMA_MAX_RENDER_SLOT; slot++) a += sprintf(str+a, "|Slot %d %%x%d", slot+1, slot); return str; @@ -378,15 +378,15 @@ static char *layer_menu(RenderResult *rr, short *UNUSED(curlay)) a= strlen(str); /* compo result */ - if(rr->rectf) { + if (rr->rectf) { a+= sprintf(str+a, "|Composite %%x0"); nr= 1; } - else if(rr->rect32) { + else if (rr->rect32) { a+= sprintf(str+a, "|Sequence %%x0"); nr= 1; } - for(rl= rr->layers.first; rl; rl= rl->next, nr++) { + for (rl= rr->layers.first; rl; rl= rl->next, nr++) { a+= sprintf(str+a, "|%s %%x%d", rl->name, nr); } @@ -407,16 +407,16 @@ static char *pass_menu(RenderLayer *rl, short *curpass) a= strlen(str); /* rendered results don't have a Combined pass */ - if(rl==NULL || rl->rectf) { + if (rl==NULL || rl->rectf) { a+= sprintf(str+a, "|Combined %%x0"); nr= 1; } - if(rl) - for(rpass= rl->passes.first; rpass; rpass= rpass->next, nr++) + if (rl) + for (rpass= rl->passes.first; rpass; rpass= rpass->next, nr++) a+= sprintf(str+a, "|%s %%x%d", rpass->name, nr); - if(*curpass >= nr) + if (*curpass >= nr) *curpass= 0; return str; @@ -428,7 +428,7 @@ static void set_frames_cb(bContext *C, void *ima_v, void *iuser_v) Image *ima= ima_v; ImageUser *iuser= iuser_v; - if(ima->anim) { + if (ima->anim) { iuser->frames = IMB_anim_get_duration(ima->anim, IMB_TC_RECORD_RUN); BKE_image_user_calc_frame(iuser, scene->r.cfra, 0); } @@ -448,10 +448,10 @@ static void image_multi_inclay_cb(bContext *C, void *rr_v, void *iuser_v) ImageUser *iuser= iuser_v; int tot= BLI_countlist(&rr->layers); - if(rr->rectf || rr->rect32) + if (rr->rectf || rr->rect32) tot++; /* fake compo/sequencer layer */ - if(iuser->layer<tot-1) { + if (iuser->layer<tot-1) { iuser->layer++; BKE_image_multilayer_index(rr, iuser); WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL); @@ -461,7 +461,7 @@ static void image_multi_declay_cb(bContext *C, void *rr_v, void *iuser_v) { ImageUser *iuser= iuser_v; - if(iuser->layer>0) { + if (iuser->layer>0) { iuser->layer--; BKE_image_multilayer_index(rr_v, iuser); WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL); @@ -473,13 +473,13 @@ static void image_multi_incpass_cb(bContext *C, void *rr_v, void *iuser_v) ImageUser *iuser= iuser_v; RenderLayer *rl= BLI_findlink(&rr->layers, iuser->layer); - if(rl) { + if (rl) { int tot= BLI_countlist(&rl->passes); - if(rr->rectf || rr->rect32) + if (rr->rectf || rr->rect32) tot++; /* fake compo/sequencer layer */ - if(iuser->pass<tot-1) { + if (iuser->pass<tot-1) { iuser->pass++; BKE_image_multilayer_index(rr, iuser); WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL); @@ -490,7 +490,7 @@ static void image_multi_decpass_cb(bContext *C, void *rr_v, void *iuser_v) { ImageUser *iuser= iuser_v; - if(iuser->pass>0) { + if (iuser->pass>0) { iuser->pass--; BKE_image_multilayer_index(rr_v, iuser); WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL); @@ -530,21 +530,21 @@ static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, Image wmenu3= (3*w)/6; /* menu buts */ - if(render_slot) { + if (render_slot) { strp= slot_menu(); but = uiDefButS(block, MENU, 0, strp, 0, 0, wmenu1, UI_UNIT_Y, render_slot, 0,0,0,0, "Select Slot"); uiButSetFunc(but, image_multi_cb, rr, iuser); MEM_freeN(strp); } - if(rr) { + if (rr) { strp= layer_menu(rr, &iuser->layer); but = uiDefButS(block, MENU, 0, strp, 0, 0, wmenu2, UI_UNIT_Y, &iuser->layer, 0,0,0,0, "Select Layer"); uiButSetFunc(but, image_multi_cb, rr, iuser); MEM_freeN(strp); layer = iuser->layer; - if(rr->rectf || rr->rect32) + if (rr->rectf || rr->rect32) layer--; /* fake compo/sequencer layer */ rl= BLI_findlink(&rr->layers, layer); /* return NULL is meant to be */ @@ -564,9 +564,9 @@ static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, row= uiLayoutRow(layout, 1); - if(rr==NULL || iuser==NULL) + if (rr==NULL || iuser==NULL) return; - if(rr->layers.first==NULL) { + if (rr->layers.first==NULL) { uiItemL(row, "No Layers in Render Result", ICON_NONE); return; } @@ -626,17 +626,17 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char char str[128]; void *lock; - if(!ptr->data) + if (!ptr->data) return; prop= RNA_struct_find_property(ptr, propname); - if(!prop) { + if (!prop) { printf("%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); return; } - if(RNA_property_type(prop) != PROP_POINTER) { + if (RNA_property_type(prop) != PROP_POINTER) { printf("%s: expected pointer property for %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); return; @@ -655,13 +655,13 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char uiLayoutSetContextPointer(layout, "edit_image", &imaptr); - if(!compact) + if (!compact) uiTemplateID(layout, C, ptr, propname, "IMAGE_OT_new", "IMAGE_OT_open", NULL); - if(ima) { + if (ima) { uiBlockSetNFunc(block, rna_update_cb, MEM_dupallocN(cb), NULL); - if(ima->source == IMA_SRC_VIEWER) { + if (ima->source == IMA_SRC_VIEWER) { ibuf= BKE_image_acquire_ibuf(ima, iuser, &lock); image_info(scene, iuser, ima, ibuf, str); BKE_image_release_ibuf(ima, lock); @@ -669,18 +669,18 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char uiItemL(layout, ima->id.name+2, ICON_NONE); uiItemL(layout, str, ICON_NONE); - if(ima->type==IMA_TYPE_COMPOSITE) { + if (ima->type==IMA_TYPE_COMPOSITE) { // XXX not working yet #if 0 iuser= ntree_get_active_iuser(scene->nodetree); - if(iuser) { + if (iuser) { uiBlockBeginAlign(block); uiDefIconTextBut(block, BUT, B_SIMA_RECORD, ICON_REC, "Record", 10,120,100,20, 0, 0, 0, 0, 0, ""); uiDefIconTextBut(block, BUT, B_SIMA_PLAY, ICON_PLAY, "Play", 110,120,100,20, 0, 0, 0, 0, 0, ""); but = uiDefBut(block, BUT, B_NOP, "Free Cache", 210,120,100,20, 0, 0, 0, 0, 0, ""); uiButSetFunc(but, image_freecache_cb, ima, NULL); - if(iuser->frames) + if (iuser->frames) BLI_snprintf(str, sizeof(str), "(%d) Frames:", iuser->framenr); else strcpy(str, "Frames:"); uiBlockBeginAlign(block); @@ -689,7 +689,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char } #endif } - else if(ima->type==IMA_TYPE_R_RESULT) { + else if (ima->type==IMA_TYPE_R_RESULT) { /* browse layer/passes */ Render *re= RE_GetRender(scene->id.name); RenderResult *rr= RE_AcquireResultRead(re); @@ -700,7 +700,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char else { uiItemR(layout, &imaptr, "source", 0, NULL, ICON_NONE); - if(ima->source != IMA_SRC_GENERATED) { + if (ima->source != IMA_SRC_GENERATED) { row= uiLayoutRow(layout, 1); if (ima->packedfile) uiItemO(row, "", ICON_PACKAGE, "image.unpack"); @@ -716,8 +716,8 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char // XXX what was this for? #if 0 /* check for re-render, only buttons */ - if(imagechanged==B_IMAGECHANGED) { - if(iuser->flag & IMA_ANIM_REFRESHED) { + if (imagechanged==B_IMAGECHANGED) { + if (iuser->flag & IMA_ANIM_REFRESHED) { iuser->flag &= ~IMA_ANIM_REFRESHED; WM_event_add_notifier(C, NC_IMAGE, ima); } @@ -725,11 +725,11 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char #endif /* multilayer? */ - if(ima->type==IMA_TYPE_MULTILAYER && ima->rr) { + if (ima->type==IMA_TYPE_MULTILAYER && ima->rr) { uiblock_layer_pass_arrow_buttons(layout, ima->rr, iuser, NULL); } - else if(ima->source != IMA_SRC_GENERATED) { - if(compact == 0) { + else if (ima->source != IMA_SRC_GENERATED) { + if (compact == 0) { ibuf= BKE_image_acquire_ibuf(ima, iuser, &lock); image_info(scene, iuser, ima, ibuf, str); BKE_image_release_ibuf(ima, lock); @@ -737,8 +737,8 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char } } - if(ima->source != IMA_SRC_GENERATED) { - if(compact == 0) { /* background image view doesnt need these */ + if (ima->source != IMA_SRC_GENERATED) { + if (compact == 0) { /* background image view doesnt need these */ uiItemS(layout); split= uiLayoutSplit(layout, 0, 0); @@ -755,7 +755,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char } } - if(ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { + if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { uiItemS(layout); split= uiLayoutSplit(layout, 0, 0); @@ -764,7 +764,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char BLI_snprintf(str, sizeof(str), "(%d) Frames", iuser->framenr); uiItemR(col, userptr, "frame_duration", 0, str, ICON_NONE); - if(ima->anim) { + if (ima->anim) { block= uiLayoutGetBlock(col); but = uiDefBut(block, BUT, 0, "Match Movie Length", 0, 0, UI_UNIT_X*2, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Set the number of frames to match the movie or sequence"); uiButSetFunc(but, set_frames_cb, ima, iuser); @@ -780,7 +780,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char uiItemR(col, userptr, "use_auto_refresh", 0, NULL, ICON_NONE); uiItemR(col, userptr, "use_cyclic", 0, NULL, ICON_NONE); } - else if(ima->source==IMA_SRC_GENERATED) { + else if (ima->source==IMA_SRC_GENERATED) { split= uiLayoutSplit(layout, 0, 0); col= uiLayoutColumn(split, 1); @@ -818,7 +818,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr) uiItemR(sub, imfptr, "color_mode", UI_ITEM_R_EXPAND, "Color", ICON_NONE); /* only display depth setting if multiple depths can be used */ - if((ELEM6(depth_ok, + if ((ELEM6(depth_ok, R_IMF_CHAN_DEPTH_1, R_IMF_CHAN_DEPTH_8, R_IMF_CHAN_DEPTH_12, @@ -877,7 +877,7 @@ void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser RenderResult *rr; /* render layers and passes */ - if(ima && iuser) { + if (ima && iuser) { const float dpi_fac= UI_DPI_FAC; rr= BKE_image_acquire_renderresult(scene, ima); uiblock_layer_pass_buttons(layout, rr, iuser, 160 * dpi_fac, (ima->type==IMA_TYPE_R_RESULT)? &ima->render_slot: NULL); @@ -909,7 +909,7 @@ static int image_properties(bContext *C, wmOperator *UNUSED(op)) ScrArea *sa= CTX_wm_area(C); ARegion *ar= image_has_buttons_region(sa); - if(ar) + if (ar) ED_region_toggle_hidden(C, ar); return OPERATOR_FINISHED; @@ -933,7 +933,7 @@ static int image_scopes(bContext *C, wmOperator *UNUSED(op)) ScrArea *sa= CTX_wm_area(C); ARegion *ar= image_has_scope_region(sa); - if(ar) + if (ar) ED_region_toggle_hidden(C, ar); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 3c2ebea5c28..59ca1925abf 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -85,9 +85,9 @@ static void image_verify_buffer_float(Image *ima, ImBuf *ibuf, int color_manage) * NOTE: if float buffer changes, we have to manually remove the rect */ - if(ibuf->rect_float && (ibuf->rect==NULL || (ibuf->userflags & IB_RECT_INVALID)) ) { - if(color_manage) { - if(ima && ima->source == IMA_SRC_VIEWER) + if (ibuf->rect_float && (ibuf->rect==NULL || (ibuf->userflags & IB_RECT_INVALID)) ) { + if (color_manage) { + if (ima && ima->source == IMA_SRC_VIEWER) ibuf->profile = IB_PROFILE_LINEAR_RGB; } else @@ -103,7 +103,7 @@ static void draw_render_info(Scene *scene, Image *ima, ARegion *ar) rr= BKE_image_acquire_renderresult(scene, ima); - if(rr && rr->text) { + if (rr && rr->text) { ED_region_info_draw(ar, rr->text, 1, 0.25); } @@ -147,14 +147,14 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); - if(zp) { + if (zp) { glColor3ub(255, 255, 255); BLI_snprintf(str, sizeof(str), " Z:%-.4f |", 0.5f+0.5f*(((float)*zp)/(float)0x7fffffff)); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); } - if(zpf) { + if (zpf) { glColor3ub(255, 255, 255); BLI_snprintf(str, sizeof(str), " Z:%-.3f |", *zpf); BLF_position(blf_mono_font, dx, 6, 0); @@ -162,7 +162,7 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int dx += BLF_width(blf_mono_font, str); } - if(channels >= 3) { + if (channels >= 3) { glColor3ubv(red); if (fp) BLI_snprintf(str, sizeof(str), " R:%-.4f", fp[0]); @@ -196,7 +196,7 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); - if(channels == 4) { + if (channels == 4) { glColor3ub(255, 255, 255); if (fp) BLI_snprintf(str, sizeof(str), " A:%-.4f", fp[3]); @@ -278,7 +278,7 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int dx += 35; glColor3ub(255, 255, 255); - if(channels == 1) { + if (channels == 1) { if (fp) { rgb_to_hsv(fp[0], fp[0], fp[0], &hue, &sat, &val); rgb_to_yuv(fp[0], fp[0], fp[0], &lum, &u, &v); @@ -298,7 +298,7 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); } - else if(channels >= 3) { + else if (channels >= 3) { if (fp) { rgb_to_hsv(fp[0], fp[1], fp[2], &hue, &sat, &val); rgb_to_yuv(fp[0], fp[1], fp[2], &lum, &u, &v); @@ -349,16 +349,16 @@ static void draw_image_grid(ARegion *ar, float zoomx, float zoomy) /* gridsize adapted to zoom level */ gridsize= 0.5f*(zoomx+zoomy); - if(gridsize<=0.0f) return; + if (gridsize<=0.0f) return; - if(gridsize<1.0f) { - while(gridsize<1.0f) { + if (gridsize<1.0f) { + while (gridsize<1.0f) { gridsize*= 4.0f; gridstep*= 4.0f; } } else { - while(gridsize>=4.0f) { + while (gridsize>=4.0f) { gridsize/= 4.0f; gridstep/= 4.0f; } @@ -371,7 +371,7 @@ static void draw_image_grid(ARegion *ar, float zoomx, float zoomy) fac= 0.0f; glBegin(GL_LINES); - while(fac<1.0f) { + while (fac<1.0f) { glVertex2f(x1, y1*(1.0f-fac) + y2*fac); glVertex2f(x2, y1*(1.0f-fac) + y2*fac); glVertex2f(x1*(1.0f-fac) + x2*fac, y1); @@ -383,7 +383,7 @@ static void draw_image_grid(ARegion *ar, float zoomx, float zoomy) UI_ThemeColor(TH_BACK); fac= 0.0f; - while(fac<1.0f) { + while (fac<1.0f) { glVertex2f(x1, y1*(1.0f-fac) + y2*fac); glVertex2f(x2, y1*(1.0f-fac) + y2*fac); glVertex2f(x1*(1.0f-fac) + x2*fac, y1); @@ -421,7 +421,7 @@ static void sima_draw_alpha_pixels(float x1, float y1, int rectx, int recty, uns { /* swap bytes, so alpha is most significant one, then just draw it as luminance int */ - if(ENDIAN_ORDER == B_ENDIAN) + if (ENDIAN_ORDER == B_ENDIAN) glPixelStorei(GL_UNPACK_SWAP_BYTES, 1); glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_LUMINANCE, GL_UNSIGNED_INT, recti); @@ -433,7 +433,7 @@ static void sima_draw_alpha_pixelsf(float x1, float y1, int rectx, int recty, fl float *trectf= MEM_mallocN(rectx*recty*4, "temp"); int a, b; - for(a= rectx*recty -1, b= 4*a+3; a>=0; a--, b-=4) + for (a= rectx*recty -1, b= 4*a+3; a>=0; a--, b-=4) trectf[a]= rectf[b]; glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_LUMINANCE, GL_FLOAT, trectf); @@ -473,7 +473,7 @@ static void sima_draw_zbuffloat_pixels(Scene *scene, float x1, float y1, int rec float bias, scale, *rectf, clipend; int a; - if(scene->camera && scene->camera->type==OB_CAMERA) { + if (scene->camera && scene->camera->type==OB_CAMERA) { bias= ((Camera *)scene->camera->data)->clipsta; clipend= ((Camera *)scene->camera->data)->clipend; scale= 1.0f/(clipend-bias); @@ -485,10 +485,10 @@ static void sima_draw_zbuffloat_pixels(Scene *scene, float x1, float y1, int rec } rectf= MEM_mallocN(rectx*recty*4, "temp"); - for(a= rectx*recty -1; a>=0; a--) { - if(rect_float[a]>clipend) + for (a= rectx*recty -1; a>=0; a--) { + if (rect_float[a]>clipend) rectf[a]= 0.0f; - else if(rect_float[a]<bias) + else if (rect_float[a]<bias) rectf[a]= 1.0f; else { rectf[a]= 1.0f - (rect_float[a]-bias)*scale; @@ -512,22 +512,22 @@ static void draw_image_buffer(SpaceImage *sima, ARegion *ar, Scene *scene, Image UI_view2d_to_region_no_clip(&ar->v2d, fx, fy, &x, &y); /* this part is generic image display */ - if(sima->flag & SI_SHOW_ALPHA) { - if(ibuf->rect) + if (sima->flag & SI_SHOW_ALPHA) { + if (ibuf->rect) sima_draw_alpha_pixels(x, y, ibuf->x, ibuf->y, ibuf->rect); - else if(ibuf->rect_float && ibuf->channels==4) + else if (ibuf->rect_float && ibuf->channels==4) sima_draw_alpha_pixelsf(x, y, ibuf->x, ibuf->y, ibuf->rect_float); } - else if(sima->flag & SI_SHOW_ZBUF && (ibuf->zbuf || ibuf->zbuf_float || (ibuf->channels==1))) { - if(ibuf->zbuf) + else if (sima->flag & SI_SHOW_ZBUF && (ibuf->zbuf || ibuf->zbuf_float || (ibuf->channels==1))) { + if (ibuf->zbuf) sima_draw_zbuf_pixels(x, y, ibuf->x, ibuf->y, ibuf->zbuf); - else if(ibuf->zbuf_float) + else if (ibuf->zbuf_float) sima_draw_zbuffloat_pixels(scene, x, y, ibuf->x, ibuf->y, ibuf->zbuf_float); - else if(ibuf->channels==1) + else if (ibuf->channels==1) sima_draw_zbuffloat_pixels(scene, x, y, ibuf->x, ibuf->y, ibuf->rect_float); } else { - if(sima->flag & SI_USE_ALPHA) { + if (sima->flag & SI_USE_ALPHA) { unsigned char col1[3]= {100, 100, 100}, col2[3]= {160, 160, 160}; sima_draw_alpha_backdrop(x, y, ibuf->x, ibuf->y, zoomx, zoomy, col1, col2); @@ -539,14 +539,14 @@ static void draw_image_buffer(SpaceImage *sima, ARegion *ar, Scene *scene, Image * convert them, and optionally apply curves */ image_verify_buffer_float(ima, ibuf, color_manage); - if(ibuf->rect) + if (ibuf->rect) glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); #if 0 else glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_FLOAT, ibuf->rect_float); #endif - if(sima->flag & SI_USE_ALPHA) + if (sima->flag & SI_USE_ALPHA) glDisable(GL_BLEND); } @@ -568,7 +568,7 @@ static unsigned int *get_part_from_ibuf(ImBuf *ibuf, short startx, short starty, rp=rectmain= MEM_mallocN(heigth*len*sizeof(int), "rect"); - for(y=0; y<heigth; y++) { + for (y=0; y<heigth; y++) { memcpy(rp, rt, len*4); rt+= ibuf->x; rp+= len; @@ -583,12 +583,12 @@ static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Scene *scene, int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT; /* verify valid values, just leave this a while */ - if(ima->xrep<1) return; - if(ima->yrep<1) return; + if (ima->xrep<1) return; + if (ima->yrep<1) return; glPixelZoom(zoomx, zoomy); - if(sima->curtile >= ima->xrep*ima->yrep) + if (sima->curtile >= ima->xrep*ima->yrep) sima->curtile = ima->xrep*ima->yrep - 1; /* create char buffer from float if needed */ @@ -602,8 +602,8 @@ static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Scene *scene, rect= get_part_from_ibuf(ibuf, sx, sy, sx+dx, sy+dy); /* draw repeated */ - for(sy=0; sy+dy<=ibuf->y; sy+= dy) { - for(sx=0; sx+dx<=ibuf->x; sx+= dx) { + for (sy=0; sy+dy<=ibuf->y; sy+= dy) { + for (sx=0; sx+dx<=ibuf->x; sx+= dx) { UI_view2d_to_region_no_clip(&ar->v2d, fx + (float)sx/(float)ibuf->x, fy + (float)sy/(float)ibuf->y, &x, &y); glaDrawPixelsSafe(x, y, dx, dy, dx, GL_RGBA, GL_UNSIGNED_BYTE, rect); @@ -626,16 +626,16 @@ static void draw_image_buffer_repeated(SpaceImage *sima, ARegion *ar, Scene *sce int x; - for(x=xmin; x<xmax; x++) { + for (x=xmin; x<xmax; x++) { int y; - for(y=ymin; y<ymax; y++) { - if(ima && (ima->tpageflag & IMA_TILES)) + for (y=ymin; y<ymax; y++) { + if (ima && (ima->tpageflag & IMA_TILES)) draw_image_buffer_tiled(sima, ar, scene, ima, ibuf, x, y, zoomx, zoomy); else draw_image_buffer(sima, ar, scene, ima, ibuf, x, y, zoomx, zoomy); /* only draw until running out of time */ - if((PIL_check_seconds_timer() - time_current) > 0.25) + if ((PIL_check_seconds_timer() - time_current) > 0.25) return; } } @@ -679,15 +679,15 @@ static void draw_image_view_tool(Scene *scene) float radius; int draw= 0; - if(brush) { - if(settings->imapaint.flag & IMAGEPAINT_DRAWING) { - if(settings->imapaint.flag & IMAGEPAINT_DRAW_TOOL_DRAWING) + if (brush) { + if (settings->imapaint.flag & IMAGEPAINT_DRAWING) { + if (settings->imapaint.flag & IMAGEPAINT_DRAW_TOOL_DRAWING) draw= 1; } - else if(settings->imapaint.flag & IMAGEPAINT_DRAW_TOOL) + else if (settings->imapaint.flag & IMAGEPAINT_DRAW_TOOL) draw= 1; - if(draw) { + if (draw) { getmouseco_areawin(mval); radius= brush_size(brush)*G.sima->zoom; @@ -709,16 +709,16 @@ static unsigned char *get_alpha_clone_image(Scene *scene, int *width, int *heigh unsigned int size, alpha; unsigned char *rect, *cp; - if(!brush || !brush->clone.image) + if (!brush || !brush->clone.image) return NULL; ibuf= BKE_image_get_ibuf(brush->clone.image, NULL); - if(!ibuf || !ibuf->rect) + if (!ibuf || !ibuf->rect) return NULL; rect= MEM_dupallocN(ibuf->rect); - if(!rect) + if (!rect) return NULL; *width= ibuf->x; @@ -728,7 +728,7 @@ static unsigned char *get_alpha_clone_image(Scene *scene, int *width, int *heigh alpha= (unsigned char)255*brush->clone.alpha; cp= rect; - while(size-- > 0) { + while (size-- > 0) { cp[3]= alpha; cp += 4; } @@ -744,12 +744,12 @@ static void draw_image_paint_helpers(ARegion *ar, Scene *scene, float zoomx, flo brush= paint_brush(&scene->toolsettings->imapaint.paint); - if(brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE)) { + if (brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE)) { /* this is not very efficient, but glDrawPixels doesn't allow * drawing with alpha */ clonerect= get_alpha_clone_image(scene, &w, &h); - if(clonerect) { + if (clonerect) { UI_view2d_to_region_no_clip(&ar->v2d, brush->clone.offset[0], brush->clone.offset[1], &x, &y); glPixelZoom(zoomx, zoomy); @@ -780,13 +780,13 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene) #if 0 what_image(sima); - if(sima->image) { + if (sima->image) { ED_image_aspect(sima->image, &xuser_asp, &yuser_asp); /* UGLY hack? until now iusers worked fine... but for flipbook viewer we need this */ - if(sima->image->type==IMA_TYPE_COMPOSITE) { + if (sima->image->type==IMA_TYPE_COMPOSITE) { ImageUser *iuser= ntree_get_active_iuser(scene->nodetree); - if(iuser) { + if (iuser) { BKE_image_user_calc_imanr(iuser, scene->r.cfra, 0); sima->iuser= *iuser; } @@ -805,26 +805,26 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene) show_render= (show_viewer && ima->type == IMA_TYPE_R_RESULT); /* draw the image or grid */ - if(ibuf==NULL) + if (ibuf==NULL) draw_image_grid(ar, zoomx, zoomy); - else if(sima->flag & SI_DRAW_TILE) + else if (sima->flag & SI_DRAW_TILE) draw_image_buffer_repeated(sima, ar, scene, ima, ibuf, zoomx, zoomy); - else if(ima && (ima->tpageflag & IMA_TILES)) + else if (ima && (ima->tpageflag & IMA_TILES)) draw_image_buffer_tiled(sima, ar, scene, ima, ibuf, 0.0f, 0.0, zoomx, zoomy); else draw_image_buffer(sima, ar, scene, ima, ibuf, 0.0f, 0.0f, zoomx, zoomy); /* paint helpers */ - if(sima->flag & SI_DRAWTOOL) + if (sima->flag & SI_DRAWTOOL) draw_image_paint_helpers(ar, scene, zoomx, zoomy); /* XXX integrate this code */ #if 0 - if(ibuf) { + if (ibuf) { float xoffs=0.0f, yoffs= 0.0f; - if(image_preview_active(sa, &xim, &yim)) { + if (image_preview_active(sa, &xim, &yim)) { xoffs= scene->r.disprect.xmin; yoffs= scene->r.disprect.ymin; glColor3ub(0,0,0); @@ -839,7 +839,7 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene) ED_space_image_release_buffer(sima, lock); /* render info */ - if(ima && show_render) + if (ima && show_render) draw_render_info(scene, ima, ar); } diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 6d4aa63a770..5de0dd3fccd 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -96,15 +96,15 @@ static void sima_zoom_set(SpaceImage *sima, ARegion *ar, float zoom, float locat width *= sima->zoom; height *= sima->zoom; - if((width < 4) && (height < 4)) + if ((width < 4) && (height < 4)) sima->zoom= oldzoom; - else if((ar->winrct.xmax - ar->winrct.xmin) <= sima->zoom) + else if ((ar->winrct.xmax - ar->winrct.xmin) <= sima->zoom) sima->zoom= oldzoom; - else if((ar->winrct.ymax - ar->winrct.ymin) <= sima->zoom) + else if ((ar->winrct.ymax - ar->winrct.ymin) <= sima->zoom) sima->zoom= oldzoom; } - if((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) { + if ((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) { float aspx, aspy, w, h; ED_space_image_size(sima, &width, &height); @@ -133,15 +133,15 @@ static int image_poll(bContext *C) static int space_image_buffer_exists_poll(bContext *C) { SpaceImage *sima= CTX_wm_space_image(C); - if(sima && sima->spacetype==SPACE_IMAGE) - if(ED_space_image_has_buffer(sima)) + if (sima && sima->spacetype==SPACE_IMAGE) + if (ED_space_image_has_buffer(sima)) return 1; return 0; } static int space_image_file_exists_poll(bContext *C) { - if(space_image_buffer_exists_poll(C)) { + if (space_image_buffer_exists_poll(C)) { Main *bmain= CTX_data_main(C); SpaceImage *sima= CTX_wm_space_image(C); ImBuf *ibuf; @@ -150,11 +150,11 @@ static int space_image_file_exists_poll(bContext *C) char name[FILE_MAX]; ibuf= ED_space_image_acquire_buffer(sima, &lock); - if(ibuf) { + if (ibuf) { BLI_strncpy(name, ibuf->name, FILE_MAX); BLI_path_abs(name, bmain->name); - if(BLI_exists(name) == FALSE) { + if (BLI_exists(name) == FALSE) { CTX_wm_operator_poll_msg_set(C, "image file not found"); } else if (BLI_file_is_writable(name) == FALSE) { @@ -174,7 +174,7 @@ static int space_image_file_exists_poll(bContext *C) static int space_image_poll(bContext *C) { SpaceImage *sima= CTX_wm_space_image(C); - if(sima && sima->spacetype==SPACE_IMAGE && sima->image) + if (sima && sima->spacetype==SPACE_IMAGE && sima->image) return 1; return 0; } @@ -184,7 +184,7 @@ int space_image_main_area_poll(bContext *C) SpaceImage *sima= CTX_wm_space_image(C); // XXX ARegion *ar= CTX_wm_region(C); - if(sima) + if (sima) return 1; // XXX (ar && ar->type->regionid == RGN_TYPE_WINDOW); return 0; @@ -196,7 +196,7 @@ int space_image_main_area_not_uv_brush_poll(bContext *C) SpaceImage *sima= CTX_wm_space_image(C); ToolSettings *toolsettings = CTX_data_scene(C)->toolsettings; - if(sima && !toolsettings->uvsculpt) + if (sima && !toolsettings->uvsculpt) return 1; return 0; @@ -208,8 +208,8 @@ static int space_image_image_sample_poll(bContext *C) Object *obedit= CTX_data_edit_object(C); ToolSettings *toolsettings = CTX_data_scene(C)->toolsettings; - if(obedit){ - if(ED_space_image_show_uvedit(sima, obedit) && (toolsettings->use_uv_sculpt)) + if (obedit) { + if (ED_space_image_show_uvedit(sima, obedit) && (toolsettings->use_uv_sculpt)) return 0; } return space_image_main_area_poll(C); @@ -244,7 +244,7 @@ static void image_view_pan_exit(bContext *C, wmOperator *op, int cancel) SpaceImage *sima= CTX_wm_space_image(C); ViewPanData *vpd= op->customdata; - if(cancel) { + if (cancel) { sima->xof= vpd->xof; sima->yof= vpd->yof; ED_region_tag_redraw(CTX_wm_region(C)); @@ -267,7 +267,7 @@ static int image_view_pan_exec(bContext *C, wmOperator *op) /* XXX notifier? */ #if 0 - if(image_preview_active(curarea, NULL, NULL)) { + if (image_preview_active(curarea, NULL, NULL)) { /* recalculates new preview rect */ scrarea_do_windraw(curarea); image_preview_event(2); @@ -312,7 +312,7 @@ static int image_view_pan_modal(bContext *C, wmOperator *op, wmEvent *event) image_view_pan_exec(C, op); break; default: - if(event->type==vpd->event_type && event->val==KM_RELEASE) { + if (event->type==vpd->event_type && event->val==KM_RELEASE) { image_view_pan_exit(C, op, 0); return OPERATOR_FINISHED; } @@ -382,7 +382,7 @@ static void image_view_zoom_exit(bContext *C, wmOperator *op, int cancel) SpaceImage *sima= CTX_wm_space_image(C); ViewZoomData *vpd= op->customdata; - if(cancel) { + if (cancel) { sima->zoom= vpd->zoom; ED_region_tag_redraw(CTX_wm_region(C)); } @@ -402,7 +402,7 @@ static int image_view_zoom_exec(bContext *C, wmOperator *op) /* XXX notifier? */ #if 0 - if(image_preview_active(curarea, NULL, NULL)) { + if (image_preview_active(curarea, NULL, NULL)) { /* recalculates new preview rect */ scrarea_do_windraw(curarea); image_preview_event(2); @@ -449,7 +449,7 @@ static int image_view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event) ED_region_tag_redraw(CTX_wm_region(C)); break; default: - if(event->type==vpd->event_type && event->val==KM_RELEASE) { + if (event->type==vpd->event_type && event->val==KM_RELEASE) { image_view_zoom_exit(C, op, 0); return OPERATOR_FINISHED; } @@ -570,7 +570,7 @@ static int image_view_all_exec(bContext *C, wmOperator *UNUSED(op)) width = ar->winrct.xmax - ar->winrct.xmin + 1; height = ar->winrct.ymax - ar->winrct.ymin + 1; - if((w >= width || h >= height) && (width > 0 && height > 0)) { + if ((w >= width || h >= height) && (width > 0 && height > 0)) { /* find the zoom value that will fit the image in the image space */ zoomx= width/w; zoomy= height/h; @@ -623,7 +623,7 @@ static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) height= height*aspy; /* get bounds */ - if(!ED_uvedit_minmax(scene, ima, obedit, min, max)) + if (!ED_uvedit_minmax(scene, ima, obedit, min, max)) return OPERATOR_CANCELLED; /* adjust offset and zoom */ @@ -634,7 +634,7 @@ static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) d[1]= max[1] - min[1]; size= 0.5f*MAX2(d[0], d[1])*MAX2(width, height)/256.0f; - if(size<=0.01f) size= 0.01f; + if (size<=0.01f) size= 0.01f; sima_zoom_set(sima, ar, 0.7f/size, NULL); ED_region_tag_redraw(CTX_wm_region(C)); @@ -757,7 +757,7 @@ static int image_view_zoom_ratio_exec(bContext *C, wmOperator *op) /* XXX notifier? */ #if 0 - if(image_preview_active(curarea, NULL, NULL)) { + if (image_preview_active(curarea, NULL, NULL)) { /* recalculates new preview rect */ scrarea_do_windraw(curarea); image_preview_event(2); @@ -826,19 +826,19 @@ static int image_open_exec(bContext *C, wmOperator *op) ima= BKE_add_image_file(str); - if(!ima) { - if(op->customdata) MEM_freeN(op->customdata); + if (!ima) { + if (op->customdata) MEM_freeN(op->customdata); BKE_reportf(op->reports, RPT_ERROR, "Can't read: \"%s\", %s", str, errno ? strerror(errno) : "Unsupported image format"); return OPERATOR_CANCELLED; } - if(!op->customdata) + if (!op->customdata) image_open_init(C, op); /* hook into UI */ pprop= op->customdata; - if(pprop->prop) { + if (pprop->prop) { /* when creating new ID blocks, use is already 1, but RNA * pointer se also increases user, so this compensates it */ ima->id.us--; @@ -847,19 +847,19 @@ static int image_open_exec(bContext *C, wmOperator *op) RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr); RNA_property_update(C, &pprop->ptr, pprop->prop); } - else if(sima) { + else if (sima) { ED_space_image_set(sima, scene, obedit, ima); iuser= &sima->iuser; } else { Tex *tex= CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data; - if(tex && tex->type==TEX_IMAGE) + if (tex && tex->type==TEX_IMAGE) iuser= &tex->iuser; } /* initialize because of new image */ - if(iuser) { + if (iuser) { iuser->sfra= 1; iuser->offset= 0; iuser->fie_ima= 2; @@ -882,20 +882,20 @@ static int image_open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event) char *path=U.textudir; Image *ima= NULL; - if(sima) { + if (sima) { ima= sima->image; } if (ima==NULL) { Tex *tex= CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data; - if(tex && tex->type==TEX_IMAGE) + if (tex && tex->type==TEX_IMAGE) ima= tex->ima; } - if(ima) + if (ima) path= ima->name; - if(RNA_struct_property_is_set(op->ptr, "filepath")) + if (RNA_struct_property_is_set(op->ptr, "filepath")) return image_open_exec(C, op); image_open_init(C, op); @@ -932,7 +932,7 @@ static int image_replace_exec(bContext *C, wmOperator *op) SpaceImage *sima= CTX_wm_space_image(C); char str[FILE_MAX]; - if(!sima->image) + if (!sima->image) return OPERATOR_CANCELLED; RNA_string_get(op->ptr, "filepath", str); @@ -958,13 +958,13 @@ static int image_replace_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve { SpaceImage *sima= CTX_wm_space_image(C); - if(!sima->image) + if (!sima->image) return OPERATOR_CANCELLED; - if(RNA_struct_property_is_set(op->ptr, "filepath")) + if (RNA_struct_property_is_set(op->ptr, "filepath")) return image_replace_exec(C, op); - if(!RNA_struct_property_is_set(op->ptr, "relative_path")) + if (!RNA_struct_property_is_set(op->ptr, "relative_path")) RNA_boolean_set(op->ptr, "relative_path", (strncmp(sima->image->name, "//", 2))==0); image_filesel(C, op, sima->image->name); @@ -1035,13 +1035,13 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, void *lock; ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock); - if(ibuf) { + if (ibuf) { Image *ima= sima->image; short is_depth_set= FALSE; simopts->im_format.planes= ibuf->planes; - if(ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) { + if (ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) { /* imtype */ simopts->im_format= scene->r.im_format; is_depth_set= TRUE; @@ -1075,10 +1075,11 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, } /* check for empty path */ - if(guess_path && simopts->filepath[0]==0) { + if (guess_path && simopts->filepath[0]==0) { if ( (G.ima[0] == '/') && (G.ima[1] == '/') && (G.ima[2] == '\0') ) { BLI_strncpy(simopts->filepath, "//untitled", FILE_MAX); - } else { + } + else { BLI_strncpy(simopts->filepath, G.ima, FILE_MAX); } BLI_path_abs(simopts->filepath, G.main->name); @@ -1130,27 +1131,27 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI WM_cursor_wait(1); - if(ima->type == IMA_TYPE_R_RESULT) { + if (ima->type == IMA_TYPE_R_RESULT) { /* enforce user setting for RGB or RGBA, but skip BW */ - if(simopts->im_format.planes==R_IMF_PLANES_RGBA) { + if (simopts->im_format.planes==R_IMF_PLANES_RGBA) { ibuf->planes= R_IMF_PLANES_RGBA; } - else if(simopts->im_format.planes==R_IMF_PLANES_RGB) { + else if (simopts->im_format.planes==R_IMF_PLANES_RGB) { ibuf->planes= R_IMF_PLANES_RGB; } } else { /* TODO, better solution, if a 24bit image is painted onto it may contain alpha */ - if(ibuf->userflags & IB_BITMAPDIRTY) { /* it has been painted onto */ + if (ibuf->userflags & IB_BITMAPDIRTY) { /* it has been painted onto */ /* checks each pixel, not ideal */ ibuf->planes= BKE_alphatest_ibuf(ibuf) ? 32 : 24; } } - if(simopts->im_format.imtype==R_IMF_IMTYPE_MULTILAYER) { + if (simopts->im_format.imtype==R_IMF_IMTYPE_MULTILAYER) { Scene *scene= CTX_data_scene(C); RenderResult *rr= BKE_image_acquire_renderresult(scene, ima); - if(rr) { + if (rr) { RE_WriteRenderResult(op->reports, rr, simopts->filepath, simopts->im_format.quality); ok= TRUE; } @@ -1166,8 +1167,8 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI } if (ok) { - if(!save_copy) { - if(do_newpath) { + if (!save_copy) { + if (do_newpath) { BLI_strncpy(ibuf->name, simopts->filepath, sizeof(ibuf->name)); BLI_strncpy(ima->name, simopts->filepath, sizeof(ima->name)); } @@ -1175,28 +1176,28 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI ibuf->userflags &= ~IB_BITMAPDIRTY; /* change type? */ - if(ima->type==IMA_TYPE_R_RESULT) { + if (ima->type==IMA_TYPE_R_RESULT) { ima->type= IMA_TYPE_IMAGE; /* workaround to ensure the render result buffer is no longer used * by this image, otherwise can crash when a new render result is * created. */ - if(ibuf->rect && !(ibuf->mall & IB_rect)) + if (ibuf->rect && !(ibuf->mall & IB_rect)) imb_freerectImBuf(ibuf); - if(ibuf->rect_float && !(ibuf->mall & IB_rectfloat)) + if (ibuf->rect_float && !(ibuf->mall & IB_rectfloat)) imb_freerectfloatImBuf(ibuf); - if(ibuf->zbuf && !(ibuf->mall & IB_zbuf)) + if (ibuf->zbuf && !(ibuf->mall & IB_zbuf)) IMB_freezbufImBuf(ibuf); - if(ibuf->zbuf_float && !(ibuf->mall & IB_zbuffloat)) + if (ibuf->zbuf_float && !(ibuf->mall & IB_zbuffloat)) IMB_freezbuffloatImBuf(ibuf); } - if( ELEM(ima->source, IMA_SRC_GENERATED, IMA_SRC_VIEWER)) { + if ( ELEM(ima->source, IMA_SRC_GENERATED, IMA_SRC_VIEWER)) { ima->source= IMA_SRC_FILE; ima->type= IMA_TYPE_IMAGE; } /* only image path, never ibuf */ - if(relative) { + if (relative) { BLI_path_rel(ima->name, relbase); /* only after saving */ } } @@ -1247,7 +1248,7 @@ static int image_save_as_check(bContext *UNUSED(C), wmOperator *op) ImageFormatData *imf= op->customdata; char filepath[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filepath); - if(BKE_add_image_extension(filepath, imf->imtype)) { + if (BKE_add_image_extension(filepath, imf->imtype)) { RNA_string_set(op->ptr, "filepath", filepath); return TRUE; } @@ -1261,7 +1262,7 @@ static int image_save_as_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve Scene *scene= CTX_data_scene(C); SaveImageOptions simopts; - if(RNA_struct_property_is_set(op->ptr, "filepath")) + if (RNA_struct_property_is_set(op->ptr, "filepath")) return image_save_as_exec(C, op); if (save_image_options_init(&simopts, sima, scene, TRUE) == 0) @@ -1269,7 +1270,7 @@ static int image_save_as_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve save_image_options_to_op(&simopts, op); /* enable save_copy by default for render results */ - if(ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE) && !RNA_struct_property_is_set(op->ptr, "copy")) { + if (ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE) && !RNA_struct_property_is_set(op->ptr, "copy")) { RNA_boolean_set(op->ptr, "copy", TRUE); } @@ -1387,32 +1388,32 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op) int tot= 0; char di[FILE_MAX], fi[FILE_MAX]; - if(sima->image==NULL) + if (sima->image==NULL) return OPERATOR_CANCELLED; - if(sima->image->source!=IMA_SRC_SEQUENCE) { + if (sima->image->source!=IMA_SRC_SEQUENCE) { BKE_report(op->reports, RPT_ERROR, "Can only save sequence on image sequences"); return OPERATOR_CANCELLED; } - if(sima->image->type==IMA_TYPE_MULTILAYER) { + if (sima->image->type==IMA_TYPE_MULTILAYER) { BKE_report(op->reports, RPT_ERROR, "Can't save multilayer sequences"); return OPERATOR_CANCELLED; } /* get total */ - for(ibuf= sima->image->ibufs.first; ibuf; ibuf= ibuf->next) - if(ibuf->userflags & IB_BITMAPDIRTY) + for (ibuf= sima->image->ibufs.first; ibuf; ibuf= ibuf->next) + if (ibuf->userflags & IB_BITMAPDIRTY) tot++; - if(tot==0) { + if (tot==0) { BKE_report(op->reports, RPT_WARNING, "No images have been changed"); return OPERATOR_CANCELLED; } /* get a filename for menu */ - for(ibuf= sima->image->ibufs.first; ibuf; ibuf= ibuf->next) - if(ibuf->userflags & IB_BITMAPDIRTY) + for (ibuf= sima->image->ibufs.first; ibuf; ibuf= ibuf->next) + if (ibuf->userflags & IB_BITMAPDIRTY) break; BLI_strncpy(di, ibuf->name, FILE_MAX); @@ -1420,14 +1421,14 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op) BKE_reportf(op->reports, RPT_INFO, "%d Image(s) will be saved in %s", tot, di); - for(ibuf= sima->image->ibufs.first; ibuf; ibuf= ibuf->next) { - if(ibuf->userflags & IB_BITMAPDIRTY) { + for (ibuf= sima->image->ibufs.first; ibuf; ibuf= ibuf->next) { + if (ibuf->userflags & IB_BITMAPDIRTY) { char name[FILE_MAX]; BLI_strncpy(name, ibuf->name, sizeof(name)); BLI_path_abs(name, bmain->name); - if(0 == IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat)) { + if (0 == IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat)) { BKE_reportf(op->reports, RPT_ERROR, "Could not write image %s", name); break; } @@ -1461,7 +1462,7 @@ static int image_reload_exec(bContext *C, wmOperator *UNUSED(op)) Image *ima= CTX_data_edit_image(C); SpaceImage *sima= CTX_wm_space_image(C); - if(!ima) + if (!ima) return OPERATOR_CANCELLED; /* XXX unpackImage frees image buffers */ @@ -1518,18 +1519,18 @@ static int image_new_exec(bContext *C, wmOperator *op) if (!floatbuf && scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) linearrgb_to_srgb_v3_v3(color, color); - if(!alpha) + if (!alpha) color[3]= 1.0f; ima = BKE_add_image_size(width, height, name, alpha ? 32 : 24, floatbuf, uvtestgrid, color); - if(!ima) + if (!ima) return OPERATOR_CANCELLED; /* hook into UI */ uiIDContextProperty(C, &ptr, &prop); - if(prop) { + if (prop) { /* when creating new ID blocks, use is already 1, but RNA * pointer se also increases user, so this compensates it */ ima->id.us--; @@ -1538,7 +1539,7 @@ static int image_new_exec(bContext *C, wmOperator *op) RNA_property_pointer_set(&ptr, prop, idptr); RNA_property_update(C, &ptr, prop); } - else if(sima) + else if (sima) ED_space_image_set(sima, scene, obedit, ima); // XXX other users? @@ -1589,7 +1590,7 @@ static int image_invert_poll(bContext *C) Image *ima= CTX_data_edit_image(C); ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - if( ibuf != NULL ) + if ( ibuf != NULL ) return 1; return 0; } @@ -1607,32 +1608,32 @@ static int image_invert_exec(bContext *C, wmOperator *op) int i; - if( ibuf == NULL) // TODO: this should actually never happen, but does for render-results -> cleanup + if ( ibuf == NULL) // TODO: this should actually never happen, but does for render-results -> cleanup return OPERATOR_CANCELLED; /* TODO: make this into an IMB_invert_channels(ibuf,r,g,b,a) method!? */ if (ibuf->rect_float) { float *fp = (float *) ibuf->rect_float; - for( i = ibuf->x * ibuf->y; i > 0; i--, fp+=4 ) { - if( r ) fp[0] = 1.0f - fp[0]; - if( g ) fp[1] = 1.0f - fp[1]; - if( b ) fp[2] = 1.0f - fp[2]; - if( a ) fp[3] = 1.0f - fp[3]; + for ( i = ibuf->x * ibuf->y; i > 0; i--, fp+=4 ) { + if ( r ) fp[0] = 1.0f - fp[0]; + if ( g ) fp[1] = 1.0f - fp[1]; + if ( b ) fp[2] = 1.0f - fp[2]; + if ( a ) fp[3] = 1.0f - fp[3]; } - if(ibuf->rect) { + if (ibuf->rect) { IMB_rect_from_float(ibuf); } } - else if(ibuf->rect) { + else if (ibuf->rect) { char *cp = (char *) ibuf->rect; - for( i = ibuf->x * ibuf->y; i > 0; i--, cp+=4 ) { - if( r ) cp[0] = 255 - cp[0]; - if( g ) cp[1] = 255 - cp[1]; - if( b ) cp[2] = 255 - cp[2]; - if( a ) cp[3] = 255 - cp[3]; + for ( i = ibuf->x * ibuf->y; i > 0; i--, cp+=4 ) { + if ( r ) cp[0] = 255 - cp[0]; + if ( g ) cp[1] = 255 - cp[1]; + if ( b ) cp[2] = 255 - cp[2]; + if ( a ) cp[3] = 255 - cp[3]; } } else { @@ -1640,7 +1641,7 @@ static int image_invert_exec(bContext *C, wmOperator *op) } ibuf->userflags |= IB_BITMAPDIRTY; - if(ibuf->mipmap[0]) + if (ibuf->mipmap[0]) ibuf->userflags |= IB_MIPMAP_INVALID; WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, ima); @@ -1674,12 +1675,12 @@ static int image_pack_test(bContext *C, wmOperator *op) Image *ima= CTX_data_edit_image(C); int as_png= RNA_boolean_get(op->ptr, "as_png"); - if(!ima) + if (!ima) return 0; - if(!as_png && ima->packedfile) + if (!as_png && ima->packedfile) return 0; - if(ima->source==IMA_SRC_SEQUENCE || ima->source==IMA_SRC_MOVIE) { + if (ima->source==IMA_SRC_SEQUENCE || ima->source==IMA_SRC_MOVIE) { BKE_report(op->reports, RPT_ERROR, "Packing movies or image sequences not supported"); return 0; } @@ -1694,15 +1695,15 @@ static int image_pack_exec(bContext *C, wmOperator *op) ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); int as_png= RNA_boolean_get(op->ptr, "as_png"); - if(!image_pack_test(C, op)) + if (!image_pack_test(C, op)) return OPERATOR_CANCELLED; - if(!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) { + if (!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) { BKE_report(op->reports, RPT_ERROR, "Can't pack edited image from disk, only as internal PNG"); return OPERATOR_CANCELLED; } - if(as_png) + if (as_png) BKE_image_memorypack(ima); else ima->packedfile= newPackedFile(op->reports, ima->name, ID_BLEND_PATH(bmain, &ima->id)); @@ -1720,10 +1721,10 @@ static int image_pack_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event) uiLayout *layout; int as_png= RNA_boolean_get(op->ptr, "as_png"); - if(!image_pack_test(C, op)) + if (!image_pack_test(C, op)) return OPERATOR_CANCELLED; - if(!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) { + if (!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) { pup= uiPupMenuBegin(C, "OK", ICON_QUESTION); layout= uiPupMenuLayout(pup); uiItemBooleanO(layout, "Can't pack edited image from disk. Pack as internal PNG?", ICON_NONE, op->idname, "as_png", 1); @@ -1768,15 +1769,15 @@ static int image_unpack_exec(bContext *C, wmOperator *op) if (!ima) ima = CTX_data_edit_image(C); } - if(!ima || !ima->packedfile) + if (!ima || !ima->packedfile) return OPERATOR_CANCELLED; - if(ima->source==IMA_SRC_SEQUENCE || ima->source==IMA_SRC_MOVIE) { + if (ima->source==IMA_SRC_SEQUENCE || ima->source==IMA_SRC_MOVIE) { BKE_report(op->reports, RPT_ERROR, "Unpacking movies or image sequences not supported"); return OPERATOR_CANCELLED; } - if(G.fileflags & G_AUTOPACK) + if (G.fileflags & G_AUTOPACK) BKE_report(op->reports, RPT_WARNING, "AutoPack is enabled, so image will be packed again on file save"); /* XXX unpackImage frees image buffers */ @@ -1793,18 +1794,18 @@ static int image_unpack_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even { Image *ima= CTX_data_edit_image(C); - if(RNA_struct_property_is_set(op->ptr, "id")) + if (RNA_struct_property_is_set(op->ptr, "id")) return image_unpack_exec(C, op); - if(!ima || !ima->packedfile) + if (!ima || !ima->packedfile) return OPERATOR_CANCELLED; - if(ima->source==IMA_SRC_SEQUENCE || ima->source==IMA_SRC_MOVIE) { + if (ima->source==IMA_SRC_SEQUENCE || ima->source==IMA_SRC_MOVIE) { BKE_report(op->reports, RPT_ERROR, "Unpacking movies or image sequences not supported"); return OPERATOR_CANCELLED; } - if(G.fileflags & G_AUTOPACK) + if (G.fileflags & G_AUTOPACK) BKE_report(op->reports, RPT_WARNING, "AutoPack is enabled, so image will be packed again on file save"); unpack_menu(C, "IMAGE_OT_unpack", ima->id.name+2, ima->name, "textures", ima->packedfile); @@ -1855,7 +1856,7 @@ typedef struct ImageSampleInfo { static void image_sample_draw(const bContext *UNUSED(C), ARegion *ar, void *arg_info) { ImageSampleInfo *info= arg_info; - if(info->draw) { + if (info->draw) { /* no color management needed for images (color_manage=0) */ ED_image_draw_info(ar, 0, info->channels, info->x, info->y, info->colp, info->colfp, info->zp, info->zfp); } @@ -1870,14 +1871,14 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) ImageSampleInfo *info= op->customdata; float fx, fy; - if(ibuf == NULL) { + if (ibuf == NULL) { ED_space_image_release_buffer(sima, lock); return; } UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fx, &fy); - if(fx>=0.0f && fy>=0.0f && fx<1.0f && fy<1.0f) { + if (fx>=0.0f && fy>=0.0f && fx<1.0f && fy<1.0f) { float *fp; unsigned char *cp; int x= (int)(fx*ibuf->x), y= (int)(fy*ibuf->y); @@ -1895,7 +1896,7 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) info->zp= NULL; info->zfp= NULL; - if(ibuf->rect) { + if (ibuf->rect) { cp= (unsigned char *)(ibuf->rect + y*ibuf->x + x); info->col[0]= cp[0]; @@ -1910,7 +1911,7 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) info->colf[3]= (float)cp[3]/255.0f; info->colfp= info->colf; } - if(ibuf->rect_float) { + if (ibuf->rect_float) { fp= (ibuf->rect_float + (ibuf->channels)*(y*ibuf->x + x)); info->colf[0]= fp[0]; @@ -1920,28 +1921,28 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) info->colfp= info->colf; } - if(ibuf->zbuf) { + if (ibuf->zbuf) { info->z= ibuf->zbuf[y*ibuf->x + x]; info->zp= &info->z; } - if(ibuf->zbuf_float) { + if (ibuf->zbuf_float) { info->zf= ibuf->zbuf_float[y*ibuf->x + x]; info->zfp= &info->zf; } - if(sima->cumap && ibuf->channels==4) { + if (sima->cumap && ibuf->channels==4) { /* we reuse this callback for set curves point operators */ - if(RNA_struct_find_property(op->ptr, "point")) { + if (RNA_struct_find_property(op->ptr, "point")) { int point= RNA_enum_get(op->ptr, "point"); - if(point == 1) { + if (point == 1) { curvemapping_set_black_white(sima->cumap, NULL, info->colfp); - if(ibuf->rect_float) + if (ibuf->rect_float) curvemapping_do_ibuf(sima->cumap, ibuf); } - else if(point == 0) { + else if (point == 0) { curvemapping_set_black_white(sima->cumap, info->colfp, NULL); - if(ibuf->rect_float) + if (ibuf->rect_float) curvemapping_do_ibuf(sima->cumap, ibuf); } } @@ -1953,8 +1954,8 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) ScrArea *sa, *cur= curarea; node_curvemap_sample(fp); /* sends global to node editor */ - for(sa= G.curscreen->areabase.first; sa; sa= sa->next) { - if(sa->spacetype==SPACE_NODE) { + for (sa= G.curscreen->areabase.first; sa; sa= sa->next) { + if (sa->spacetype==SPACE_NODE) { areawinset(sa->win); scrarea_do_windraw(sa); } @@ -1986,7 +1987,7 @@ static int image_sample_invoke(bContext *C, wmOperator *op, wmEvent *event) ARegion *ar= CTX_wm_region(C); ImageSampleInfo *info; - if(!ED_space_image_has_buffer(sima)) + if (!ED_space_image_has_buffer(sima)) return OPERATOR_CANCELLED; info= MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo"); @@ -2089,7 +2090,8 @@ static int image_sample_line_exec(bContext *C, wmOperator *op) if (x<0 || y<0 || x>=ibuf->x || y>=ibuf->y) { hist->data_luma[i] = hist->data_r[i] = hist->data_g[i]= hist->data_b[i] = 0.0f; - } else { + } + else { if (ibuf->rect_float) { fp= (ibuf->rect_float + (ibuf->channels)*(y*ibuf->x + x)); @@ -2124,7 +2126,7 @@ static int image_sample_line_invoke(bContext *C, wmOperator *op, wmEvent *event) { SpaceImage *sima= CTX_wm_space_image(C); - if(!ED_space_image_has_buffer(sima)) + if (!ED_space_image_has_buffer(sima)) return OPERATOR_CANCELLED; return WM_gesture_straightline_invoke(C, op, event); @@ -2203,7 +2205,7 @@ static int image_record_composite_apply(bContext *C, wmOperator *op) ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser); /* save memory in flipbooks */ - if(ibuf) + if (ibuf) imb_freerectfloatImBuf(ibuf); scene->r.cfra++; @@ -2217,9 +2219,9 @@ static int image_record_composite_init(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); RecordCompositeData *rcd; - if(sima->iuser.frames < 2) + if (sima->iuser.frames < 2) return 0; - if(scene->nodetree == NULL) + if (scene->nodetree == NULL) return 0; op->customdata= rcd= MEM_callocN(sizeof(RecordCompositeData), "ImageRecordCompositeData"); @@ -2242,7 +2244,7 @@ static void image_record_composite_exit(bContext *C, wmOperator *op) WM_cursor_restore(CTX_wm_window(C)); - if(rcd->timer) + if (rcd->timer) WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), rcd->timer); WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, sima->image); @@ -2255,7 +2257,7 @@ static void image_record_composite_exit(bContext *C, wmOperator *op) static int image_record_composite_exec(bContext *C, wmOperator *op) { - if(!image_record_composite_init(C, op)) + if (!image_record_composite_init(C, op)) return OPERATOR_CANCELLED; while(image_record_composite_apply(C, op)) @@ -2270,14 +2272,14 @@ static int image_record_composite_invoke(bContext *C, wmOperator *op, wmEvent *U { RecordCompositeData *rcd; - if(!image_record_composite_init(C, op)) + if (!image_record_composite_init(C, op)) return OPERATOR_CANCELLED; rcd= op->customdata; rcd->timer= WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.0f); WM_event_add_modal_handler(C, op); - if(!image_record_composite_apply(C, op)) + if (!image_record_composite_apply(C, op)) return OPERATOR_FINISHED; return OPERATOR_RUNNING_MODAL; @@ -2289,8 +2291,8 @@ static int image_record_composite_modal(bContext *C, wmOperator *op, wmEvent *ev switch(event->type) { case TIMER: - if(rcd->timer == event->customdata) { - if(!image_record_composite_apply(C, op)) { + if (rcd->timer == event->customdata) { + if (!image_record_composite_apply(C, op)) { image_record_composite_exit(C, op); return OPERATOR_FINISHED; } @@ -2339,27 +2341,27 @@ static int image_cycle_render_slot_exec(bContext *C, wmOperator *op) int a, slot, cur= ima->render_slot; const short use_reverse= RNA_boolean_get(op->ptr, "reverse"); - for(a=1; a<IMA_MAX_RENDER_SLOT; a++) { + for (a=1; a<IMA_MAX_RENDER_SLOT; a++) { slot= (cur + (use_reverse ? -a:a))%IMA_MAX_RENDER_SLOT; - if(slot<0) slot+=IMA_MAX_RENDER_SLOT; + if (slot<0) slot+=IMA_MAX_RENDER_SLOT; - if(ima->renders[slot] || slot == ima->last_render_slot) { + if (ima->renders[slot] || slot == ima->last_render_slot) { ima->render_slot= slot; break; } - else if((slot - 1) == ima->last_render_slot && slot < IMA_MAX_RENDER_SLOT) { + else if ((slot - 1) == ima->last_render_slot && slot < IMA_MAX_RENDER_SLOT) { ima->render_slot= slot; break; } } - if(a == IMA_MAX_RENDER_SLOT) + if (a == IMA_MAX_RENDER_SLOT) ima->render_slot= ((cur == 1)? 0: 1); WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL); /* no undo push for browsing existing */ - if(ima->renders[ima->render_slot] || ima->render_slot==ima->last_render_slot) + if (ima->renders[ima->render_slot] || ima->render_slot==ima->last_render_slot) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; @@ -2394,42 +2396,42 @@ void ED_image_update_frame(const Main *mainp, int cfra) Tex *tex; /* texture users */ - for(tex= mainp->tex.first; tex; tex= tex->id.next) { - if(tex->type==TEX_IMAGE && tex->ima) { - if(ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { - if(tex->iuser.flag & IMA_ANIM_ALWAYS) + for (tex= mainp->tex.first; tex; tex= tex->id.next) { + if (tex->type==TEX_IMAGE && tex->ima) { + if (ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { + if (tex->iuser.flag & IMA_ANIM_ALWAYS) BKE_image_user_calc_frame(&tex->iuser, cfra, 0); } } } /* image window, compo node users */ - for(wm=mainp->wm.first; wm; wm= wm->id.next) { /* only 1 wm */ - for(win= wm->windows.first; win; win= win->next) { + for (wm=mainp->wm.first; wm; wm= wm->id.next) { /* only 1 wm */ + for (win= wm->windows.first; win; win= win->next) { ScrArea *sa; - for(sa= win->screen->areabase.first; sa; sa= sa->next) { - if(sa->spacetype==SPACE_VIEW3D) { + for (sa= win->screen->areabase.first; sa; sa= sa->next) { + if (sa->spacetype==SPACE_VIEW3D) { View3D *v3d= sa->spacedata.first; BGpic *bgpic; - for(bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next) - if(bgpic->iuser.flag & IMA_ANIM_ALWAYS) + for (bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next) + if (bgpic->iuser.flag & IMA_ANIM_ALWAYS) BKE_image_user_calc_frame(&bgpic->iuser, cfra, 0); } - else if(sa->spacetype==SPACE_IMAGE) { + else if (sa->spacetype==SPACE_IMAGE) { SpaceImage *sima= sa->spacedata.first; - if(sima->iuser.flag & IMA_ANIM_ALWAYS) + if (sima->iuser.flag & IMA_ANIM_ALWAYS) BKE_image_user_calc_frame(&sima->iuser, cfra, 0); } - else if(sa->spacetype==SPACE_NODE) { + else if (sa->spacetype==SPACE_NODE) { SpaceNode *snode= sa->spacedata.first; - if((snode->treetype==NTREE_COMPOSIT) && (snode->nodetree)) { + if ((snode->treetype==NTREE_COMPOSIT) && (snode->nodetree)) { bNode *node; - for(node= snode->nodetree->nodes.first; node; node= node->next) { - if(node->id && node->type==CMP_NODE_IMAGE) { + for (node= snode->nodetree->nodes.first; node; node= node->next) { + if (node->id && node->type==CMP_NODE_IMAGE) { Image *ima= (Image *)node->id; ImageUser *iuser= node->storage; - if(ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) - if(iuser->flag & IMA_ANIM_ALWAYS) + if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) + if (iuser->flag & IMA_ANIM_ALWAYS) BKE_image_user_calc_frame(iuser, cfra, 0); } } diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 5005e0de9c5..f1967477d7a 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -92,16 +92,16 @@ void ED_space_image_set(SpaceImage *sima, Scene *scene, Object *obedit, Image *i * to check if the face is displayed in UV-localview */ sima->image= ima; - if(ima == NULL || ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE) + if (ima == NULL || ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE) sima->flag &= ~SI_DRAWTOOL; - if(sima->image) + if (sima->image) BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE); - if(sima->image && sima->image->id.us==0) + if (sima->image && sima->image->id.us==0) sima->image->id.us= 1; - if(obedit) + if (obedit) WM_main_add_notifier(NC_GEOM|ND_DATA, obedit->data); WM_main_add_notifier(NC_SPACE|ND_SPACE_IMAGE, NULL); @@ -111,15 +111,15 @@ ImBuf *ED_space_image_acquire_buffer(SpaceImage *sima, void **lock_r) { ImBuf *ibuf; - if(sima && sima->image) { + if (sima && sima->image) { #if 0 - if(sima->image->type==IMA_TYPE_R_RESULT && BIF_show_render_spare()) + if (sima->image->type==IMA_TYPE_R_RESULT && BIF_show_render_spare()) return BIF_render_spare_imbuf(); else #endif ibuf= BKE_image_acquire_ibuf(sima->image, &sima->iuser, lock_r); - if(ibuf && (ibuf->rect || ibuf->rect_float)) + if (ibuf && (ibuf->rect || ibuf->rect_float)) return ibuf; } @@ -128,7 +128,7 @@ ImBuf *ED_space_image_acquire_buffer(SpaceImage *sima, void **lock_r) void ED_space_image_release_buffer(SpaceImage *sima, void *lock) { - if(sima && sima->image) + if (sima && sima->image) BKE_image_release_ibuf(sima->image, lock); } @@ -150,10 +150,10 @@ void ED_image_size(Image *ima, int *width, int *height) ImBuf *ibuf= NULL; void *lock; - if(ima) + if (ima) ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock); - if(ibuf && ibuf->x > 0 && ibuf->y > 0) { + if (ibuf && ibuf->x > 0 && ibuf->y > 0) { *width= ibuf->x; *height= ibuf->y; } @@ -162,7 +162,7 @@ void ED_image_size(Image *ima, int *width, int *height) *height= 256; } - if(ima) + if (ima) BKE_image_release_ibuf(ima, lock); } @@ -174,23 +174,23 @@ void ED_space_image_size(SpaceImage *sima, int *width, int *height) ibuf= ED_space_image_acquire_buffer(sima, &lock); - if(ibuf && ibuf->x > 0 && ibuf->y > 0) { + if (ibuf && ibuf->x > 0 && ibuf->y > 0) { *width= ibuf->x; *height= ibuf->y; } - else if(sima->image && sima->image->type==IMA_TYPE_R_RESULT && scene) { + else if (sima->image && sima->image->type==IMA_TYPE_R_RESULT && scene) { /* not very important, just nice */ *width= (scene->r.xsch*scene->r.size)/100; *height= (scene->r.ysch*scene->r.size)/100; - if((scene->r.mode & R_BORDER) && (scene->r.mode & R_CROP)) { + if ((scene->r.mode & R_BORDER) && (scene->r.mode & R_CROP)) { *width *= (scene->r.border.xmax - scene->r.border.xmin); *height *= (scene->r.border.ymax - scene->r.border.ymin); } } /* I know a bit weak... but preview uses not actual image size */ - // XXX else if(image_preview_active(sima, width, height)); + // XXX else if (image_preview_active(sima, width, height)); else { *width= 256; *height= 256; @@ -203,7 +203,7 @@ void ED_image_aspect(Image *ima, float *aspx, float *aspy) { *aspx= *aspy= 1.0; - if((ima == NULL) || (ima->type == IMA_TYPE_R_RESULT) || (ima->type == IMA_TYPE_COMPOSITE) || + if ((ima == NULL) || (ima->type == IMA_TYPE_R_RESULT) || (ima->type == IMA_TYPE_COMPOSITE) || (ima->aspx==0.0f || ima->aspy==0.0f)) return; @@ -236,7 +236,7 @@ void ED_space_image_uv_aspect(SpaceImage *sima, float *aspx, float *aspy) *aspx *= (float)w; *aspy *= (float)h; - if(*aspx < *aspy) { + if (*aspx < *aspy) { *aspy= *aspy / *aspx; *aspx= 1.0f; } @@ -264,7 +264,7 @@ int ED_space_image_show_render(SpaceImage *sima) int ED_space_image_show_paint(SpaceImage *sima) { - if(ED_space_image_show_render(sima)) + if (ED_space_image_show_render(sima)) return 0; return (sima->flag & SI_DRAWTOOL); @@ -272,10 +272,10 @@ int ED_space_image_show_paint(SpaceImage *sima) int ED_space_image_show_uvedit(SpaceImage *sima, Object *obedit) { - if(sima && (ED_space_image_show_render(sima) || ED_space_image_show_paint(sima))) + if (sima && (ED_space_image_show_render(sima) || ED_space_image_show_paint(sima))) return 0; - if(obedit && obedit->type == OB_MESH) { + if (obedit && obedit->type == OB_MESH) { struct BMEditMesh *em = BMEdit_FromObject(obedit); int ret; @@ -289,11 +289,11 @@ int ED_space_image_show_uvedit(SpaceImage *sima, Object *obedit) int ED_space_image_show_uvshadow(SpaceImage *sima, Object *obedit) { - if(ED_space_image_show_render(sima)) + if (ED_space_image_show_render(sima)) return 0; - if(ED_space_image_show_paint(sima)) - if(obedit && obedit->type == OB_MESH) { + if (ED_space_image_show_paint(sima)) + if (obedit && obedit->type == OB_MESH) { struct BMEditMesh *em = BMEdit_FromObject(obedit); int ret; @@ -328,13 +328,13 @@ ARegion *image_has_buttons_region(ScrArea *sa) ARegion *ar, *arnew; ar= BKE_area_find_region_type(sa, RGN_TYPE_UI); - if(ar) return ar; + if (ar) return ar; /* add subdiv level; after header */ ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER); /* is error! */ - if(ar==NULL) return NULL; + if (ar==NULL) return NULL; arnew= MEM_callocN(sizeof(ARegion), "buttons for image"); @@ -352,13 +352,13 @@ ARegion *image_has_scope_region(ScrArea *sa) ARegion *ar, *arnew; ar= BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW); - if(ar) return ar; + if (ar) return ar; /* add subdiv level; after buttons */ ar= BKE_area_find_region_type(sa, RGN_TYPE_UI); /* is error! */ - if(ar==NULL) return NULL; + if (ar==NULL) return NULL; arnew= MEM_callocN(sizeof(ARegion), "scopes for image"); @@ -429,7 +429,7 @@ static void image_free(SpaceLink *sl) { SpaceImage *simage= (SpaceImage*) sl; - if(simage->cumap) + if (simage->cumap) curvemapping_free(simage->cumap); scopes_free(&simage->scopes); } @@ -450,7 +450,7 @@ static SpaceLink *image_duplicate(SpaceLink *sl) SpaceImage *simagen= MEM_dupallocN(sl); /* clear or remove stuff from old */ - if(simagen->cumap) + if (simagen->cumap) simagen->cumap= curvemapping_copy(simagen->cumap); scopes_new(&simagen->scopes); @@ -548,8 +548,8 @@ static void image_keymap(struct wmKeyConfig *keyconf) /* dropboxes */ static int image_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) { - if(drag->type==WM_DRAG_PATH) - if(ELEM3(drag->icon, 0, ICON_FILE_IMAGE, ICON_FILE_BLANK)) /* rule might not work? */ + if (drag->type==WM_DRAG_PATH) + if (ELEM3(drag->icon, 0, ICON_FILE_IMAGE, ICON_FILE_BLANK)) /* rule might not work? */ return 1; return 0; } @@ -579,25 +579,25 @@ static void image_refresh(const bContext *C, ScrArea *UNUSED(sa)) ima= ED_space_image(sima); - if(sima->iuser.flag & IMA_ANIM_ALWAYS) + if (sima->iuser.flag & IMA_ANIM_ALWAYS) BKE_image_user_calc_frame(&sima->iuser, scene->r.cfra, 0); /* check if we have to set the image from the editmesh */ - if(ima && (ima->source==IMA_SRC_VIEWER || sima->pin)); - else if(obedit && obedit->type == OB_MESH) { + if (ima && (ima->source==IMA_SRC_VIEWER || sima->pin)); + else if (obedit && obedit->type == OB_MESH) { Mesh *me= (Mesh*)obedit->data; struct BMEditMesh *em= me->edit_btmesh; int sloppy= 1; /* partially selected face is ok */ - if(scene_use_new_shading_nodes(scene)) { + if (scene_use_new_shading_nodes(scene)) { /* new shading system, get image from material */ BMFace *efa = BM_active_face_get(em->bm, sloppy); - if(efa) { + if (efa) { Image *node_ima; ED_object_get_active_image(obedit, efa->mat_nr, &node_ima, NULL, NULL); - if(node_ima) + if (node_ima) sima->image= node_ima; } } @@ -605,16 +605,16 @@ static void image_refresh(const bContext *C, ScrArea *UNUSED(sa)) /* old shading system, we set texface */ MTexPoly *tf; - if(em && EDBM_texFaceCheck(em)) { + if (em && EDBM_texFaceCheck(em)) { sima->image= NULL; tf = EDBM_get_active_mtexpoly(em, NULL, TRUE); /* partially selected face is ok */ - if(tf) { + if (tf) { /* don't need to check for pin here, see above */ sima->image= tf->tpage; - if(sima->flag & SI_EDITTILE); + if (sima->flag & SI_EDITTILE); else sima->curtile= tf->tile; } } @@ -653,7 +653,7 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_SPACE: - if(wmn->data == ND_SPACE_IMAGE) { + if (wmn->data == ND_SPACE_IMAGE) { image_scopes_tag_refresh(sa); ED_area_tag_redraw(sa); } @@ -673,7 +673,7 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn) switch(wmn->data) { case ND_TRANSFORM: case ND_MODIFIER: - if(ob && (ob->mode & OB_MODE_EDIT) && sima->lock && (sima->flag & SI_DRAWSHADOW)) { + if (ob && (ob->mode & OB_MODE_EDIT) && sima->lock && (sima->flag & SI_DRAWSHADOW)) { ED_area_tag_refresh(sa); ED_area_tag_redraw(sa); } @@ -689,10 +689,10 @@ static int image_context(const bContext *C, const char *member, bContextDataResu { SpaceImage *sima= CTX_wm_space_image(C); - if(CTX_data_dir(member)) { + if (CTX_data_dir(member)) { CTX_data_dir_set(result, image_context_dir); } - else if(CTX_data_equals(member, "edit_image")) { + else if (CTX_data_equals(member, "edit_image")) { CTX_data_id_pointer_set(result, (ID*)ED_space_image(sima)); return 1; } @@ -710,7 +710,7 @@ static void image_main_area_set_view2d(SpaceImage *sima, ARegion *ar) int width, height, winx, winy; #if 0 - if(image_preview_active(curarea, &width, &height)); + if (image_preview_active(curarea, &width, &height)); else #endif ED_space_image_size(sima, &width, &height); @@ -718,7 +718,7 @@ static void image_main_area_set_view2d(SpaceImage *sima, ARegion *ar) w= width; h= height; - if(ima) + if (ima) h *= ima->aspy/ima->aspx; winx= ar->winrct.xmax - ar->winrct.xmin + 1; @@ -869,7 +869,7 @@ static void image_buttons_area_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; case NC_BRUSH: - if(wmn->action==NA_EDITED) + if (wmn->action==NA_EDITED) ED_region_tag_redraw(ar); break; case NC_TEXTURE: @@ -900,7 +900,7 @@ static void image_scope_area_draw(const bContext *C, ARegion *ar) Scene *scene= CTX_data_scene(C); void *lock; ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock); - if(ibuf) { + if (ibuf) { scopes_update(&sima->scopes, ibuf, scene->r.color_mgt_flag & R_COLOR_MANAGEMENT ); } ED_space_image_release_buffer(sima, lock); |