From 864c8068639a1341220f5a97b683f6834928ad76 Mon Sep 17 00:00:00 2001 From: Yevgeny Makarov Date: Sat, 19 Dec 2020 21:52:45 -0600 Subject: UI: Reorder enums in render results image editor header The convention is to put the label at the bottom of the enum, or in the spot furthest away from the button. This commit reorders the items in the "Slot", "Layer", and "Pass" menus to be consistent with this convention. It also reorders the numbering so that higher numbers are lower. The original patch was by Adrian Newton (@TFS), with slight changes and additions. Differential Revision: https://developer.blender.org/D7142 --- source/blender/editors/space_image/image_buttons.c | 142 ++++++++++----------- 1 file changed, 68 insertions(+), 74 deletions(-) (limited to 'source/blender/editors/space_image/image_buttons.c') diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index f8f25e399eb..1996f05b36a 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -86,26 +86,9 @@ static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void * { uiBlock *block = uiLayoutGetBlock(layout); Image *image = image_p; - 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_id = BLI_listbase_count(&image->renderslots) - 1; - for (RenderSlot *slot = image->renderslots.last; slot; slot = slot->prev) { + int slot_id; + LISTBASE_FOREACH_INDEX (RenderSlot *, slot, &image->renderslots, slot_id) { char str[64]; if (slot->name[0] != '\0') { BLI_strncpy(str, slot->name, sizeof(str)); @@ -127,8 +110,23 @@ static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void * 0, -1, ""); - slot_id--; } + + uiItemS(layout); + uiDefBut(block, + UI_BTYPE_LABEL, + 0, + IFACE_("Slot"), + 0, + 0, + UI_UNIT_X * 5, + UI_UNIT_Y, + NULL, + 0.0, + 0.0, + 0, + 0, + ""); } static bool ui_imageuser_slot_menu_step(bContext *C, int direction, void *image_p) @@ -175,14 +173,9 @@ static void ui_imageuser_layer_menu(bContext *UNUSED(C), uiLayout *layout, void Image *image = rnd_data->image; ImageUser *iuser = rnd_data->iuser; Scene *scene = iuser->scene; - RenderResult *rr; - RenderLayer *rl; - RenderLayer rl_fake = {NULL}; - const char *fake_name; - int nr; - /* may have been freed since drawing */ - rr = BKE_image_acquire_renderresult(scene, image); + /* May have been freed since drawing. */ + RenderResult *rr = BKE_image_acquire_renderresult(scene, image); if (UNLIKELY(rr == NULL)) { return; } @@ -190,32 +183,26 @@ static void ui_imageuser_layer_menu(bContext *UNUSED(C), uiLayout *layout, void UI_block_layout_set_current(block, layout); uiLayoutColumn(layout, false); - uiDefBut(block, - UI_BTYPE_LABEL, - 0, - IFACE_("Layer"), - 0, - 0, - UI_UNIT_X * 5, - UI_UNIT_Y, - NULL, - 0.0, - 0.0, - 0, - 0, - ""); - uiItemS(layout); - - nr = BLI_listbase_count(&rr->layers) - 1; - fake_name = ui_imageuser_layer_fake_name(rr); - + const char *fake_name = ui_imageuser_layer_fake_name(rr); if (fake_name) { - BLI_strncpy(rl_fake.name, fake_name, sizeof(rl_fake.name)); - nr += 1; + uiDefButS(block, + UI_BTYPE_BUT_MENU, + B_NOP, + fake_name, + 0, + 0, + UI_UNIT_X * 5, + UI_UNIT_X, + &iuser->layer, + 0.0, + 0.0, + 0, + -1, + ""); } - for (rl = rr->layers.last; rl; rl = rl->prev, nr--) { - final: + int nr = fake_name ? 1 : 0; + for (RenderLayer *rl = rr->layers.first; rl; rl = rl->next, nr++) { uiDefButS(block, UI_BTYPE_BUT_MENU, B_NOP, @@ -232,13 +219,21 @@ static void ui_imageuser_layer_menu(bContext *UNUSED(C), uiLayout *layout, void ""); } - if (fake_name) { - fake_name = NULL; - rl = &rl_fake; - goto final; - } - - BLI_assert(nr == -1); + uiItemS(layout); + uiDefBut(block, + UI_BTYPE_LABEL, + 0, + IFACE_("Layer"), + 0, + 0, + UI_UNIT_X * 5, + UI_UNIT_Y, + NULL, + 0.0, + 0.0, + 0, + 0, + ""); BKE_image_release_renderresult(scene, image); } @@ -268,23 +263,6 @@ static void ui_imageuser_pass_menu(bContext *UNUSED(C), uiLayout *layout, void * UI_block_layout_set_current(block, layout); uiLayoutColumn(layout, false); - uiDefBut(block, - UI_BTYPE_LABEL, - 0, - IFACE_("Pass"), - 0, - 0, - UI_UNIT_X * 5, - UI_UNIT_Y, - NULL, - 0.0, - 0.0, - 0, - 0, - ""); - - uiItemS(layout); - nr = (rl == NULL) ? 1 : 0; ListBase added_passes; @@ -315,6 +293,22 @@ static void ui_imageuser_pass_menu(bContext *UNUSED(C), uiLayout *layout, void * ""); } + uiItemS(layout); + uiDefBut(block, + UI_BTYPE_LABEL, + 0, + IFACE_("Pass"), + 0, + 0, + UI_UNIT_X * 5, + UI_UNIT_Y, + NULL, + 0.0, + 0.0, + 0, + 0, + ""); + BLI_freelistN(&added_passes); BKE_image_release_renderresult(scene, image); -- cgit v1.2.3