From aab8196a1c16a1695a168c486fc6883953f97722 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Tue, 19 Jan 2010 01:32:06 +0000 Subject: Finished some work from the weekend to keep local tree clean.. * Added a generic 'histogram' ui control, currently available in new image editor 'scopes' region (shortcut P). Shows the histogram of the currently viewed image. It's a baby step in unifying the functionality and code from the sequence editor, so eventually we can migrate the sequence preview to the image editor too, like compositor. Still a couple of rough edges to tweak, regarding when it updates. Also would be very nice to have this region as a partially transparent overlapping region... --- source/blender/editors/space_image/image_buttons.c | 21 ++++++ source/blender/editors/space_image/image_draw.c | 15 ++++ source/blender/editors/space_image/image_intern.h | 2 + source/blender/editors/space_image/image_ops.c | 3 +- source/blender/editors/space_image/space_image.c | 86 +++++++++++++++++++++- 5 files changed, 125 insertions(+), 2 deletions(-) (limited to 'source/blender/editors/space_image') diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 6b92fc3fe4f..e740b355727 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -1036,5 +1036,26 @@ void IMAGE_OT_properties(wmOperatorType *ot) ot->flag= 0; } +static int image_scopes(bContext *C, wmOperator *op) +{ + ScrArea *sa= CTX_wm_area(C); + ARegion *ar= image_has_scope_region(sa); + + if(ar) + ED_region_toggle_hidden(C, ar); + + return OPERATOR_FINISHED; +} +void IMAGE_OT_scopes(wmOperatorType *ot) +{ + ot->name= "Scopes"; + ot->idname= "IMAGE_OT_scopes"; + + ot->exec= image_scopes; + ot->poll= ED_operator_image_active; + + /* flags */ + ot->flag= 0; +} diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index ea526b13219..2b2f1f0b3e4 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -204,6 +204,16 @@ void draw_image_info(ARegion *ar, int channels, int x, int y, char *cp, float *f UI_DrawString(10, 10, str); } +static inline int get_bin_float(float f) +{ + CLAMP(f, 0.0, 1.0); + + //return (int) (((f + 0.25) / 1.5) * 512); + + return (int)(f * 511); +} + + /* image drawing */ static void draw_image_grid(ARegion *ar, float zoomx, float zoomy) @@ -702,6 +712,11 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene) if(ibuf && ima && show_render) draw_render_info(ima, ar); + /* histogram */ + if (ibuf) { + histogram_update(&sima->hist, ibuf); + } + /* XXX integrate this code */ #if 0 if(ibuf) { diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h index a33475c1213..b7f81245296 100644 --- a/source/blender/editors/space_image/image_intern.h +++ b/source/blender/editors/space_image/image_intern.h @@ -44,6 +44,7 @@ struct bNodeTree; /* space_image.c */ struct ARegion *image_has_buttons_region(struct ScrArea *sa); +struct ARegion *image_has_scope_region(struct ScrArea *sa); /* image_header.c */ void image_header_buttons(const struct bContext *C, struct ARegion *ar); @@ -88,6 +89,7 @@ void draw_uvedit_main(struct SpaceImage *sima, struct ARegion *ar, struct Scene struct ImageUser *ntree_get_active_iuser(struct bNodeTree *ntree); void image_buttons_register(struct ARegionType *art); void IMAGE_OT_properties(struct wmOperatorType *ot); +void IMAGE_OT_scopes(struct wmOperatorType *ot); #endif /* ED_IMAGE_INTERN_H */ diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index cef92153725..6b901814634 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -704,7 +704,8 @@ static int open_exec(bContext *C, wmOperator *op) // XXX other users? BKE_image_signal(ima, (sima)? &sima->iuser: NULL, IMA_SIGNAL_RELOAD); - + WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, ima); + MEM_freeN(op->customdata); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 6c325d9722f..62021f824ae 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -104,6 +104,33 @@ ARegion *image_has_buttons_region(ScrArea *sa) return arnew; } +ARegion *image_has_scope_region(ScrArea *sa) +{ + ARegion *ar, *arnew; + + for(ar= sa->regionbase.first; ar; ar= ar->next) + if(ar->regiontype==RGN_TYPE_PREVIEW) + return ar; + + /* add subdiv level; after buttons */ + for(ar= sa->regionbase.first; ar; ar= ar->next) + if(ar->regiontype==RGN_TYPE_UI) + break; + + /* is error! */ + if(ar==NULL) return NULL; + + arnew= MEM_callocN(sizeof(ARegion), "scopes for image"); + + BLI_insertlinkafter(&sa->regionbase, ar, arnew); + arnew->regiontype= RGN_TYPE_PREVIEW; + arnew->alignment= RGN_ALIGN_RIGHT; + + arnew->flag = RGN_FLAG_HIDDEN; + + return arnew; +} + /* ******************** default callbacks for image space ***************** */ static SpaceLink *image_new(const bContext *C) @@ -135,6 +162,14 @@ static SpaceLink *image_new(const bContext *C) ar->alignment= RGN_ALIGN_LEFT; ar->flag = RGN_FLAG_HIDDEN; + /* scopes */ + ar= MEM_callocN(sizeof(ARegion), "buttons for image"); + + BLI_addtail(&simage->regionbase, ar); + ar->regiontype= RGN_TYPE_PREVIEW; + ar->alignment= RGN_ALIGN_RIGHT; + ar->flag = RGN_FLAG_HIDDEN; + /* main area */ ar= MEM_callocN(sizeof(ARegion), "main area for image"); @@ -201,6 +236,7 @@ void image_operatortypes(void) WM_operatortype_append(IMAGE_OT_toolbox); WM_operatortype_append(IMAGE_OT_properties); + WM_operatortype_append(IMAGE_OT_scopes); } void image_keymap(struct wmKeyConfig *keyconf) @@ -213,6 +249,7 @@ void image_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "IMAGE_OT_save", SKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "IMAGE_OT_save_as", F3KEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "IMAGE_OT_properties", NKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "IMAGE_OT_scopes", PKEY, KM_PRESS, 0, 0); keymap= WM_keymap_find(keyconf, "Image", SPACE_IMAGE, 0); @@ -278,8 +315,16 @@ static void image_refresh(const bContext *C, ScrArea *sa) } } +static void image_histogram_tag_refresh(ScrArea *sa) +{ + SpaceImage *sima= (SpaceImage *)sa->spacedata.first; + sima->hist.ok=0; +} + static void image_listener(ScrArea *sa, wmNotifier *wmn) { + SpaceImage *sima= (SpaceImage *)sa->spacedata.first; + /* context changes */ switch(wmn->category) { case NC_SCENE: @@ -293,7 +338,11 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_IMAGE: - ED_area_tag_redraw(sa); + if (wmn->reference == sima->image) { + image_histogram_tag_refresh(sa); + ED_area_tag_refresh(sa); + ED_area_tag_redraw(sa); + } break; case NC_SPACE: if(wmn->data == ND_SPACE_IMAGE) @@ -486,6 +535,31 @@ static void image_buttons_area_listener(ARegion *ar, wmNotifier *wmn) } } +/* *********************** scopes region ************************ */ + +/* add handlers, stuff you only do once or on area/region changes */ +static void image_scope_area_init(wmWindowManager *wm, ARegion *ar) +{ + wmKeyMap *keymap; + + ED_region_panels_init(wm, ar); + + keymap= WM_keymap_find(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0); + WM_event_add_keymap_handler(&ar->handlers, keymap); +} + +static void image_scope_area_draw(const bContext *C, ARegion *ar) +{ + ED_region_panels(C, ar, 1, NULL, -1); +} + +static void image_scope_area_listener(ARegion *ar, wmNotifier *wmn) +{ + /* context changes */ + switch(wmn->category) { + } +} + /************************* header region **************************/ /* add handlers, stuff you only do once or on area/region changes */ @@ -541,6 +615,16 @@ void ED_spacetype_image(void) BLI_addhead(&st->regiontypes, art); image_buttons_register(art); + + /* regions: statistics/scope buttons */ + art= MEM_callocN(sizeof(ARegionType), "spacetype image region"); + art->regionid = RGN_TYPE_PREVIEW; + art->minsizex= 220; // XXX + art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES; + art->listener= image_scope_area_listener; + art->init= image_scope_area_init; + art->draw= image_scope_area_draw; + BLI_addhead(&st->regiontypes, art); /* regions: header */ art= MEM_callocN(sizeof(ARegionType), "spacetype image region"); -- cgit v1.2.3 From 2fa3baf30b3ea1b6c681517efb4b122c2a512175 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Tue, 19 Jan 2010 02:26:36 +0000 Subject: * Make image Histogram only update when region is visible * Clean up some remaining code --- source/blender/editors/space_image/image_draw.c | 10 ---------- source/blender/editors/space_image/space_image.c | 23 +++++++++++++++++------ 2 files changed, 17 insertions(+), 16 deletions(-) (limited to 'source/blender/editors/space_image') diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 2b2f1f0b3e4..8889ca5c052 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -204,16 +204,6 @@ void draw_image_info(ARegion *ar, int channels, int x, int y, char *cp, float *f UI_DrawString(10, 10, str); } -static inline int get_bin_float(float f) -{ - CLAMP(f, 0.0, 1.0); - - //return (int) (((f + 0.25) / 1.5) * 512); - - return (int)(f * 511); -} - - /* image drawing */ static void draw_image_grid(ARegion *ar, float zoomx, float zoomy) diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 62021f824ae..0a3367b0427 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -75,6 +75,21 @@ #include "image_intern.h" + +static void image_histogram_tag_refresh(ScrArea *sa) +{ + SpaceImage *sima= (SpaceImage *)sa->spacedata.first; + ARegion *ar; + + /* only while histogram is visible */ + for (ar=sa->regionbase.first; ar; ar=ar->next) { + if (ar->regiontype == RGN_TYPE_PREVIEW && ar->flag & RGN_FLAG_HIDDEN) + return; + } + + sima->hist.ok=0; +} + /* ******************** manage regions ********************* */ ARegion *image_has_buttons_region(ScrArea *sa) @@ -128,6 +143,8 @@ ARegion *image_has_scope_region(ScrArea *sa) arnew->flag = RGN_FLAG_HIDDEN; + image_histogram_tag_refresh(sa); + return arnew; } @@ -315,12 +332,6 @@ static void image_refresh(const bContext *C, ScrArea *sa) } } -static void image_histogram_tag_refresh(ScrArea *sa) -{ - SpaceImage *sima= (SpaceImage *)sa->spacedata.first; - sima->hist.ok=0; -} - static void image_listener(ScrArea *sa, wmNotifier *wmn) { SpaceImage *sima= (SpaceImage *)sa->spacedata.first; -- cgit v1.2.3 From abb5214a8f47f65030e5d0bec8cd974e9ade4248 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 19 Jan 2010 14:04:33 +0000 Subject: removed 3D view listener for changing the background image frame. do this on drawing instead since SCREEN_OT_animation_step isnt calling the notifier (assume this is to be more efficient?). this isnt slow so is ok to do on drawing. rename BKE_image_user_calc_imanr to BKE_image_user_calc_frame --- source/blender/editors/space_image/image_buttons.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors/space_image') diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index e740b355727..c882c8db6c6 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -592,7 +592,7 @@ static void set_frames_cb(bContext *C, void *ima_v, void *iuser_v) if(ima->anim) { iuser->frames = IMB_anim_get_duration(ima->anim); - BKE_image_user_calc_imanr(iuser, scene->r.cfra, 0); + BKE_image_user_calc_frame(iuser, scene->r.cfra, 0); } } -- cgit v1.2.3 From ccb6e1904abf358c0f999019ffd62d407ecc920b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 19 Jan 2010 22:44:43 +0000 Subject: =?UTF-8?q?patch=20from=20Bj=C3=B8rnar=20Hansen=20(anachron)=20Mul?= =?UTF-8?q?tiple=20background=20images=20displaying=20each=20on=20a=20diff?= =?UTF-8?q?erent=20axis.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes made from the original patch. - Use an enum rather then multiple booleans. - Reduced the space taken up by the user interface. - Made the image template compact display not show fields & premul options. - Added readfile.c lines so old blendfile images are loaded. - Option to hide BGpic UI (like modifiers & constraints) - Use the index rather then a bgpic from the context for the remove operator. note: could be good to use 1 image for both left+right, for eg, but for this to work as intended we would need to add image flipping depending on the axis so left this commented out for now. --- source/blender/editors/space_image/image_buttons.c | 32 ++++++++++++---------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'source/blender/editors/space_image') diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index c882c8db6c6..94df99d9c8d 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -888,26 +888,30 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propn uiblock_layer_pass_arrow_buttons(layout, ima->rr, iuser); } else if(ima->source != IMA_SRC_GENERATED) { - ibuf= BKE_image_acquire_ibuf(ima, iuser, &lock); - image_info(ima, ibuf, str); - BKE_image_release_ibuf(ima, lock); - uiItemL(layout, str, 0); + if(compact == 0) { + ibuf= BKE_image_acquire_ibuf(ima, iuser, &lock); + image_info(ima, ibuf, str); + BKE_image_release_ibuf(ima, lock); + uiItemL(layout, str, 0); + } } if(ima->source != IMA_SRC_GENERATED) { - uiItemS(layout); + if(compact == 0) { /* background image view doesnt need these */ + uiItemS(layout); - split= uiLayoutSplit(layout, 0, 0); + split= uiLayoutSplit(layout, 0, 0); - col= uiLayoutColumn(split, 0); - uiItemR(col, NULL, 0, &imaptr, "fields", 0); - row= uiLayoutRow(col, 0); - uiItemR(row, NULL, 0, &imaptr, "field_order", UI_ITEM_R_EXPAND); - uiLayoutSetActive(row, RNA_boolean_get(&imaptr, "fields")); + col= uiLayoutColumn(split, 0); + uiItemR(col, NULL, 0, &imaptr, "fields", 0); + row= uiLayoutRow(col, 0); + uiItemR(row, NULL, 0, &imaptr, "field_order", UI_ITEM_R_EXPAND); + uiLayoutSetActive(row, RNA_boolean_get(&imaptr, "fields")); - col= uiLayoutColumn(split, 0); - uiItemR(col, NULL, 0, &imaptr, "antialias", 0); - uiItemR(col, NULL, 0, &imaptr, "premultiply", 0); + col= uiLayoutColumn(split, 0); + uiItemR(col, NULL, 0, &imaptr, "antialias", 0); + uiItemR(col, NULL, 0, &imaptr, "premultiply", 0); + } } if(ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { -- cgit v1.2.3 From 1d3186cbcf9e3e463e4e6362ac76862b801cf7ba Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Wed, 20 Jan 2010 04:19:55 +0000 Subject: Durian request: Added 'Color Balance' node to compositor. uses Lift/Gamma/Gain similar to sequence editor. --> http://mke3.net/blender/devel/2.5/color_balance_node.jpg Also added 0 key (zero key) shortcut when mouse is over a button, to reset it to its default value. Same as the RMB menu ->Reset to Default, except for color wheels, it only resets the hue/sat/value components that that widget affects. Peter/Xavier: The existing color balance code can generate NaNs (fractional power of a negative), which causes havoc along the image pipeline. I added a check in the node code to prevent this. Still plenty of potential for lots of better colour correction tools in the compositor, just needs time... --- source/blender/editors/space_image/space_image.c | 445 ++++++++++++----------- 1 file changed, 224 insertions(+), 221 deletions(-) (limited to 'source/blender/editors/space_image') diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 0a3367b0427..34737c62450 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -75,6 +75,228 @@ #include "image_intern.h" +/**************************** common state *****************************/ + +/* note; image_panel_properties() uses pointer to sima->image directly */ +Image *ED_space_image(SpaceImage *sima) +{ + return sima->image; +} + +/* called to assign images to UV faces */ +void ED_space_image_set(bContext *C, SpaceImage *sima, Scene *scene, Object *obedit, Image *ima) +{ + ED_uvedit_assign_image(scene, obedit, ima, sima->image); + + /* change the space ima after because uvedit_face_visible uses the space ima + * 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) + sima->flag &= ~SI_DRAWTOOL; + + if(sima->image) + BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE); + + if(sima->image && sima->image->id.us==0) + sima->image->id.us= 1; + + if(C) { + if(obedit) + WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + + ED_area_tag_redraw(CTX_wm_area(C)); + } +} + +ImBuf *ED_space_image_acquire_buffer(SpaceImage *sima, void **lock_r) +{ + ImBuf *ibuf; + + if(sima && sima->image) { +#if 0 + 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)) + return ibuf; + } + + return NULL; +} + +void ED_space_image_release_buffer(SpaceImage *sima, void *lock) +{ + if(sima && sima->image) + BKE_image_release_ibuf(sima->image, lock); +} + +int ED_space_image_has_buffer(SpaceImage *sima) +{ + ImBuf *ibuf; + void *lock; + int has_buffer; + + ibuf= ED_space_image_acquire_buffer(sima, &lock); + has_buffer= (ibuf != NULL); + ED_space_image_release_buffer(sima, lock); + + return has_buffer; +} + +void ED_image_size(Image *ima, int *width, int *height) +{ + ImBuf *ibuf= NULL; + void *lock; + + if(ima) + ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock); + + if(ibuf && ibuf->x > 0 && ibuf->y > 0) { + *width= ibuf->x; + *height= ibuf->y; + } + else { + *width= 256; + *height= 256; + } + + if(ima) + BKE_image_release_ibuf(ima, lock); +} + +void ED_space_image_size(SpaceImage *sima, int *width, int *height) +{ + Scene *scene= sima->iuser.scene; + ImBuf *ibuf; + void *lock; + + ibuf= ED_space_image_acquire_buffer(sima, &lock); + + 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) { + /* not very important, just nice */ + *width= (scene->r.xsch*scene->r.size)/100; + *height= (scene->r.ysch*scene->r.size)/100; + } + /* I know a bit weak... but preview uses not actual image size */ + // XXX else if(image_preview_active(sima, width, height)); + else { + *width= 256; + *height= 256; + } + + ED_space_image_release_buffer(sima, lock); +} + +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) || + (ima->aspx==0.0 || ima->aspy==0.0)) + return; + + /* x is always 1 */ + *aspy = ima->aspy/ima->aspx; +} + +void ED_space_image_aspect(SpaceImage *sima, float *aspx, float *aspy) +{ + ED_image_aspect(ED_space_image(sima), aspx, aspy); +} + +void ED_space_image_zoom(SpaceImage *sima, ARegion *ar, float *zoomx, float *zoomy) +{ + int width, height; + + ED_space_image_size(sima, &width, &height); + + *zoomx= (float)(ar->winrct.xmax - ar->winrct.xmin)/(float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin)*width); + *zoomy= (float)(ar->winrct.ymax - ar->winrct.ymin)/(float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin)*height); +} + +void ED_space_image_uv_aspect(SpaceImage *sima, float *aspx, float *aspy) +{ + int w, h; + + ED_space_image_aspect(sima, aspx, aspy); + ED_space_image_size(sima, &w, &h); + + *aspx *= (float)w/256.0f; + *aspy *= (float)h/256.0f; +} + +void ED_image_uv_aspect(Image *ima, float *aspx, float *aspy) +{ + int w, h; + + ED_image_aspect(ima, aspx, aspy); + ED_image_size(ima, &w, &h); + + *aspx *= (float)w; + *aspy *= (float)h; +} + +int ED_space_image_show_render(SpaceImage *sima) +{ + return (sima->image && ELEM(sima->image->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)); +} + +int ED_space_image_show_paint(SpaceImage *sima) +{ + if(ED_space_image_show_render(sima)) + return 0; + + return (sima->flag & SI_DRAWTOOL); +} + +int ED_space_image_show_uvedit(SpaceImage *sima, Object *obedit) +{ + if(ED_space_image_show_render(sima)) + return 0; + if(ED_space_image_show_paint(sima)) + return 0; + + if(obedit && obedit->type == OB_MESH) { + EditMesh *em = BKE_mesh_get_editmesh(obedit->data); + int ret; + + ret = EM_texFaceCheck(em); + + BKE_mesh_end_editmesh(obedit->data, em); + return ret; + } + + return 0; +} + +int ED_space_image_show_uvshadow(SpaceImage *sima, Object *obedit) +{ + if(ED_space_image_show_render(sima)) + return 0; + + if(ED_space_image_show_paint(sima)) + if(obedit && obedit->type == OB_MESH) { + EditMesh *em = BKE_mesh_get_editmesh(obedit->data); + int ret; + + ret = EM_texFaceCheck(em); + + BKE_mesh_end_editmesh(obedit->data, em); + return ret; + } + + return 0; +} + + static void image_histogram_tag_refresh(ScrArea *sa) { @@ -343,6 +565,8 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn) case ND_MODE: case ND_RENDER_RESULT: case ND_COMPO_RESULT: + if (ED_space_image_show_render(sima)) + image_histogram_tag_refresh(sa); ED_area_tag_refresh(sa); ED_area_tag_redraw(sa); break; @@ -650,224 +874,3 @@ void ED_spacetype_image(void) BKE_spacetype_register(st); } -/**************************** common state *****************************/ - -/* note; image_panel_properties() uses pointer to sima->image directly */ -Image *ED_space_image(SpaceImage *sima) -{ - return sima->image; -} - -/* called to assign images to UV faces */ -void ED_space_image_set(bContext *C, SpaceImage *sima, Scene *scene, Object *obedit, Image *ima) -{ - ED_uvedit_assign_image(scene, obedit, ima, sima->image); - - /* change the space ima after because uvedit_face_visible uses the space ima - * 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) - sima->flag &= ~SI_DRAWTOOL; - - if(sima->image) - BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE); - - if(sima->image && sima->image->id.us==0) - sima->image->id.us= 1; - - if(C) { - if(obedit) - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); - - ED_area_tag_redraw(CTX_wm_area(C)); - } -} - -ImBuf *ED_space_image_acquire_buffer(SpaceImage *sima, void **lock_r) -{ - ImBuf *ibuf; - - if(sima && sima->image) { -#if 0 - 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)) - return ibuf; - } - - return NULL; -} - -void ED_space_image_release_buffer(SpaceImage *sima, void *lock) -{ - if(sima && sima->image) - BKE_image_release_ibuf(sima->image, lock); -} - -int ED_space_image_has_buffer(SpaceImage *sima) -{ - ImBuf *ibuf; - void *lock; - int has_buffer; - - ibuf= ED_space_image_acquire_buffer(sima, &lock); - has_buffer= (ibuf != NULL); - ED_space_image_release_buffer(sima, lock); - - return has_buffer; -} - -void ED_image_size(Image *ima, int *width, int *height) -{ - ImBuf *ibuf= NULL; - void *lock; - - if(ima) - ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock); - - if(ibuf && ibuf->x > 0 && ibuf->y > 0) { - *width= ibuf->x; - *height= ibuf->y; - } - else { - *width= 256; - *height= 256; - } - - if(ima) - BKE_image_release_ibuf(ima, lock); -} - -void ED_space_image_size(SpaceImage *sima, int *width, int *height) -{ - Scene *scene= sima->iuser.scene; - ImBuf *ibuf; - void *lock; - - ibuf= ED_space_image_acquire_buffer(sima, &lock); - - 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) { - /* not very important, just nice */ - *width= (scene->r.xsch*scene->r.size)/100; - *height= (scene->r.ysch*scene->r.size)/100; - } - /* I know a bit weak... but preview uses not actual image size */ - // XXX else if(image_preview_active(sima, width, height)); - else { - *width= 256; - *height= 256; - } - - ED_space_image_release_buffer(sima, lock); -} - -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) || - (ima->aspx==0.0 || ima->aspy==0.0)) - return; - - /* x is always 1 */ - *aspy = ima->aspy/ima->aspx; -} - -void ED_space_image_aspect(SpaceImage *sima, float *aspx, float *aspy) -{ - ED_image_aspect(ED_space_image(sima), aspx, aspy); -} - -void ED_space_image_zoom(SpaceImage *sima, ARegion *ar, float *zoomx, float *zoomy) -{ - int width, height; - - ED_space_image_size(sima, &width, &height); - - *zoomx= (float)(ar->winrct.xmax - ar->winrct.xmin)/(float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin)*width); - *zoomy= (float)(ar->winrct.ymax - ar->winrct.ymin)/(float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin)*height); -} - -void ED_space_image_uv_aspect(SpaceImage *sima, float *aspx, float *aspy) -{ - int w, h; - - ED_space_image_aspect(sima, aspx, aspy); - ED_space_image_size(sima, &w, &h); - - *aspx *= (float)w/256.0f; - *aspy *= (float)h/256.0f; -} - -void ED_image_uv_aspect(Image *ima, float *aspx, float *aspy) -{ - int w, h; - - ED_image_aspect(ima, aspx, aspy); - ED_image_size(ima, &w, &h); - - *aspx *= (float)w; - *aspy *= (float)h; -} - -int ED_space_image_show_render(SpaceImage *sima) -{ - return (sima->image && ELEM(sima->image->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)); -} - -int ED_space_image_show_paint(SpaceImage *sima) -{ - if(ED_space_image_show_render(sima)) - return 0; - - return (sima->flag & SI_DRAWTOOL); -} - -int ED_space_image_show_uvedit(SpaceImage *sima, Object *obedit) -{ - if(ED_space_image_show_render(sima)) - return 0; - if(ED_space_image_show_paint(sima)) - return 0; - - if(obedit && obedit->type == OB_MESH) { - EditMesh *em = BKE_mesh_get_editmesh(obedit->data); - int ret; - - ret = EM_texFaceCheck(em); - - BKE_mesh_end_editmesh(obedit->data, em); - return ret; - } - - return 0; -} - -int ED_space_image_show_uvshadow(SpaceImage *sima, Object *obedit) -{ - if(ED_space_image_show_render(sima)) - return 0; - - if(ED_space_image_show_paint(sima)) - if(obedit && obedit->type == OB_MESH) { - EditMesh *em = BKE_mesh_get_editmesh(obedit->data); - int ret; - - ret = EM_texFaceCheck(em); - - BKE_mesh_end_editmesh(obedit->data, em); - return ret; - } - - return 0; -} - -- cgit v1.2.3 From 02ca0fda8ea86c5b5b05b8d1ef6cc81e8f280523 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Wed, 20 Jan 2010 08:30:40 +0000 Subject: Moved the image paint tool and the vertex/weight paint tool (blend mode?) to the Brush data. This now works the same way as sculpt, with named preset brushes that retain settings. --- source/blender/editors/space_image/image_draw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors/space_image') diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 8889ca5c052..69d0156d2fa 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -625,7 +625,7 @@ static void draw_image_paint_helpers(SpaceImage *sima, ARegion *ar, Scene *scene brush= paint_brush(&scene->toolsettings->imapaint.paint); - if(brush && (scene->toolsettings->imapaint.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); -- cgit v1.2.3 From 38aacb92f32ef5ea80a5e9b4b7b2757a6cc4b8bf Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Fri, 22 Jan 2010 06:48:29 +0000 Subject: Cleaned up some printfs in editors/ - converted some to reports, hid others behind G_DEBUG. --- source/blender/editors/space_image/image_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors/space_image') diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 6b901814634..b730f075f8f 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1079,7 +1079,7 @@ static int save_sequence_exec(bContext *C, wmOperator *op) break; } - printf("Saved: %s\n", ibuf->name); + BKE_reportf(op->reports, RPT_INFO, "Saved: %s\n", ibuf->name); ibuf->userflags &= ~IB_BITMAPDIRTY; } } -- cgit v1.2.3 From 38111eb224f08c7e5afddd6b4b429a61fa0106bc Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 26 Jan 2010 11:36:48 +0000 Subject: Patch #20800: uv editor zoom rate not properly calculated, uv's were drawn slightly offset from the image. Patch by Masahito Takahashi, thanks! --- source/blender/editors/space_image/space_image.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/editors/space_image') diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 34737c62450..33b4e37dc8f 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -218,8 +218,8 @@ void ED_space_image_zoom(SpaceImage *sima, ARegion *ar, float *zoomx, float *zoo ED_space_image_size(sima, &width, &height); - *zoomx= (float)(ar->winrct.xmax - ar->winrct.xmin)/(float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin)*width); - *zoomy= (float)(ar->winrct.ymax - ar->winrct.ymin)/(float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin)*height); + *zoomx= (float)(ar->winrct.xmax - ar->winrct.xmin + 1)/(float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin)*width); + *zoomy= (float)(ar->winrct.ymax - ar->winrct.ymin + 1)/(float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin)*height); } void ED_space_image_uv_aspect(SpaceImage *sima, float *aspx, float *aspy) -- cgit v1.2.3 From b119ce5fcc91466c6aeb1232e8bf4dca401adaed Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 26 Jan 2010 18:18:21 +0000 Subject: Drag and drop 2.5 integration! Finally, slashdot regulars can use Blender too now! :) ** Drag works as follows: - drag-able items are defined by the standard interface ui toolkit - each button can get this feature, via uiButSetDragXXX(but, ...). There are calls to define drag-able images, ID blocks, RNA paths, file paths, and so on. By default you drag an icon, exceptionally an ImBuf - Drag items are registered centrally in the WM, it allows more drag items simultaneous too, but not implemented ** Drop works as follows: - On mouse release, and if drag items exist in the WM, it converts the mouse event to an EVT_DROP type. This event then gets the full drag info as customdata - drop regions are defined with WM_dropbox_add(), similar to keymaps you can make a "drop map" this way, which become 'drop map handlers' in the queues. - next to that the UI kit handles some common button types (like accepting ID or names) to be catching a drop event too. - Every "drop box" has two callbacks: - poll() = check if the event drag data is relevant for this box - copy() = fill in custom properties in the dropbox to initialize an operator - The dropbox handler then calls its standard Operator with its dropbox properties. ** Currently implemented Drag items: - ID icons in browse buttons - ID icons in context menu of properties region - ID icons in outliner and rna viewer - FileBrowser icons - FileBrowser preview images Drag-able icons are subtly visualized by making them brighter a bit on mouse-over. In case the icon is a button or UI element too (most cases), the drag-able feature will make the item react to mouse-release instead of mouse-press. Drop options: - UI buttons: ID and text buttons (paste name) - View3d: Object ID drop copies object - View3d: Material ID drop assigns to object under cursor - View3d: Image ID drop assigns to object UV texture under cursor - Sequencer: Path drop will add either Image or Movie strip - Image window: Path drop will open image ** Drag and drop Notes: - Dropping into another Blender window (from same application) works too. I've added code that passes on mousemoves and clicks to other windows, without activating them though. This does make using multi-window Blender a bit friendler. - Dropping a file path to an image, is not the same as dropping an Image ID... keep this in mind. Sequencer for example wants paths to be dropped, textures in 3d window wants an Image ID. - Although drop boxes could be defined via Python, I suggest they're part of the UI and editor design (= how we want an editor to work), and not default offered configurable like keymaps. - At the moment only one item can be dragged at a time. This is for several reasons.... For one, Blender doesn't have a well defined uniform way to define "what is selected" (files, outliner items, etc). Secondly there's potential conflicts on what todo when you drop mixed drag sets on spots. All undefined stuff... nice for later. - Example to bypass the above: a collection of images that form a strip, should be represented in filewindow as a single sequence anyway. This then will fit well and gets handled neatly by design. - Another option to check is to allow multiple options per drop... it could show the operator as a sort of menu, allowing arrow or scrollwheel to choose. For time being I'd prefer to try to design a singular drop though, just offer only one drop action per data type on given spots. - What does work already, but a tad slow, is to use a function that detects an object (type) under cursor, so a drag item's option can be further refined (like drop object on object = parent). (disabled) ** More notes - Added saving for Region layouts (like split points for toolbar) - Label buttons now handle mouse over - File list: added full path entry for drop feature. - Filesel bugfix: wm_operator_exec() got called there and fully handled, while WM event code tried same. Added new OPERATOR_HANDLED flag for this. Maybe python needs it too? - Cocoa: added window move event, so multi-win setups work OK (didnt save). - Interface_handlers.c: removed win->active - Severe area copy bug: area handlers were not set to NULL - Filesel bugfix: next/prev folder list was not copied on area copies ** Leftover todos - Cocoa windows seem to hang on cases still... needs check - Cocoa 'draw overlap' swap doesn't work - Cocoa window loses focus permanently on using Spotlight (for these reasons, makefile building has Carbon as default atm) - ListView templates in UI cannot become dragged yet, needs review... it consists of two overlapping UI elements, preventing handling icon clicks. - There's already Ghost library code to handle dropping from OS into Blender window. I've noticed this code is unfinished for Macs, but seems to be complete for Windows. Needs test... currently, an external drop event will print in console when succesfully delivered to Blender's WM. --- source/blender/editors/space_image/space_image.c | 37 ++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'source/blender/editors/space_image') diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 33b4e37dc8f..ad3407a7414 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -431,10 +431,14 @@ static void image_free(SpaceLink *sl) } -/* spacetype; init callback */ +/* spacetype; init callback, add handlers */ static void image_init(struct wmWindowManager *wm, ScrArea *sa) { + ListBase *lb= WM_dropboxmap_find("Image", SPACE_IMAGE, 0); + /* add drop boxes */ + WM_event_add_dropbox_handler(&sa->handlers, lb); + } static SpaceLink *image_duplicate(SpaceLink *sl) @@ -521,6 +525,31 @@ void image_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "IMAGE_OT_toolbox", SPACEKEY, KM_PRESS, 0, 0); } +/* dropboxes */ +static int image_drop_poll(bContext *C, wmDrag *drag, wmEvent *event) +{ + if(drag->type==WM_DRAG_PATH) + if(ELEM(drag->icon, ICON_FILE_IMAGE, ICON_FILE_BLANK)) /* rule might not work? */ + return 1; + return 0; +} + +static void image_drop_copy(wmDrag *drag, wmDropBox *drop) +{ + /* copy drag path to properties */ + RNA_string_set(drop->ptr, "path", drag->path); +} + +/* area+region dropbox definition */ +static void image_dropboxes(void) +{ + ListBase *lb= WM_dropboxmap_find("Image", SPACE_IMAGE, 0); + + WM_dropbox_add(lb, "IMAGE_OT_open", image_drop_poll, image_drop_copy); +} + + + static void image_refresh(const bContext *C, ScrArea *sa) { SpaceImage *sima= CTX_wm_space_image(C); @@ -685,6 +714,7 @@ static void image_main_area_init(wmWindowManager *wm, ARegion *ar) WM_event_add_keymap_handler(&ar->handlers, keymap); keymap= WM_keymap_find(wm->defaultconf, "Image", SPACE_IMAGE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + } static void image_main_area_draw(const bContext *C, ARegion *ar) @@ -825,6 +855,7 @@ void ED_spacetype_image(void) st->duplicate= image_duplicate; st->operatortypes= image_operatortypes; st->keymap= image_keymap; + st->dropboxes= image_dropboxes; st->refresh= image_refresh; st->listener= image_listener; st->context= image_context; @@ -842,7 +873,7 @@ void ED_spacetype_image(void) /* regions: listview/buttons */ art= MEM_callocN(sizeof(ARegionType), "spacetype image region"); art->regionid = RGN_TYPE_UI; - art->minsizex= 220; // XXX + art->prefsizex= 220; // XXX art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES; art->listener= image_buttons_area_listener; art->init= image_buttons_area_init; @@ -864,7 +895,7 @@ void ED_spacetype_image(void) /* regions: header */ art= MEM_callocN(sizeof(ARegionType), "spacetype image region"); art->regionid = RGN_TYPE_HEADER; - art->minsizey= HEADERY; + art->prefsizey= HEADERY; art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; art->init= image_header_area_init; art->draw= image_header_area_draw; -- cgit v1.2.3 From 904665f15b9a0bc165c6ee60f05f00d66c2ffc07 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Wed, 27 Jan 2010 02:20:24 +0000 Subject: [#20728] "Export UV Layout" overwrites existing files (without feedback) The 'save over' popup was only appearing based on a string comparison of the operator name ("Save"). Changed this to use a hidden operator property: "check_existing". Python operators must have this property for the file selector confirmation too. This property can also be set to false, to prevent checking for existing files, useful in the File->Save menu item to prevent the dangerously missable confirmation popup. --- source/blender/editors/space_image/image_ops.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/editors/space_image') diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index b730f075f8f..7dd26c31658 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -741,7 +741,7 @@ void IMAGE_OT_open(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL); + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPEN); } /******************** replace image operator ********************/ @@ -794,7 +794,7 @@ void IMAGE_OT_replace(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL); + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPEN); } /******************** save image as operator ********************/ @@ -962,7 +962,7 @@ void IMAGE_OT_save_as(wmOperatorType *ot) /* properties */ RNA_def_enum(ot->srna, "file_type", image_file_type_items, R_PNG, "File Type", "File type to save image as."); - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL); + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE); } /******************** save image operator ********************/ -- cgit v1.2.3 From 9d0dbd707e2ccac6b11a6be4c19b9413f96cc3c0 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 28 Jan 2010 07:26:21 +0000 Subject: Fix [#20754] Histogram Not Updating, Showing Incorrect Levels, Colour Management on/off leads to Crash Various internal fixes, also additional feature - can drag on the histogram to change scale (0 key to reset). Also fix [#20844] Color balance node (lift freeze) --- source/blender/editors/space_image/image_draw.c | 5 ----- source/blender/editors/space_image/space_image.c | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) (limited to 'source/blender/editors/space_image') diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 69d0156d2fa..1b801060a23 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -701,11 +701,6 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene) /* render info */ if(ibuf && ima && show_render) draw_render_info(ima, ar); - - /* histogram */ - if (ibuf) { - histogram_update(&sima->hist, ibuf); - } /* XXX integrate this code */ #if 0 diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index ad3407a7414..2a8158de79b 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -815,6 +815,13 @@ static void image_scope_area_init(wmWindowManager *wm, ARegion *ar) static void image_scope_area_draw(const bContext *C, ARegion *ar) { + SpaceImage *sima= CTX_wm_space_image(C); + void *lock; + ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock); + + histogram_update(&sima->hist, ibuf); + ED_space_image_release_buffer(sima, lock); + ED_region_panels(C, ar, 1, NULL, -1); } @@ -822,6 +829,22 @@ static void image_scope_area_listener(ARegion *ar, wmNotifier *wmn) { /* context changes */ switch(wmn->category) { + case NC_SCENE: + switch(wmn->data) { + case ND_MODE: + case ND_RENDER_RESULT: + case ND_COMPO_RESULT: + ED_region_tag_redraw(ar); + break; + } + break; + case NC_IMAGE: + ED_region_tag_redraw(ar); + break; + case NC_NODE: + ED_region_tag_redraw(ar); + break; + } } -- cgit v1.2.3 From 462e7cdb47e643adff5d104b9271144d1ff80aa1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 28 Jan 2010 20:38:12 +0000 Subject: crash with viewing histogram on a blank image --- source/blender/editors/space_image/space_image.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/editors/space_image') diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 2a8158de79b..5a584782237 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -818,8 +818,8 @@ static void image_scope_area_draw(const bContext *C, ARegion *ar) SpaceImage *sima= CTX_wm_space_image(C); void *lock; ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock); - - histogram_update(&sima->hist, ibuf); + if(ibuf) + histogram_update(&sima->hist, ibuf); ED_space_image_release_buffer(sima, lock); ED_region_panels(C, ar, 1, NULL, -1); -- cgit v1.2.3 From cb499c9df4dd1983f74810024119dc204075c0db Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 28 Jan 2010 23:41:34 +0000 Subject: * Partially converted constraint template to layout engine * Removed old code --- source/blender/editors/space_image/image_draw.c | 58 +++---------------------- 1 file changed, 6 insertions(+), 52 deletions(-) (limited to 'source/blender/editors/space_image') diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 1b801060a23..6e883405ef8 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -68,47 +68,6 @@ #define HEADER_HEIGHT 18 -#if 0 -static int image_preview_active(SpaceImage *sima, Scene *scene, float *xim, float *yim) -{ - /* only when compositor shows, and image handler set */ - if(sima->image && sima->image->type==IMA_TYPE_COMPOSITE) { - /* XXX panels .. */ -#if 0 - short a; - - for(a=0; ablockhandler[a] == IMAGE_HANDLER_PREVIEW) { - if(xim) *xim= (scene->r.size*scene->r.xsch)/100; - if(yim) *yim= (scene->r.size*scene->r.ysch)/100; - return 1; - } - } -#endif - } - return 0; -} -#endif - -/* are there curves? curves visible? and curves do something? */ -static int image_curves_active(SpaceImage *sima) -{ - if(sima->cumap) { - if(curvemapping_RGBA_does_something(sima->cumap)) { - /* XXX panels .. */ -#if 0 - short a; - for(a=0; ablockhandler[a] == IMAGE_HANDLER_CURVES) - return 1; - } -#endif - } - } - - return 0; -} - static void image_verify_buffer_float(SpaceImage *sima, Image *ima, ImBuf *ibuf, int color_manage) { /* detect if we need to redo the curve map. @@ -120,18 +79,13 @@ static void image_verify_buffer_float(SpaceImage *sima, Image *ima, ImBuf *ibuf, if(ibuf->rect_float) { if(ibuf->rect==NULL) { - if(image_curves_active(sima)) { - curvemapping_do_ibuf(sima->cumap, ibuf); - } - else { - if (color_manage) { - if (ima && ima->source == IMA_SRC_VIEWER) - ibuf->profile = IB_PROFILE_LINEAR_RGB; - } else { - ibuf->profile = IB_PROFILE_NONE; - } - IMB_rect_from_float(ibuf); + if (color_manage) { + if (ima && ima->source == IMA_SRC_VIEWER) + ibuf->profile = IB_PROFILE_LINEAR_RGB; + } else { + ibuf->profile = IB_PROFILE_NONE; } + IMB_rect_from_float(ibuf); } } } -- cgit v1.2.3 From f749d0361f8a2cf8ba7d515c31cec1dcf8fe96a5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 30 Jan 2010 22:33:47 +0000 Subject: - hash characters in the path would confuse the output file name and not add numbers to it (when rendering animations). - added an option to BLI_convertstringframe and BLI_convertstringframe_range to add digits if not found. - removed BLI_convertstringframe where its obviously not needed - such as loading movies and sounds. --- source/blender/editors/space_image/image_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors/space_image') diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 7dd26c31658..e8025e84a5e 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -810,7 +810,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, Scene *scene, wmOpera if (ibuf) { BLI_convertstringcode(name, G.sce); - BLI_convertstringframe(name, scene->r.cfra); + BLI_convertstringframe(name, scene->r.cfra, 0); if(scene->r.scemode & R_EXTENSION) { BKE_add_image_extension(name, sima->imtypenr); -- cgit v1.2.3 From aafe6e2d9c4af7c2e47ce6bc13a45c91d8e17066 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 31 Jan 2010 23:07:32 +0000 Subject: Renamed the FILE_OPEN option for the file browser to FILE_OPENFILE to cleanup compiler warnings about redefined definitions (mingw) --- source/blender/editors/space_image/image_ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/editors/space_image') diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index e8025e84a5e..2011649fda6 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -741,7 +741,7 @@ void IMAGE_OT_open(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPEN); + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE); } /******************** replace image operator ********************/ @@ -794,7 +794,7 @@ void IMAGE_OT_replace(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPEN); + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE); } /******************** save image as operator ********************/ -- cgit v1.2.3 From ea70bcb5b88e3ef14d268b6b11929fab185773f2 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 31 Jan 2010 23:25:57 +0000 Subject: Fix missing redraw in image window when changing render pass. --- source/blender/editors/space_image/space_image.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors/space_image') diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 5a584782237..3cb00baf427 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -602,7 +602,7 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_IMAGE: - if (wmn->reference == sima->image) { + if (wmn->reference == sima->image || !wmn->reference) { image_histogram_tag_refresh(sa); ED_area_tag_refresh(sa); ED_area_tag_redraw(sa); -- cgit v1.2.3 From c8b69b07c4e549cc18e26666e176a78c033e2be0 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 2 Feb 2010 17:41:32 +0000 Subject: Fix #20926: 2d image paint was missing clone image, clone alpha, and wrap option in the UI, also fixes missing refresh when changing these and wrong order in keymap for clone grabbing operator. --- source/blender/editors/space_image/space_image.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source/blender/editors/space_image') diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 3cb00baf427..a653838c073 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -516,8 +516,6 @@ void image_keymap(struct wmKeyConfig *keyconf) RNA_float_set(WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_ratio", PAD4, KM_PRESS, 0, 0)->ptr, "ratio", 0.25f); RNA_float_set(WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_ratio", PAD8, KM_PRESS, 0, 0)->ptr, "ratio", 0.125f); - WM_keymap_add_item(keymap, "PAINT_OT_grab_clone", RIGHTMOUSE, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "IMAGE_OT_sample", ACTIONMOUSE, KM_PRESS, 0, 0); RNA_enum_set(WM_keymap_add_item(keymap, "IMAGE_OT_curves_point_set", ACTIONMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "point", 0); RNA_enum_set(WM_keymap_add_item(keymap, "IMAGE_OT_curves_point_set", ACTIONMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "point", 1); -- cgit v1.2.3 From 10240261e9504c4d17ce6679d074e869d876d347 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 9 Feb 2010 19:37:37 +0000 Subject: J-key render switching back, now with 10 slots. Implementation note: this was done by giving each Render a slot number, and for every slot a new Render will be created. Not sure if this is ideal, but it ensures that all passes, render info, etc are separate so you can also compare render layers and passes, in 2.4x only whatever it was currently displaying was backed up. --- source/blender/editors/space_image/image_buttons.c | 75 +++++++++++++++------- source/blender/editors/space_image/image_intern.h | 2 + source/blender/editors/space_image/image_ops.c | 46 +++++++++++++ source/blender/editors/space_image/space_image.c | 4 ++ 4 files changed, 103 insertions(+), 24 deletions(-) (limited to 'source/blender/editors/space_image') diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 94df99d9c8d..2eb371357f1 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -533,6 +533,22 @@ static void image_panel_preview(ScrArea *sa, short cntrl) // IMAGE_HANDLER_PREVI /* ********************* callbacks for standard image buttons *************** */ +static char *slot_menu() +{ + char *str; + int a, slot; + + str= MEM_callocN(RE_SLOT_MAX*32, "menu slots"); + + strcpy(str, "Slot %t"); + a= strlen(str); + + for(slot=0; slotmenunr); + BKE_image_multilayer_index(rr_v, iuser); WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL); } static void image_multi_inclay_cb(bContext *C, void *rr_v, void *iuser_v) @@ -699,34 +718,45 @@ static void image_user_change(bContext *C, void *iuser_v, void *unused) } #endif -static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, ImageUser *iuser, int w) +static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, ImageUser *iuser, int w, int render) { uiBlock *block= uiLayoutGetBlock(layout); uiBut *but; RenderLayer *rl= NULL; - int wmenu1, wmenu2; + int wmenu1, wmenu2, wmenu3; char *strp; uiLayoutRow(layout, 1); /* layer menu is 1/3 larger than pass */ - wmenu1= (3*w)/5; - wmenu2= (2*w)/5; + wmenu1= (2*w)/5; + wmenu2= (3*w)/5; + wmenu3= (3*w)/6; /* menu buts */ - strp= layer_menu(rr, &iuser->layer); - but= uiDefButS(block, MENU, 0, strp, 0, 0, wmenu1, 20, &iuser->layer, 0,0,0,0, "Select Layer"); - uiButSetFunc(but, image_multi_cb, rr, iuser); - MEM_freeN(strp); - - rl= BLI_findlink(&rr->layers, iuser->layer - (rr->rectf?1:0)); /* fake compo layer, return NULL is meant to be */ - strp= pass_menu(rl, &iuser->pass); - but= uiDefButS(block, MENU, 0, strp, 0, 0, wmenu2, 20, &iuser->pass, 0,0,0,0, "Select Pass"); - uiButSetFunc(but, image_multi_cb, rr, iuser); - MEM_freeN(strp); + if(render) { + strp= slot_menu(); + iuser->menunr= RE_GetViewSlot(); + but= uiDefButS(block, MENU, 0, strp, 0, 0, wmenu1, 20, &iuser->menunr, 0,0,0,0, "Select Slot"); + uiButSetFunc(but, image_multi_cb, rr, iuser); + MEM_freeN(strp); + } + + if(rr) { + strp= layer_menu(rr, &iuser->layer); + but= uiDefButS(block, MENU, 0, strp, 0, 0, wmenu2, 20, &iuser->layer, 0,0,0,0, "Select Layer"); + uiButSetFunc(but, image_multi_cb, rr, iuser); + MEM_freeN(strp); + + rl= BLI_findlink(&rr->layers, iuser->layer - (rr->rectf?1:0)); /* fake compo layer, return NULL is meant to be */ + strp= pass_menu(rl, &iuser->pass); + but= uiDefButS(block, MENU, 0, strp, 0, 0, wmenu3, 20, &iuser->pass, 0,0,0,0, "Select Pass"); + uiButSetFunc(but, image_multi_cb, rr, iuser); + MEM_freeN(strp); + } } -static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, ImageUser *iuser) +static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, ImageUser *iuser, int render) { uiBlock *block= uiLayoutGetBlock(layout); uiLayout *row; @@ -747,7 +777,7 @@ static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, but= uiDefIconBut(block, BUT, 0, ICON_TRIA_RIGHT, 0,0,18,20, NULL, 0, 0, 0, 0, "Next Layer"); uiButSetFunc(but, image_multi_inclay_cb, rr, iuser); - uiblock_layer_pass_buttons(row, rr, iuser, 230); + uiblock_layer_pass_buttons(row, rr, iuser, 230, render); /* decrease, increase arrows */ but= uiDefIconBut(block, BUT, 0, ICON_TRIA_LEFT, 0,0,17,20, NULL, 0, 0, 0, 0, "Previous Pass"); @@ -856,9 +886,9 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propn } else if(ima->type==IMA_TYPE_R_RESULT) { /* browse layer/passes */ - Render *re= RE_GetRender(scene->id.name); + Render *re= RE_GetRender(scene->id.name, RE_SLOT_VIEW); RenderResult *rr= RE_AcquireResultRead(re); - uiblock_layer_pass_arrow_buttons(layout, rr, iuser); + uiblock_layer_pass_arrow_buttons(layout, rr, iuser, 1); RE_ReleaseResult(re); } } @@ -885,7 +915,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propn /* multilayer? */ if(ima->type==IMA_TYPE_MULTILAYER && ima->rr) { - uiblock_layer_pass_arrow_buttons(layout, ima->rr, iuser); + uiblock_layer_pass_arrow_buttons(layout, ima->rr, iuser, 0); } else if(ima->source != IMA_SRC_GENERATED) { if(compact == 0) { @@ -965,10 +995,7 @@ void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser /* render layers and passes */ if(ima && iuser) { rr= BKE_image_acquire_renderresult(scene, ima); - - if(rr) - uiblock_layer_pass_buttons(layout, rr, iuser, 160); - + uiblock_layer_pass_buttons(layout, rr, iuser, 160, ima->type==IMA_TYPE_R_RESULT); BKE_image_release_renderresult(scene, ima); } } diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h index b7f81245296..80fcbe5f240 100644 --- a/source/blender/editors/space_image/image_intern.h +++ b/source/blender/editors/space_image/image_intern.h @@ -77,6 +77,8 @@ void IMAGE_OT_save_sequence(struct wmOperatorType *ot); void IMAGE_OT_pack(struct wmOperatorType *ot); void IMAGE_OT_unpack(struct wmOperatorType *ot); +void IMAGE_OT_cycle_render_slot(struct wmOperatorType *ot); + void IMAGE_OT_sample(struct wmOperatorType *ot); void IMAGE_OT_curves_point_set(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 2011649fda6..a1557e424da 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1791,6 +1791,51 @@ void IMAGE_OT_record_composite(wmOperatorType *ot) ot->poll= space_image_poll; } +/********************* cycle render slot operator *********************/ + +static int cycle_render_slot_poll(bContext *C) +{ + Image *ima= CTX_data_edit_image(C); + + return (ima && ima->type == IMA_TYPE_R_RESULT); +} + +static int cycle_render_slot_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + int a, slot, cur= RE_GetViewSlot(); + + for(a=1; aid.name, slot)) { + RE_SetViewSlot(slot); + break; + } + } + + if(a == RE_SLOT_MAX) + RE_SetViewSlot((cur == 1)? 0: 1); + + WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL); + + return OPERATOR_FINISHED; +} + +void IMAGE_OT_cycle_render_slot(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Cycle Render Slot"; + ot->idname= "IMAGE_OT_cycle_render_slot"; + + /* api callbacks */ + ot->exec= cycle_render_slot_exec; + ot->poll= cycle_render_slot_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + /******************** TODO ********************/ /* XXX notifier? */ @@ -1843,3 +1888,4 @@ void BIF_image_update_frame(void) } #endif + diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index a653838c073..c8c110b3d02 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -472,6 +472,8 @@ void image_operatortypes(void) WM_operatortype_append(IMAGE_OT_pack); WM_operatortype_append(IMAGE_OT_unpack); + WM_operatortype_append(IMAGE_OT_cycle_render_slot); + WM_operatortype_append(IMAGE_OT_sample); WM_operatortype_append(IMAGE_OT_curves_point_set); @@ -493,6 +495,8 @@ void image_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "IMAGE_OT_save_as", F3KEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "IMAGE_OT_properties", NKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "IMAGE_OT_scopes", PKEY, KM_PRESS, 0, 0); + + WM_keymap_add_item(keymap, "IMAGE_OT_cycle_render_slot", JKEY, KM_PRESS, 0, 0); keymap= WM_keymap_find(keyconf, "Image", SPACE_IMAGE, 0); -- cgit v1.2.3 From 081c1205a31cb12ef632565b8d0c3fce024aa339 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 12 Feb 2010 13:34:04 +0000 Subject: correct fsf address --- source/blender/editors/space_image/image_buttons.c | 2 +- source/blender/editors/space_image/image_draw.c | 2 +- source/blender/editors/space_image/image_header.c | 2 +- source/blender/editors/space_image/image_intern.h | 2 +- source/blender/editors/space_image/image_ops.c | 2 +- source/blender/editors/space_image/image_render.c | 2 +- source/blender/editors/space_image/space_image.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source/blender/editors/space_image') diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 2eb371357f1..01c53961f66 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 6e883405ef8..cb942472b9e 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/editors/space_image/image_header.c b/source/blender/editors/space_image/image_header.c index dbe2acd603f..c851aa442eb 100644 --- a/source/blender/editors/space_image/image_header.c +++ b/source/blender/editors/space_image/image_header.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2008 Blender Foundation. * All rights reserved. diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h index 80fcbe5f240..f5d84d7487f 100644 --- a/source/blender/editors/space_image/image_intern.h +++ b/source/blender/editors/space_image/image_intern.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2008 Blender Foundation. * All rights reserved. diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index a1557e424da..4a2dd52384c 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/editors/space_image/image_render.c b/source/blender/editors/space_image/image_render.c index 617749937cb..97b5f9847ff 100644 --- a/source/blender/editors/space_image/image_render.c +++ b/source/blender/editors/space_image/image_render.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index c8c110b3d02..e68335e49a0 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2008 Blender Foundation. * All rights reserved. -- cgit v1.2.3 From b673f7318c9733f009acfae1b640ca14eec79047 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sat, 13 Feb 2010 13:09:30 +0000 Subject: Added support for animated texture draw, GLSL textures. Note, this is not like GE ffmpg, but Blender Image Texture display for GLSL materials. Speed can be disappointing, use smaller images for realtime edits. --- source/blender/editors/space_image/image_ops.c | 32 +++++++++++++++++--------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'source/blender/editors/space_image') diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 4a2dd52384c..b69b6a552a6 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -37,6 +37,7 @@ #include "DNA_space_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "DNA_texture_types.h" #include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" @@ -44,7 +45,9 @@ #include "BKE_context.h" #include "BKE_image.h" #include "BKE_global.h" +#include "BKE_image.h" #include "BKE_library.h" +#include "BKE_main.h" #include "BKE_node.h" #include "BKE_packedFile.h" #include "BKE_report.h" @@ -1839,20 +1842,26 @@ void IMAGE_OT_cycle_render_slot(wmOperatorType *ot) /******************** TODO ********************/ /* XXX notifier? */ -#if 0 + /* goes over all ImageUsers, and sets frame numbers if auto-refresh is set */ -void BIF_image_update_frame(void) + +void ED_image_update_frame(const bContext *C) { + Main *mainp = CTX_data_main(C); + Scene *scene= CTX_data_scene(C); Tex *tex; /* texture users */ - for(tex= G.main->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)) + 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_imanr(&tex->iuser, scene->r.cfra, 0); - + BKE_image_user_calc_frame(&tex->iuser, scene->r.cfra, 0); + } + } } + +#if 0 /* image window, compo node users */ if(G.curscreen) { ScrArea *sa; @@ -1861,12 +1870,12 @@ void BIF_image_update_frame(void) View3D *v3d= sa->spacedata.first; if(v3d->bgpic) if(v3d->bgpic->iuser.flag & IMA_ANIM_ALWAYS) - BKE_image_user_calc_imanr(&v3d->bgpic->iuser, scene->r.cfra, 0); + BKE_image_user_calc_frame(&v3d->bgpic->iuser, scene->r.cfra, 0); } else if(sa->spacetype==SPACE_IMAGE) { SpaceImage *sima= sa->spacedata.first; if(sima->iuser.flag & IMA_ANIM_ALWAYS) - BKE_image_user_calc_imanr(&sima->iuser, scene->r.cfra, 0); + BKE_image_user_calc_frame(&sima->iuser, scene->r.cfra, 0); } else if(sa->spacetype==SPACE_NODE) { SpaceNode *snode= sa->spacedata.first; @@ -1878,14 +1887,15 @@ void BIF_image_update_frame(void) ImageUser *iuser= node->storage; if(ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) if(iuser->flag & IMA_ANIM_ALWAYS) - BKE_image_user_calc_imanr(iuser, scene->r.cfra, 0); + BKE_image_user_calc_frame(iuser, scene->r.cfra, 0); } } } } } } -} #endif +} + -- cgit v1.2.3 From 2061f91741861f5646974b4960b5ff03d509f5eb Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 16 Feb 2010 15:49:22 +0000 Subject: Render Slots: change the implementation by moving it from the render to the image code, this should be clearer and makes reusing the Render struct later on easier. --- source/blender/editors/space_image/image_buttons.c | 24 +++++----- source/blender/editors/space_image/image_draw.c | 52 +++++++++++----------- source/blender/editors/space_image/image_ops.c | 18 ++++---- 3 files changed, 46 insertions(+), 48 deletions(-) (limited to 'source/blender/editors/space_image') diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 01c53961f66..bd5f8754990 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -538,12 +538,12 @@ static char *slot_menu() char *str; int a, slot; - str= MEM_callocN(RE_SLOT_MAX*32, "menu slots"); + str= MEM_callocN(IMA_MAX_RENDER_SLOT*32, "menu slots"); strcpy(str, "Slot %t"); a= strlen(str); - for(slot=0; slotmenunr); BKE_image_multilayer_index(rr_v, iuser); WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL); } @@ -718,7 +717,7 @@ static void image_user_change(bContext *C, void *iuser_v, void *unused) } #endif -static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, ImageUser *iuser, int w, int render) +static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, ImageUser *iuser, int w, short *render_slot) { uiBlock *block= uiLayoutGetBlock(layout); uiBut *but; @@ -734,10 +733,9 @@ static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, Image wmenu3= (3*w)/6; /* menu buts */ - if(render) { + if(render_slot) { strp= slot_menu(); - iuser->menunr= RE_GetViewSlot(); - but= uiDefButS(block, MENU, 0, strp, 0, 0, wmenu1, 20, &iuser->menunr, 0,0,0,0, "Select Slot"); + but= uiDefButS(block, MENU, 0, strp, 0, 0, wmenu1, 20, render_slot, 0,0,0,0, "Select Slot"); uiButSetFunc(but, image_multi_cb, rr, iuser); MEM_freeN(strp); } @@ -756,7 +754,7 @@ static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, Image } } -static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, ImageUser *iuser, int render) +static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, ImageUser *iuser, short *render_slot) { uiBlock *block= uiLayoutGetBlock(layout); uiLayout *row; @@ -777,7 +775,7 @@ static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, but= uiDefIconBut(block, BUT, 0, ICON_TRIA_RIGHT, 0,0,18,20, NULL, 0, 0, 0, 0, "Next Layer"); uiButSetFunc(but, image_multi_inclay_cb, rr, iuser); - uiblock_layer_pass_buttons(row, rr, iuser, 230, render); + uiblock_layer_pass_buttons(row, rr, iuser, 230, render_slot); /* decrease, increase arrows */ but= uiDefIconBut(block, BUT, 0, ICON_TRIA_LEFT, 0,0,17,20, NULL, 0, 0, 0, 0, "Previous Pass"); @@ -886,9 +884,9 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propn } else if(ima->type==IMA_TYPE_R_RESULT) { /* browse layer/passes */ - Render *re= RE_GetRender(scene->id.name, RE_SLOT_VIEW); + Render *re= RE_GetRender(scene->id.name); RenderResult *rr= RE_AcquireResultRead(re); - uiblock_layer_pass_arrow_buttons(layout, rr, iuser, 1); + uiblock_layer_pass_arrow_buttons(layout, rr, iuser, &ima->render_slot); RE_ReleaseResult(re); } } @@ -915,7 +913,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propn /* multilayer? */ if(ima->type==IMA_TYPE_MULTILAYER && ima->rr) { - uiblock_layer_pass_arrow_buttons(layout, ima->rr, iuser, 0); + uiblock_layer_pass_arrow_buttons(layout, ima->rr, iuser, NULL); } else if(ima->source != IMA_SRC_GENERATED) { if(compact == 0) { @@ -995,7 +993,7 @@ void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser /* render layers and passes */ if(ima && iuser) { rr= BKE_image_acquire_renderresult(scene, ima); - uiblock_layer_pass_buttons(layout, rr, iuser, 160, ima->type==IMA_TYPE_R_RESULT); + uiblock_layer_pass_buttons(layout, rr, iuser, 160, (ima->type==IMA_TYPE_R_RESULT)? &ima->render_slot: NULL); BKE_image_release_renderresult(scene, ima); } } diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index cb942472b9e..bc07222c9fb 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -64,6 +64,8 @@ #include "WM_api.h" +#include "RE_pipeline.h" + #include "image_intern.h" #define HEADER_HEIGHT 18 @@ -90,37 +92,35 @@ static void image_verify_buffer_float(SpaceImage *sima, Image *ima, ImBuf *ibuf, } } -static void draw_render_info(Image *ima, ARegion *ar) +static void draw_render_info(Scene *scene, Image *ima, ARegion *ar) { + RenderResult *rr; rcti rect; float colf[3]; - int showspare= 0; // XXX BIF_show_render_spare(); - - if(ima->render_text==NULL) - return; - - rect= ar->winrct; - rect.xmin= 0; - rect.ymin= ar->winrct.ymax - ar->winrct.ymin - HEADER_HEIGHT; - rect.xmax= ar->winrct.xmax - ar->winrct.xmin; - rect.ymax= ar->winrct.ymax - ar->winrct.ymin; - - /* clear header rect */ - UI_GetThemeColor3fv(TH_BACK, colf); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); - glColor4f(colf[0]+0.1f, colf[1]+0.1f, colf[2]+0.1f, 0.5f); - glRecti(rect.xmin, rect.ymin, rect.xmax, rect.ymax+1); - glDisable(GL_BLEND); - UI_ThemeColor(TH_TEXT_HI); + rr= BKE_image_acquire_renderresult(scene, ima); + + if(rr->text) { + rect= ar->winrct; + rect.xmin= 0; + rect.ymin= ar->winrct.ymax - ar->winrct.ymin - HEADER_HEIGHT; + rect.xmax= ar->winrct.xmax - ar->winrct.xmin; + rect.ymax= ar->winrct.ymax - ar->winrct.ymin; + + /* clear header rect */ + UI_GetThemeColor3fv(TH_BACK, colf); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + glColor4f(colf[0]+0.1f, colf[1]+0.1f, colf[2]+0.1f, 0.5f); + glRecti(rect.xmin, rect.ymin, rect.xmax, rect.ymax+1); + glDisable(GL_BLEND); + + UI_ThemeColor(TH_TEXT_HI); - if(showspare) { - UI_DrawString(12, rect.ymin + 5, "(Previous)"); - UI_DrawString(72, rect.ymin + 5, ima->render_text); + UI_DrawString(12, rect.ymin + 5, rr->text); } - else - UI_DrawString(12, rect.ymin + 5, ima->render_text); + + BKE_image_release_renderresult(scene, ima); } void draw_image_info(ARegion *ar, int channels, int x, int y, char *cp, float *fp, int *zp, float *zpf) @@ -654,7 +654,7 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene) /* render info */ if(ibuf && ima && show_render) - draw_render_info(ima, ar); + draw_render_info(scene, ima, ar); /* XXX integrate this code */ #if 0 diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index b69b6a552a6..eb87b5656bf 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1805,21 +1805,21 @@ static int cycle_render_slot_poll(bContext *C) static int cycle_render_slot_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - int a, slot, cur= RE_GetViewSlot(); + Image *ima= CTX_data_edit_image(C); + int a, slot, cur= ima->render_slot; - for(a=1; aid.name, slot)) { - RE_SetViewSlot(slot); + if(ima->renders[slot] || slot == ima->last_render_slot) { + ima->render_slot= slot; break; } } - if(a == RE_SLOT_MAX) - RE_SetViewSlot((cur == 1)? 0: 1); - + if(a == IMA_MAX_RENDER_SLOT) + ima->render_slot= ((cur == 1)? 0: 1); + WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL); return OPERATOR_FINISHED; -- cgit v1.2.3 From ad01c90ee3942fb2a4a792f0454a136b441f42b4 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 16 Feb 2010 19:24:04 +0000 Subject: Revert render slots commit for release, I can't find the bug or even redo it myself, there will still be render slots just old implementation. --- source/blender/editors/space_image/image_buttons.c | 24 +++++----- source/blender/editors/space_image/image_draw.c | 52 +++++++++++----------- source/blender/editors/space_image/image_ops.c | 18 ++++---- 3 files changed, 48 insertions(+), 46 deletions(-) (limited to 'source/blender/editors/space_image') diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index bd5f8754990..01c53961f66 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -538,12 +538,12 @@ static char *slot_menu() char *str; int a, slot; - str= MEM_callocN(IMA_MAX_RENDER_SLOT*32, "menu slots"); + str= MEM_callocN(RE_SLOT_MAX*32, "menu slots"); strcpy(str, "Slot %t"); a= strlen(str); - for(slot=0; slotmenunr); BKE_image_multilayer_index(rr_v, iuser); WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL); } @@ -717,7 +718,7 @@ static void image_user_change(bContext *C, void *iuser_v, void *unused) } #endif -static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, ImageUser *iuser, int w, short *render_slot) +static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, ImageUser *iuser, int w, int render) { uiBlock *block= uiLayoutGetBlock(layout); uiBut *but; @@ -733,9 +734,10 @@ static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, Image wmenu3= (3*w)/6; /* menu buts */ - if(render_slot) { + if(render) { strp= slot_menu(); - but= uiDefButS(block, MENU, 0, strp, 0, 0, wmenu1, 20, render_slot, 0,0,0,0, "Select Slot"); + iuser->menunr= RE_GetViewSlot(); + but= uiDefButS(block, MENU, 0, strp, 0, 0, wmenu1, 20, &iuser->menunr, 0,0,0,0, "Select Slot"); uiButSetFunc(but, image_multi_cb, rr, iuser); MEM_freeN(strp); } @@ -754,7 +756,7 @@ static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, Image } } -static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, ImageUser *iuser, short *render_slot) +static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, ImageUser *iuser, int render) { uiBlock *block= uiLayoutGetBlock(layout); uiLayout *row; @@ -775,7 +777,7 @@ static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, but= uiDefIconBut(block, BUT, 0, ICON_TRIA_RIGHT, 0,0,18,20, NULL, 0, 0, 0, 0, "Next Layer"); uiButSetFunc(but, image_multi_inclay_cb, rr, iuser); - uiblock_layer_pass_buttons(row, rr, iuser, 230, render_slot); + uiblock_layer_pass_buttons(row, rr, iuser, 230, render); /* decrease, increase arrows */ but= uiDefIconBut(block, BUT, 0, ICON_TRIA_LEFT, 0,0,17,20, NULL, 0, 0, 0, 0, "Previous Pass"); @@ -884,9 +886,9 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propn } else if(ima->type==IMA_TYPE_R_RESULT) { /* browse layer/passes */ - Render *re= RE_GetRender(scene->id.name); + Render *re= RE_GetRender(scene->id.name, RE_SLOT_VIEW); RenderResult *rr= RE_AcquireResultRead(re); - uiblock_layer_pass_arrow_buttons(layout, rr, iuser, &ima->render_slot); + uiblock_layer_pass_arrow_buttons(layout, rr, iuser, 1); RE_ReleaseResult(re); } } @@ -913,7 +915,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propn /* multilayer? */ if(ima->type==IMA_TYPE_MULTILAYER && ima->rr) { - uiblock_layer_pass_arrow_buttons(layout, ima->rr, iuser, NULL); + uiblock_layer_pass_arrow_buttons(layout, ima->rr, iuser, 0); } else if(ima->source != IMA_SRC_GENERATED) { if(compact == 0) { @@ -993,7 +995,7 @@ void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser /* render layers and passes */ if(ima && iuser) { rr= BKE_image_acquire_renderresult(scene, ima); - uiblock_layer_pass_buttons(layout, rr, iuser, 160, (ima->type==IMA_TYPE_R_RESULT)? &ima->render_slot: NULL); + uiblock_layer_pass_buttons(layout, rr, iuser, 160, ima->type==IMA_TYPE_R_RESULT); BKE_image_release_renderresult(scene, ima); } } diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index bc07222c9fb..cb942472b9e 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -64,8 +64,6 @@ #include "WM_api.h" -#include "RE_pipeline.h" - #include "image_intern.h" #define HEADER_HEIGHT 18 @@ -92,35 +90,37 @@ static void image_verify_buffer_float(SpaceImage *sima, Image *ima, ImBuf *ibuf, } } -static void draw_render_info(Scene *scene, Image *ima, ARegion *ar) +static void draw_render_info(Image *ima, ARegion *ar) { - RenderResult *rr; rcti rect; float colf[3]; + int showspare= 0; // XXX BIF_show_render_spare(); - rr= BKE_image_acquire_renderresult(scene, ima); - - if(rr->text) { - rect= ar->winrct; - rect.xmin= 0; - rect.ymin= ar->winrct.ymax - ar->winrct.ymin - HEADER_HEIGHT; - rect.xmax= ar->winrct.xmax - ar->winrct.xmin; - rect.ymax= ar->winrct.ymax - ar->winrct.ymin; - - /* clear header rect */ - UI_GetThemeColor3fv(TH_BACK, colf); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); - glColor4f(colf[0]+0.1f, colf[1]+0.1f, colf[2]+0.1f, 0.5f); - glRecti(rect.xmin, rect.ymin, rect.xmax, rect.ymax+1); - glDisable(GL_BLEND); - - UI_ThemeColor(TH_TEXT_HI); + if(ima->render_text==NULL) + return; + + rect= ar->winrct; + rect.xmin= 0; + rect.ymin= ar->winrct.ymax - ar->winrct.ymin - HEADER_HEIGHT; + rect.xmax= ar->winrct.xmax - ar->winrct.xmin; + rect.ymax= ar->winrct.ymax - ar->winrct.ymin; + + /* clear header rect */ + UI_GetThemeColor3fv(TH_BACK, colf); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + glColor4f(colf[0]+0.1f, colf[1]+0.1f, colf[2]+0.1f, 0.5f); + glRecti(rect.xmin, rect.ymin, rect.xmax, rect.ymax+1); + glDisable(GL_BLEND); + + UI_ThemeColor(TH_TEXT_HI); - UI_DrawString(12, rect.ymin + 5, rr->text); + if(showspare) { + UI_DrawString(12, rect.ymin + 5, "(Previous)"); + UI_DrawString(72, rect.ymin + 5, ima->render_text); } - - BKE_image_release_renderresult(scene, ima); + else + UI_DrawString(12, rect.ymin + 5, ima->render_text); } void draw_image_info(ARegion *ar, int channels, int x, int y, char *cp, float *fp, int *zp, float *zpf) @@ -654,7 +654,7 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene) /* render info */ if(ibuf && ima && show_render) - draw_render_info(scene, ima, ar); + draw_render_info(ima, ar); /* XXX integrate this code */ #if 0 diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index eb87b5656bf..b69b6a552a6 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1805,21 +1805,21 @@ static int cycle_render_slot_poll(bContext *C) static int cycle_render_slot_exec(bContext *C, wmOperator *op) { - Image *ima= CTX_data_edit_image(C); - int a, slot, cur= ima->render_slot; + Scene *scene= CTX_data_scene(C); + int a, slot, cur= RE_GetViewSlot(); - for(a=1; arenders[slot] || slot == ima->last_render_slot) { - ima->render_slot= slot; + if(RE_GetRender(scene->id.name, slot)) { + RE_SetViewSlot(slot); break; } } - if(a == IMA_MAX_RENDER_SLOT) - ima->render_slot= ((cur == 1)? 0: 1); - + if(a == RE_SLOT_MAX) + RE_SetViewSlot((cur == 1)? 0: 1); + WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL); return OPERATOR_FINISHED; -- cgit v1.2.3