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:
authorHarley Acheson <harley.acheson@gmail.com>2020-03-14 21:05:09 +0300
committerHarley Acheson <harley.acheson@gmail.com>2020-03-14 21:05:09 +0300
commita210b8297f5afe6eaf2d001e57c1e8b7e8429c52 (patch)
treeb7760da467e778d34768183ea99cce590acbedd0 /source/blender/editors
parenta816a067ede6c8df3fc3a32bba2370a0ef179061 (diff)
UI: Larger Alert Icons
Adding a set of larger icons for use in informational dialogs. Differential Revision: https://developer.blender.org/D6859 Reviewed by Campbell Barton
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/datafiles/CMakeLists.txt1
-rw-r--r--source/blender/editors/include/ED_datafiles.h3
-rw-r--r--source/blender/editors/include/UI_interface.h5
-rw-r--r--source/blender/editors/include/UI_interface_icons.h11
-rw-r--r--source/blender/editors/interface/interface.c42
-rw-r--r--source/blender/editors/interface/interface_draw.c24
-rw-r--r--source/blender/editors/interface/interface_icons.c24
-rw-r--r--source/blender/editors/space_image/image_ops.c9
8 files changed, 105 insertions, 14 deletions
diff --git a/source/blender/editors/datafiles/CMakeLists.txt b/source/blender/editors/datafiles/CMakeLists.txt
index 3b56e39dcac..1b147663a7e 100644
--- a/source/blender/editors/datafiles/CMakeLists.txt
+++ b/source/blender/editors/datafiles/CMakeLists.txt
@@ -782,6 +782,7 @@ if(WITH_BLENDER)
# images
data_to_c_simple(../../../../release/datafiles/splash.png SRC)
data_to_c_simple(../../../../release/datafiles/splash_2x.png SRC)
+ data_to_c_simple(../../../../release/datafiles/alert_icons.png SRC)
# XXX These are handy, but give nasty "false changes" in svn :/
# svg_to_png(../../../../release/datafiles/blender_icons.svg
# ../../../../release/datafiles/blender_icons16.png
diff --git a/source/blender/editors/include/ED_datafiles.h b/source/blender/editors/include/ED_datafiles.h
index c1f5eddd8df..a2ad343da37 100644
--- a/source/blender/editors/include/ED_datafiles.h
+++ b/source/blender/editors/include/ED_datafiles.h
@@ -48,6 +48,9 @@ extern char datatoc_blender_icons32_png[];
extern int datatoc_prvicons_png_size;
extern char datatoc_prvicons_png[];
+extern int datatoc_alert_icons_png_size;
+extern char datatoc_alert_icons_png[];
+
extern int datatoc_splash_png_size;
extern char datatoc_splash_png[];
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index dba95c5106e..71263a65a36 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -1124,7 +1124,10 @@ uiBut *uiDefIconButO_ptr(uiBlock *block,
short width,
short height,
const char *tip);
-
+uiBut *uiDefButImage(
+ uiBlock *block, void *imbuf, int x, int y, short width, short height, const uchar color[4]);
+uiBut *uiDefButAlert(
+ uiBlock *block, int icon, int x, int y, short width, short height);
uiBut *uiDefIconTextBut(uiBlock *block,
int type,
int retval,
diff --git a/source/blender/editors/include/UI_interface_icons.h b/source/blender/editors/include/UI_interface_icons.h
index 6bf0cb8952d..a304c76bc9d 100644
--- a/source/blender/editors/include/UI_interface_icons.h
+++ b/source/blender/editors/include/UI_interface_icons.h
@@ -52,6 +52,17 @@ typedef struct IconFile {
#define PREVIEW_DEFAULT_HEIGHT 128
+typedef enum eAlertIcon {
+ ALERT_ICON_WARNING = 0,
+ ALERT_ICON_QUESTION = 1,
+ ALERT_ICON_ERROR = 2,
+ ALERT_ICON_INFO = 3,
+ ALERT_ICON_BLENDER = 4,
+ ALERT_ICON_MAX,
+} eAlertIcon;
+
+struct ImBuf *UI_alert_image(eAlertIcon icon);
+
/*
* Resizable Icons for Blender
*/
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index a0a3d0a3b85..b5fce7ea99f 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -4439,6 +4439,48 @@ uiBut *uiDefBut(uiBlock *block,
return but;
}
+uiBut *uiDefButImage(
+ uiBlock *block, void *imbuf, int x, int y, short width, short height, const uchar color[4])
+{
+ uiBut *but = ui_def_but(
+ block, UI_BTYPE_IMAGE, 0, "", x, y, width, height, imbuf, 0, 0, 0, 0, "");
+ if (color) {
+ copy_v4_v4_uchar(but->col, color);
+ }
+ else {
+ but->col[0] = 255;
+ but->col[1] = 255;
+ but->col[2] = 255;
+ but->col[3] = 255;
+ }
+ ui_but_update(but);
+ return but;
+}
+
+uiBut *uiDefButAlert(uiBlock *block, int icon, int x, int y, short width, short height)
+{
+ struct ImBuf *ibuf = UI_alert_image(icon);
+
+ if (icon == ALERT_ICON_BLENDER) {
+ return uiDefButImage(block, ibuf, x, y, width, height, NULL);
+ }
+ else {
+ uchar icon_color[4];
+ ThemeColorID color_id = TH_INFO_WARNING;
+ if (icon == ALERT_ICON_ERROR) {
+ color_id = TH_INFO_ERROR;
+ }
+ else if (icon == ALERT_ICON_INFO) {
+ color_id = TH_INFO_INFO;
+ }
+ else if (icon == ALERT_ICON_QUESTION) {
+ color_id = TH_INFO_PROPERTY;
+ }
+ UI_GetThemeColorType4ubv(color_id, SPACE_INFO, icon_color);
+ return uiDefButImage(block, ibuf, x, y, width, height, icon_color);
+ }
+}
+
/**
* if \a _x_ is a power of two (only one bit) return the power,
* otherwise return -1.
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index e8e74e77425..2800d808889 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -707,9 +707,6 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(region),
return;
}
- float facx = 1.0f;
- float facy = 1.0f;
-
int w = BLI_rcti_size_x(rect);
int h = BLI_rcti_size_y(rect);
@@ -722,10 +719,18 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(region),
# endif
GPU_blend(true);
+ /* Combine with premultiplied alpha. */
+ GPU_blend_set_func_separate(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
if (w != ibuf->x || h != ibuf->y) {
- facx = (float)w / (float)ibuf->x;
- facy = (float)h / (float)ibuf->y;
+ /* We scale the bitmap, rather than have OGL do a worse job. */
+ IMB_scaleImBuf(ibuf, w, h);
+ }
+
+ float col[4] = {1.0f, 1.0f, 1.0f, 1.0f};
+ if (but->col[3] != 0) {
+ /* Optionally use uiBut's col to recolor the image. */
+ rgba_uchar_to_float(col, but->col);
}
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
@@ -738,11 +743,14 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(region),
GL_UNSIGNED_BYTE,
GL_NEAREST,
ibuf->rect,
- facx,
- facy,
- NULL);
+ 1.0f,
+ 1.0f,
+ col);
GPU_blend(false);
+ /* Reset default. */
+ GPU_blend_set_func_separate(
+ GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
# if 0
// restore scissortest
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 3e07023e52d..8dd449b4b67 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -177,6 +177,30 @@ static const IconType icontypes[] = {
# include "UI_icons.h"
};
+/* ********** Alert Icons ********** */
+
+# define ALERT_IMG_SIZE 256
+
+ImBuf *UI_alert_image(eAlertIcon icon)
+{
+# ifdef WITH_HEADLESS
+ return NULL
+# else
+ ImBuf *ibuf;
+ icon = MIN2(icon, ALERT_ICON_MAX - 1);
+ const int left = icon * ALERT_IMG_SIZE;
+ const rcti crop = {left, left + ALERT_IMG_SIZE - 1, 0, ALERT_IMG_SIZE - 1};
+ ibuf = IMB_ibImageFromMemory((const uchar *)datatoc_alert_icons_png,
+ datatoc_alert_icons_png_size,
+ IB_rect,
+ NULL,
+ "alert_icon");
+ IMB_rect_crop(ibuf, &crop);
+ IMB_premultiply_alpha(ibuf);
+ return ibuf;
+#endif
+}
+
/* **************************************************** */
static DrawInfo *def_internal_icon(
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 34ff61749b2..8710b02e2a5 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -2351,7 +2351,7 @@ int ED_image_save_all_modified_info(const Main *bmain, ReportList *reports)
else {
BKE_reportf(reports,
RPT_WARNING,
- "Packed library image: %s from library %s can't be saved",
+ "Packed library image can't be saved: \"%s\" from \"%s\"",
ima->id.name + 2,
ima->id.lib->name);
}
@@ -2359,7 +2359,7 @@ int ED_image_save_all_modified_info(const Main *bmain, ReportList *reports)
else if (!is_format_writable) {
BKE_reportf(reports,
RPT_WARNING,
- "Image %s can't be saved automatically, must use a different file format",
+ "Image can't be saved, use a different file format: \"%s\"",
ima->id.name + 2);
}
else {
@@ -2368,7 +2368,7 @@ int ED_image_save_all_modified_info(const Main *bmain, ReportList *reports)
if (BLI_gset_haskey(unique_paths, ima->name)) {
BKE_reportf(reports,
RPT_WARNING,
- "File path used by more than one saved image: %s",
+ "Multiple images can't be saved to an identical path: \"%s\"",
ima->name);
}
else {
@@ -2378,8 +2378,7 @@ int ED_image_save_all_modified_info(const Main *bmain, ReportList *reports)
else {
BKE_reportf(reports,
RPT_WARNING,
- "Image %s can't be saved, no valid file path: %s",
- ima->id.name + 2,
+ "Image can't be saved, no valid file path: \"%s\"",
ima->name);
}
}