diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-02-09 22:37:37 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-02-09 22:37:37 +0300 |
commit | 10240261e9504c4d17ce6679d074e869d876d347 (patch) | |
tree | 6b5c8897666a75aeb417d2b28906cda109453875 /source/blender/editors/space_image | |
parent | 52b1c3764595c87506d1a164c46bf83773549cd6 (diff) |
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.
Diffstat (limited to 'source/blender/editors/space_image')
-rw-r--r-- | source/blender/editors/space_image/image_buttons.c | 75 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 46 | ||||
-rw-r--r-- | source/blender/editors/space_image/space_image.c | 4 |
4 files changed, 103 insertions, 24 deletions
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; slot<RE_SLOT_MAX; slot++) + a += sprintf(str+a, "|Slot %d %%x%d", slot+1, slot); + + return str; +} + static char *layer_menu(RenderResult *rr, short *curlay) { RenderLayer *rl; @@ -599,7 +615,10 @@ static void set_frames_cb(bContext *C, void *ima_v, void *iuser_v) /* 5 layer button callbacks... */ static void image_multi_cb(bContext *C, void *rr_v, void *iuser_v) { - BKE_image_multilayer_index(rr_v, iuser_v); + ImageUser *iuser= iuser_v; + + RE_SetViewSlot(iuser->menunr); + 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; a<RE_SLOT_MAX; a++) { + slot= (cur+a)%RE_SLOT_MAX; + + if(RE_GetRender(scene->id.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); |