Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_image/image_buttons.c
| Show First 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /* ********************* callbacks for standard image buttons *************** */ | /* ********************* callbacks for standard image buttons *************** */ | ||||
| static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void *image_p) | static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void *image_p) | ||||
| { | { | ||||
| uiBlock *block = uiLayoutGetBlock(layout); | uiBlock *block = uiLayoutGetBlock(layout); | ||||
| Image *image = image_p; | Image *image = image_p; | ||||
| int slot_id; | |||||
| uiDefBut(block, | int slot_id; | ||||
| UI_BTYPE_LABEL, | LISTBASE_FOREACH_INDEX (RenderSlot *, slot, &image->renderslots, slot_id) { | ||||
| 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) { | |||||
| char str[64]; | char str[64]; | ||||
| if (slot->name[0] != '\0') { | if (slot->name[0] != '\0') { | ||||
| BLI_strncpy(str, slot->name, sizeof(str)); | BLI_strncpy(str, slot->name, sizeof(str)); | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), slot_id + 1); | BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), slot_id + 1); | ||||
| } | } | ||||
| uiDefButS(block, | uiDefButS(block, | ||||
| UI_BTYPE_BUT_MENU, | UI_BTYPE_BUT_MENU, | ||||
| B_NOP, | B_NOP, | ||||
| str, | str, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| UI_UNIT_X * 5, | UI_UNIT_X * 5, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| &image->render_slot, | &image->render_slot, | ||||
| (float)slot_id, | (float)slot_id, | ||||
| 0.0, | 0.0, | ||||
| 0, | 0, | ||||
| -1, | -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) | static bool ui_imageuser_slot_menu_step(bContext *C, int direction, void *image_p) | ||||
| { | { | ||||
| Image *image = image_p; | Image *image = image_p; | ||||
| if (ED_image_slot_cycle(image, direction)) { | if (ED_image_slot_cycle(image, direction)) { | ||||
| WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL); | WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL); | ||||
| Show All 30 Lines | |||||
| static void ui_imageuser_layer_menu(bContext *UNUSED(C), uiLayout *layout, void *rnd_pt) | static void ui_imageuser_layer_menu(bContext *UNUSED(C), uiLayout *layout, void *rnd_pt) | ||||
| { | { | ||||
| struct ImageUI_Data *rnd_data = rnd_pt; | struct ImageUI_Data *rnd_data = rnd_pt; | ||||
| uiBlock *block = uiLayoutGetBlock(layout); | uiBlock *block = uiLayoutGetBlock(layout); | ||||
| Image *image = rnd_data->image; | Image *image = rnd_data->image; | ||||
| ImageUser *iuser = rnd_data->iuser; | ImageUser *iuser = rnd_data->iuser; | ||||
| Scene *scene = iuser->scene; | Scene *scene = iuser->scene; | ||||
| RenderResult *rr; | |||||
| RenderLayer *rl; | |||||
| RenderLayer rl_fake = {NULL}; | |||||
| const char *fake_name; | |||||
| int nr; | |||||
| /* may have been freed since drawing */ | /* May have been freed since drawing. */ | ||||
| rr = BKE_image_acquire_renderresult(scene, image); | RenderResult *rr = BKE_image_acquire_renderresult(scene, image); | ||||
| if (UNLIKELY(rr == NULL)) { | if (UNLIKELY(rr == NULL)) { | ||||
| return; | return; | ||||
| } | } | ||||
| UI_block_layout_set_current(block, layout); | UI_block_layout_set_current(block, layout); | ||||
| uiLayoutColumn(layout, false); | uiLayoutColumn(layout, false); | ||||
| uiDefBut(block, | const char *fake_name = ui_imageuser_layer_fake_name(rr); | ||||
| UI_BTYPE_LABEL, | if (fake_name) { | ||||
| 0, | uiDefButS(block, | ||||
| IFACE_("Layer"), | UI_BTYPE_BUT_MENU, | ||||
| B_NOP, | |||||
| fake_name, | |||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| UI_UNIT_X * 5, | UI_UNIT_X * 5, | ||||
| UI_UNIT_Y, | UI_UNIT_X, | ||||
| NULL, | &iuser->layer, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0, | 0, | ||||
| 0, | -1, | ||||
| ""); | ""); | ||||
| uiItemS(layout); | |||||
| nr = BLI_listbase_count(&rr->layers) - 1; | |||||
| fake_name = ui_imageuser_layer_fake_name(rr); | |||||
| if (fake_name) { | |||||
| BLI_strncpy(rl_fake.name, fake_name, sizeof(rl_fake.name)); | |||||
| nr += 1; | |||||
| } | } | ||||
| for (rl = rr->layers.last; rl; rl = rl->prev, nr--) { | int nr = fake_name ? 1 : 0; | ||||
| final: | for (RenderLayer *rl = rr->layers.first; rl; rl = rl->next, nr++) { | ||||
| uiDefButS(block, | uiDefButS(block, | ||||
| UI_BTYPE_BUT_MENU, | UI_BTYPE_BUT_MENU, | ||||
| B_NOP, | B_NOP, | ||||
| rl->name, | rl->name, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| UI_UNIT_X * 5, | UI_UNIT_X * 5, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| &iuser->layer, | &iuser->layer, | ||||
| (float)nr, | (float)nr, | ||||
| 0.0, | 0.0, | ||||
| 0, | 0, | ||||
| -1, | -1, | ||||
| ""); | ""); | ||||
| } | } | ||||
| if (fake_name) { | uiItemS(layout); | ||||
| fake_name = NULL; | uiDefBut(block, | ||||
| rl = &rl_fake; | UI_BTYPE_LABEL, | ||||
| goto final; | 0, | ||||
| } | IFACE_("Layer"), | ||||
| 0, | |||||
| BLI_assert(nr == -1); | 0, | ||||
| UI_UNIT_X * 5, | |||||
| UI_UNIT_Y, | |||||
| NULL, | |||||
| 0.0, | |||||
| 0.0, | |||||
| 0, | |||||
| 0, | |||||
| ""); | |||||
| BKE_image_release_renderresult(scene, image); | BKE_image_release_renderresult(scene, image); | ||||
| } | } | ||||
| static void ui_imageuser_pass_menu(bContext *UNUSED(C), uiLayout *layout, void *rnd_pt) | static void ui_imageuser_pass_menu(bContext *UNUSED(C), uiLayout *layout, void *rnd_pt) | ||||
| { | { | ||||
| struct ImageUI_Data *rnd_data = rnd_pt; | struct ImageUI_Data *rnd_data = rnd_pt; | ||||
| uiBlock *block = uiLayoutGetBlock(layout); | uiBlock *block = uiLayoutGetBlock(layout); | ||||
| Show All 13 Lines | if (UNLIKELY(rr == NULL)) { | ||||
| return; | return; | ||||
| } | } | ||||
| rl = BLI_findlink(&rr->layers, rpass_index); | rl = BLI_findlink(&rr->layers, rpass_index); | ||||
| UI_block_layout_set_current(block, layout); | UI_block_layout_set_current(block, layout); | ||||
| uiLayoutColumn(layout, false); | 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; | nr = (rl == NULL) ? 1 : 0; | ||||
| ListBase added_passes; | ListBase added_passes; | ||||
| BLI_listbase_clear(&added_passes); | BLI_listbase_clear(&added_passes); | ||||
| /* rendered results don't have a Combined pass */ | /* rendered results don't have a Combined pass */ | ||||
| /* multiview: the ordering must be ascending, so the left-most pass is always the one picked */ | /* multiview: the ordering must be ascending, so the left-most pass is always the one picked */ | ||||
| for (rpass = rl ? rl->passes.first : NULL; rpass; rpass = rpass->next, nr++) { | for (rpass = rl ? rl->passes.first : NULL; rpass; rpass = rpass->next, nr++) { | ||||
| Show All 14 Lines | uiDefButS(block, | ||||
| &iuser->pass, | &iuser->pass, | ||||
| (float)nr, | (float)nr, | ||||
| 0.0, | 0.0, | ||||
| 0, | 0, | ||||
| -1, | -1, | ||||
| ""); | ""); | ||||
| } | } | ||||
| 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); | BLI_freelistN(&added_passes); | ||||
| BKE_image_release_renderresult(scene, image); | BKE_image_release_renderresult(scene, image); | ||||
| } | } | ||||
| /**************************** view menus *****************************/ | /**************************** view menus *****************************/ | ||||
| static void ui_imageuser_view_menu_rr(bContext *UNUSED(C), uiLayout *layout, void *rnd_pt) | static void ui_imageuser_view_menu_rr(bContext *UNUSED(C), uiLayout *layout, void *rnd_pt) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||