diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-10-09 13:15:47 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-10-09 13:17:31 +0400 |
commit | 375d2dc85535b9f08fd2e854c80434eac1c28a67 (patch) | |
tree | 9cb344ef18c86d8286abfb2933d37e98cc48754c /source/blender/editors/space_image/image_buttons.c | |
parent | fe9394741b7ac9ca153c602d6f58664b27438d56 (diff) |
Implement custom names for render slots
Basically the title tells it all, quite straightforward implementation.
The only thing is the image.render_slot which used to represent the active
render slot index is now moved to image.render_slots.active_index.
Reviewers: venomgfx, campbellbarton
Differential Revision: https://developer.blender.org/D821
Diffstat (limited to 'source/blender/editors/space_image/image_buttons.c')
-rw-r--r-- | source/blender/editors/space_image/image_buttons.c | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index ed6e6ba1e1b..ffdb8ecfce6 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -284,10 +284,10 @@ static void image_panel_preview(ScrArea *sa, short cntrl) // IMAGE_HANDLER_PRE /* ********************* callbacks for standard image buttons *************** */ -static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void *render_slot_p) +static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void *image_p) { uiBlock *block = uiLayoutGetBlock(layout); - short *render_slot = render_slot_p; + Image *image = image_p; int slot; uiDefBut(block, LABEL, 0, IFACE_("Slot"), @@ -296,10 +296,15 @@ static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void * slot = IMA_MAX_RENDER_SLOT; while (slot--) { - char str[32]; - BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), slot + 1); + char str[64]; + if (image->render_slots[slot].name[0] != '\0') { + BLI_strncpy(str, image->render_slots[slot].name, sizeof(str)); + } + else { + BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), slot + 1); + } uiDefButS(block, BUTM, B_NOP, str, 0, 0, - UI_UNIT_X * 5, UI_UNIT_X, render_slot, (float) slot, 0.0, 0, -1, ""); + UI_UNIT_X * 5, UI_UNIT_X, &image->render_slot, (float) slot, 0.0, 0, -1, ""); } } @@ -492,7 +497,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, Image *image, RenderResult *rr, ImageUser *iuser, int w, short *render_slot) { static void *rnd_pt[3]; /* XXX, workaround */ uiBlock *block = uiLayoutGetBlock(layout); @@ -516,8 +521,13 @@ static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, Image /* menu buts */ if (render_slot) { char str[64]; - BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), *render_slot + 1); - but = uiDefMenuBut(block, ui_imageuser_slot_menu, render_slot, str, 0, 0, wmenu1, UI_UNIT_Y, TIP_("Select Slot")); + if (image->render_slots[*render_slot].name[0] != '\0') { + BLI_strncpy(str, image->render_slots[*render_slot].name, sizeof(str)); + } + else { + BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), *render_slot + 1); + } + but = uiDefMenuBut(block, ui_imageuser_slot_menu, image, str, 0, 0, wmenu1, UI_UNIT_Y, TIP_("Select Slot")); uiButSetFunc(but, image_multi_cb, rr, iuser); uiButSetMenuFromPulldown(but); } @@ -547,7 +557,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, Image *image, RenderResult *rr, ImageUser *iuser, short *render_slot) { uiBlock *block = uiLayoutGetBlock(layout); uiLayout *row; @@ -569,7 +579,7 @@ static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, but = uiDefIconBut(block, BUT, 0, ICON_TRIA_RIGHT, 0, 0, 0.90f * UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Next Layer")); uiButSetFunc(but, image_multi_inclay_cb, rr, iuser); - uiblock_layer_pass_buttons(row, rr, iuser, 230 * dpi_fac, render_slot); + uiblock_layer_pass_buttons(row, image, rr, iuser, 230 * dpi_fac, render_slot); /* decrease, increase arrows */ but = uiDefIconBut(block, BUT, 0, ICON_TRIA_LEFT, 0, 0, 0.85f * UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Previous Pass")); @@ -691,7 +701,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char /* use BKE_image_acquire_renderresult so we get the correct slot in the menu */ rr = BKE_image_acquire_renderresult(scene, ima); - uiblock_layer_pass_arrow_buttons(layout, rr, iuser, &ima->render_slot); + uiblock_layer_pass_arrow_buttons(layout, ima, rr, iuser, &ima->render_slot); BKE_image_release_renderresult(scene, ima); } } @@ -724,7 +734,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char /* 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, ima->rr, iuser, NULL); } else if (ima->source != IMA_SRC_GENERATED) { if (compact == 0) { @@ -937,7 +947,7 @@ void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser /* use BKE_image_acquire_renderresult so we get the correct slot in the menu */ rr = BKE_image_acquire_renderresult(scene, ima); - uiblock_layer_pass_buttons(layout, rr, iuser, 160 * dpi_fac, (ima->type == IMA_TYPE_R_RESULT) ? &ima->render_slot : NULL); + uiblock_layer_pass_buttons(layout, ima, rr, iuser, 160 * dpi_fac, (ima->type == IMA_TYPE_R_RESULT) ? &ima->render_slot : NULL); BKE_image_release_renderresult(scene, ima); } } |