Nodes: Various UI cleanups for Image and Environment Texture Nodes

Mainly consistency changes and smaller fixes.

* Environment Texture Nodes:
** show image info
** split layout for menus (showing menu title on the left)
** hierarchical button order

* Image Nodes:
** disable Alpha Mode menu if Use Alpha is disabled
** Don't show "+" icon/button if an image is already loaded
** Consistent alignment of menu buttons (see Input Color Space menu)

Requested and approved by @venomgfx
This commit is contained in:
julianeisel 2015-02-09 23:11:30 +01:00
parent 64ef6e74f7
commit 25412d8ae2
Notes: blender-bot 2023-02-14 09:30:46 +01:00
Referenced by issue #43657, grease pencil crash
Referenced by issue #43624, Freestyle uses wrong colour on second Line Set with textured lines in Cycles
4 changed files with 50 additions and 24 deletions

View File

@ -892,6 +892,7 @@ void uiTemplateGameStates(uiLayout *layout, struct PointerRNA *ptr, const char *
void uiTemplateImage(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, int compact);
void uiTemplateImageSettings(uiLayout *layout, struct PointerRNA *imfptr, int color_management);
void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser);
void uiTemplateImageInfo(uiLayout *layout, struct bContext *C, Image *ima, ImageUser *iuser);
void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C);
void UI_but_func_operator_search(uiBut *but);
void uiTemplateOperatorSearch(uiLayout *layout);

View File

@ -3570,8 +3570,7 @@ void uiTemplateColorspaceSettings(uiLayout *layout, PointerRNA *ptr, const char
colorspace_settings_ptr = RNA_property_pointer_get(ptr, prop);
uiItemL(layout, IFACE_("Input Color Space:"), ICON_NONE);
uiItemR(layout, &colorspace_settings_ptr, "name", 0, "", ICON_NONE);
uiItemR(layout, &colorspace_settings_ptr, "name", 0, IFACE_("Color Space"), ICON_NONE);
}
void uiTemplateColormanagedViewSettings(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr, const char *propname)

View File

@ -64,6 +64,7 @@
#include "image_intern.h"
#define B_NOP -1
#define MAX_IMAGE_INFO_LEN 128
/* proto */
@ -640,8 +641,6 @@ static void rna_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg))
void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, PointerRNA *userptr, int compact)
{
#define MAX_INFO_LEN 128
PropertyRNA *prop;
PointerRNA imaptr;
RNAUpdateCb *cb;
@ -650,7 +649,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
Scene *scene = CTX_data_scene(C);
uiLayout *row, *split, *col;
uiBlock *block;
char str[MAX_INFO_LEN];
char str[MAX_IMAGE_INFO_LEN];
void *lock;
@ -687,14 +686,14 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
uiLayoutSetContextPointer(layout, "edit_image_user", userptr);
if (!compact)
uiTemplateID(layout, C, ptr, propname, "IMAGE_OT_new", "IMAGE_OT_open", NULL);
uiTemplateID(layout, C, ptr, propname, ima ? NULL : "IMAGE_OT_new", "IMAGE_OT_open", NULL);
if (ima) {
UI_block_funcN_set(block, rna_update_cb, MEM_dupallocN(cb), NULL);
if (ima->source == IMA_SRC_VIEWER) {
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);
image_info(scene, iuser, ima, ibuf, str, MAX_INFO_LEN);
image_info(scene, iuser, ima, ibuf, str, MAX_IMAGE_INFO_LEN);
BKE_image_release_ibuf(ima, ibuf, lock);
uiItemL(layout, ima->id.name + 2, ICON_NONE);
@ -763,10 +762,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
}
else if (ima->source != IMA_SRC_GENERATED) {
if (compact == 0) {
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);
image_info(scene, iuser, ima, ibuf, str, MAX_INFO_LEN);
BKE_image_release_ibuf(ima, ibuf, lock);
uiItemL(layout, str, ICON_NONE);
uiTemplateImageInfo(layout, C, ima, iuser);
}
}
@ -791,7 +787,9 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
if (has_alpha) {
col = uiLayoutColumn(layout, false);
uiItemR(col, &imaptr, "use_alpha", 0, NULL, ICON_NONE);
uiItemR(col, &imaptr, "alpha_mode", 0, IFACE_("Alpha"), ICON_NONE);
row = uiLayoutRow(col, false);
uiLayoutSetActive(row, RNA_boolean_get(&imaptr, "use_alpha"));
uiItemR(row, &imaptr, "alpha_mode", 0, IFACE_("Alpha"), ICON_NONE);
}
if (ima->source == IMA_SRC_MOVIE) {
@ -861,8 +859,6 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
}
MEM_freeN(cb);
#undef MAX_INFO_LEN
}
void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, int color_management)
@ -982,6 +978,24 @@ void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser
}
}
void uiTemplateImageInfo(uiLayout *layout, bContext *C, Image *ima, ImageUser *iuser)
{
ImBuf *ibuf;
char str[MAX_IMAGE_INFO_LEN];
void *lock;
if (!ima || !iuser)
return;
ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);
image_info(CTX_data_scene(C), iuser, ima, ibuf, str, MAX_IMAGE_INFO_LEN);
BKE_image_release_ibuf(ima, ibuf, lock);
uiItemL(layout, str, ICON_NONE);
}
#undef MAX_IMAGE_INFO_LEN
void image_buttons_register(ARegionType *UNUSED(art))
{

View File

@ -703,10 +703,10 @@ static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *ptr,
uiItemR(col, ptr, "use_auto_refresh", 0, NULL, ICON_NONE);
}
col = uiLayoutColumn(layout, false);
if (RNA_enum_get(imaptr, "type") == IMA_TYPE_MULTILAYER)
if (RNA_enum_get(imaptr, "type") == IMA_TYPE_MULTILAYER) {
col = uiLayoutColumn(layout, false);
uiItemR(col, ptr, "layer", 0, NULL, ICON_NONE);
}
}
static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA *ptr)
@ -839,10 +839,11 @@ static void node_shader_buts_tex_environment(uiLayout *layout, bContext *C, Poin
uiLayoutSetContextPointer(layout, "image_user", &iuserptr);
uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE);
uiItemR(layout, ptr, "projection", 0, "", ICON_NONE);
node_buts_image_user(layout, C, &iuserptr, &imaptr, &iuserptr);
uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE);
uiItemR(layout, ptr, "projection", 0, "", ICON_NONE);
}
static void node_shader_buts_tex_environment_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
@ -852,9 +853,14 @@ static void node_shader_buts_tex_environment_ex(uiLayout *layout, bContext *C, P
Image *ima = imaptr.data;
uiLayoutSetContextPointer(layout, "image_user", &iuserptr);
uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
uiTemplateID(layout, C, ptr, "image", ima ? NULL : "IMAGE_OT_new", "IMAGE_OT_open", NULL);
if (ima && ima->source != IMA_SRC_GENERATED) {
if (!ima)
return;
uiItemR(layout, &imaptr, "source", 0, IFACE_("Source"), ICON_NONE);
if (!(ELEM(ima->source, IMA_SRC_GENERATED, IMA_SRC_VIEWER))) {
uiLayout *row = uiLayoutRow(layout, true);
if (ima->packedfile)
@ -868,10 +874,16 @@ static void node_shader_buts_tex_environment_ex(uiLayout *layout, bContext *C, P
uiItemO(row, "", ICON_FILE_REFRESH, "image.reload");
}
uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE);
uiItemR(layout, ptr, "projection", 0, "", ICON_NONE);
/* multilayer? */
if (ima->type == IMA_TYPE_MULTILAYER && ima->rr) {
uiTemplateImageLayers(layout, C, ima, iuserptr.data);
}
else if (ima->source != IMA_SRC_GENERATED) {
uiTemplateImageInfo(layout, C, ima, iuserptr.data);
}
node_buts_image_user(layout, C, &iuserptr, &imaptr, &iuserptr);
uiItemR(layout, ptr, "color_space", 0, IFACE_("Color Space"), ICON_NONE);
uiItemR(layout, ptr, "projection", 0, IFACE_("Projection"), ICON_NONE);
}
static void node_shader_buts_tex_sky(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)