Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Stockner <lukas.stockner@freenet.de>2018-06-14 23:46:30 +0300
committerLukas Stockner <lukas.stockner@freenet.de>2018-06-14 23:46:30 +0300
commit525be2f579c994777328bd7ac206be4769d3e6a4 (patch)
tree40c37d025adf13865647ab24267d212c0b2076e1 /source/blender/editors/space_image/image_buttons.c
parent51f1ed8221042f2e273f5ee47a6053f506a783fc (diff)
Image: Refactor render slots to a dynamic list
Previously, render slots were hardcoded to a fixed amount. With this change, render slots now are stored in a list. Therefore, users can add and/or remove as many slots as they want. Credit to brecht for the UI part. Reviewers: brecht, sergey Differential Revision: https://developer.blender.org/D3474
Diffstat (limited to 'source/blender/editors/space_image/image_buttons.c')
-rw-r--r--source/blender/editors/space_image/image_buttons.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index e0a1afc4537..7236a99ad80 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -291,23 +291,24 @@ static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void *
{
uiBlock *block = uiLayoutGetBlock(layout);
Image *image = image_p;
- int slot;
+ int slot_id;
uiDefBut(block, UI_BTYPE_LABEL, 0, IFACE_("Slot"),
0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
uiItemS(layout);
- slot = IMA_MAX_RENDER_SLOT;
- while (slot--) {
+ slot_id = BLI_listbase_count(&image->renderslots) - 1;
+ for (RenderSlot *slot = image->renderslots.last; slot; slot = slot->prev) {
char str[64];
- if (image->render_slots[slot].name[0] != '\0') {
- BLI_strncpy(str, image->render_slots[slot].name, sizeof(str));
+ if (slot->name[0] != '\0') {
+ BLI_strncpy(str, slot->name, sizeof(str));
}
else {
- BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), slot + 1);
+ BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), slot_id + 1);
}
uiDefButS(block, UI_BTYPE_BUT_MENU, B_NOP, str, 0, 0,
- UI_UNIT_X * 5, UI_UNIT_X, &image->render_slot, (float) slot, 0.0, 0, -1, "");
+ UI_UNIT_X * 5, UI_UNIT_X, &image->render_slot, (float) slot_id, 0.0, 0, -1, "");
+ slot_id--;
}
}
@@ -708,8 +709,9 @@ static void uiblock_layer_pass_buttons(
/* menu buts */
if (render_slot) {
char str[64];
- if (image->render_slots[*render_slot].name[0] != '\0') {
- BLI_strncpy(str, image->render_slots[*render_slot].name, sizeof(str));
+ RenderSlot *slot = BKE_image_get_renderslot(image, *render_slot);
+ if (slot->name[0] != '\0') {
+ BLI_strncpy(str, slot->name, sizeof(str));
}
else {
BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), *render_slot + 1);