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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-05-09 20:19:52 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-05-09 20:55:10 +0300
commit6148ed8cf9cadbd913667c2f80e9e44f584c0f1c (patch)
tree2f37120e374e30735c71ad0720438f1fc81ba8c5 /source/blender/editors
parent5f7eebda23b844e932294b1ecaced46b5c75dde0 (diff)
Cleanup: reduce number of UI_icon_draw variations
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/include/UI_interface_icons.h22
-rw-r--r--source/blender/editors/interface/interface_icons.c87
-rw-r--r--source/blender/editors/interface/interface_panel.c13
-rw-r--r--source/blender/editors/interface/interface_widgets.c18
-rw-r--r--source/blender/editors/screen/area.c2
-rw-r--r--source/blender/editors/space_file/file_draw.c2
6 files changed, 48 insertions, 96 deletions
diff --git a/source/blender/editors/include/UI_interface_icons.h b/source/blender/editors/include/UI_interface_icons.h
index 8b9f439ec1c..53bd0f01d34 100644
--- a/source/blender/editors/include/UI_interface_icons.h
+++ b/source/blender/editors/include/UI_interface_icons.h
@@ -53,6 +53,7 @@ typedef struct IconFile {
*/
void UI_icons_init(void);
void UI_icons_reload_internal_textures(void);
+
int UI_icon_get_width(int icon_id);
int UI_icon_get_height(int icon_id);
@@ -65,16 +66,16 @@ int UI_preview_render_size(enum eIconSizes size);
void UI_icon_draw(float x, float y, int icon_id);
void UI_icon_draw_alpha(float x, float y, int icon_id, float alpha);
-void UI_icon_draw_preview(float x, float y, int icon_id);
-void UI_icon_draw_preview_aspect(float x, float y, int icon_id, float aspect);
-void UI_icon_draw_preview_aspect_size(
- float x, float y, int icon_id, float aspect, float alpha, int size);
-
-void UI_icon_draw_aspect(
- float x, float y, int icon_id, float aspect, float alpha, const char mono_color[4]);
-void UI_icon_draw_aspect_color(
- float x, float y, int icon_id, float aspect, const float rgb[3], const char mono_color[4]);
-void UI_icon_draw_size(float x, float y, int size, int icon_id, float alpha);
+void UI_icon_draw_preview(float x, float y, int icon_id, float aspect, float alpha, int size);
+
+void UI_icon_draw_ex(float x,
+ float y,
+ int icon_id,
+ float aspect,
+ float alpha,
+ float desaturate,
+ const char mono_color[4]);
+
void UI_icon_draw_desaturate(float x,
float y,
int icon_id,
@@ -82,6 +83,7 @@ void UI_icon_draw_desaturate(float x,
float alpha,
float desaturate,
const char mono_color[4]);
+
void UI_icons_free(void);
void UI_icons_free_drawinfo(void *drawinfo);
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 7fdaa99c464..3b941969fd5 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -1467,7 +1467,6 @@ static void icon_draw_rect(float x,
int rh,
uint *rect,
float alpha,
- const float rgb[3],
const float desaturate)
{
ImBuf *ima = NULL;
@@ -1485,12 +1484,6 @@ static void icon_draw_rect(float x,
/* modulate color */
float col[4] = {1.0f, 1.0f, 1.0f, alpha};
- if (rgb) {
- col[0] = rgb[0];
- col[1] = rgb[1];
- col[2] = rgb[2];
- }
-
/* rect contains image in 'rendersize', we only scale if needed */
if (rw != w || rh != h) {
/* preserve aspect ratio and center */
@@ -1766,7 +1759,6 @@ static void icon_draw_size(float x,
int icon_id,
float aspect,
float alpha,
- const float rgb[3],
enum eIconSizes size,
int draw_size,
const float desaturate,
@@ -1827,7 +1819,7 @@ static void icon_draw_size(float x,
GPU_blend_set_func_separate(
GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
- icon_draw_rect(x, y, w, h, aspect, w, h, ibuf->rect, alpha, rgb, desaturate);
+ icon_draw_rect(x, y, w, h, aspect, w, h, ibuf->rect, alpha, desaturate);
GPU_blend_set_func_separate(
GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
}
@@ -1847,7 +1839,7 @@ static void icon_draw_size(float x,
di->data.texture.w,
di->data.texture.h,
alpha,
- rgb,
+ NULL,
false);
}
else if (di->type == ICON_TYPE_MONO_TEXTURE) {
@@ -1866,10 +1858,6 @@ static void icon_draw_size(float x,
with_border = (btheme->tui.icon_border_intensity > 0.0f);
}
- if (rgb) {
- mul_v3_v3(color, rgb);
- }
-
mul_v4_fl(color, alpha);
float border_outset = 0.0;
@@ -1903,7 +1891,7 @@ static void icon_draw_size(float x,
return;
}
- icon_draw_rect(x, y, w, h, aspect, iimg->w, iimg->h, iimg->rect, alpha, rgb, desaturate);
+ icon_draw_rect(x, y, w, h, aspect, iimg->w, iimg->h, iimg->rect, alpha, desaturate);
}
else if (di->type == ICON_TYPE_PREVIEW) {
PreviewImage *pi = (icon->id_type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) :
@@ -1920,7 +1908,7 @@ static void icon_draw_size(float x,
GPU_blend_set_func_separate(
GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
icon_draw_rect(
- x, y, w, h, aspect, pi->w[size], pi->h[size], pi->rect[size], alpha, rgb, desaturate);
+ x, y, w, h, aspect, pi->w[size], pi->h[size], pi->rect[size], alpha, desaturate);
GPU_blend_set_func_separate(
GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
}
@@ -2242,71 +2230,30 @@ int UI_idcode_icon_get(const int idcode)
}
}
-static void icon_draw_at_size(float x,
- float y,
- int icon_id,
- float aspect,
- float alpha,
- enum eIconSizes size,
- const float desaturate,
- const char mono_color[4])
-{
- int draw_size = get_draw_size(size);
- icon_draw_size(x, y, icon_id, aspect, alpha, NULL, size, draw_size, desaturate, mono_color);
-}
-
-void UI_icon_draw_aspect(
- float x, float y, int icon_id, float aspect, float alpha, const char mono_color[4])
-{
- icon_draw_at_size(x, y, icon_id, aspect, alpha, ICON_SIZE_ICON, 0.0f, mono_color);
-}
-
-void UI_icon_draw_aspect_color(
- float x, float y, int icon_id, float aspect, const float rgb[3], const char mono_color[4])
-{
- int draw_size = get_draw_size(ICON_SIZE_ICON);
- icon_draw_size(x, y, icon_id, aspect, 1.0f, rgb, ICON_SIZE_ICON, draw_size, false, mono_color);
-}
-
-void UI_icon_draw_desaturate(float x,
- float y,
- int icon_id,
- float aspect,
- float alpha,
- float desaturate,
- const char mono_color[4])
-{
- icon_draw_at_size(x, y, icon_id, aspect, alpha, ICON_SIZE_ICON, desaturate, mono_color);
-}
-
/* draws icon with dpi scale factor */
void UI_icon_draw(float x, float y, int icon_id)
{
- UI_icon_draw_aspect(x, y, icon_id, 1.0f / UI_DPI_FAC, 1.0f, NULL);
+ UI_icon_draw_ex(x, y, icon_id, 1.0f / UI_DPI_FAC, 1.0f, 0.0f, NULL);
}
void UI_icon_draw_alpha(float x, float y, int icon_id, float alpha)
{
- UI_icon_draw_aspect(x, y, icon_id, 1.0f / UI_DPI_FAC, alpha, NULL);
+ UI_icon_draw_ex(x, y, icon_id, 1.0f / UI_DPI_FAC, alpha, 0.0f, NULL);
}
-void UI_icon_draw_size(float x, float y, int size, int icon_id, float alpha)
+void UI_icon_draw_preview(float x, float y, int icon_id, float aspect, float alpha, int size)
{
- icon_draw_size(x, y, icon_id, 1.0f, alpha, NULL, ICON_SIZE_ICON, size, false, NULL);
+ icon_draw_size(x, y, icon_id, aspect, alpha, ICON_SIZE_PREVIEW, size, false, NULL);
}
-void UI_icon_draw_preview(float x, float y, int icon_id)
+void UI_icon_draw_ex(float x,
+ float y,
+ int icon_id,
+ float aspect,
+ float alpha,
+ float desaturate,
+ const char mono_color[4])
{
- icon_draw_at_size(x, y, icon_id, 1.0f, 1.0f, ICON_SIZE_PREVIEW, false, NULL);
-}
-
-void UI_icon_draw_preview_aspect(float x, float y, int icon_id, float aspect)
-{
- icon_draw_at_size(x, y, icon_id, aspect, 1.0f, ICON_SIZE_PREVIEW, false, NULL);
-}
-
-void UI_icon_draw_preview_aspect_size(
- float x, float y, int icon_id, float aspect, float alpha, int size)
-{
- icon_draw_size(x, y, icon_id, aspect, alpha, NULL, ICON_SIZE_PREVIEW, size, false, NULL);
+ int draw_size = get_draw_size(ICON_SIZE_ICON);
+ icon_draw_size(x, y, icon_id, aspect, alpha, ICON_SIZE_ICON, draw_size, desaturate, mono_color);
}
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 87e58a4b3b5..66fb609335d 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -765,12 +765,13 @@ void ui_draw_aligned_panel(uiStyle *style,
panel_title_color_get(show_background, col_title);
GPU_blend(true);
- UI_icon_draw_aspect(headrect.xmax - ((PNL_ICON * 2.2f) / block->aspect),
- headrect.ymin + (5.0f / block->aspect),
- (panel->flag & PNL_PIN) ? ICON_PINNED : ICON_UNPINNED,
- (block->aspect / UI_DPI_FAC),
- 1.0f,
- (const char *)col_title);
+ UI_icon_draw_ex(headrect.xmax - ((PNL_ICON * 2.2f) / block->aspect),
+ headrect.ymin + (5.0f / block->aspect),
+ (panel->flag & PNL_PIN) ? ICON_PINNED : ICON_UNPINNED,
+ (block->aspect / UI_DPI_FAC),
+ 1.0f,
+ 0.0f,
+ (const char *)col_title);
GPU_blend(false);
}
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 60aa360e923..62fc785a432 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1421,7 +1421,7 @@ static void widget_draw_preview(BIFIconID icon, float alpha, const rcti *rect)
int x = rect->xmin + w / 2 - size / 2;
int y = rect->ymin + h / 2 - size / 2;
- UI_icon_draw_preview_aspect_size(x, y, icon, 1.0f, alpha, size);
+ UI_icon_draw_preview(x, y, icon, 1.0f, alpha, size);
}
}
@@ -1508,16 +1508,18 @@ static void widget_draw_icon(
/* to indicate draggable */
if (but->dragpoin && (but->flag & UI_ACTIVE)) {
- float rgb[3] = {1.25f, 1.25f, 1.25f};
- UI_icon_draw_aspect_color(xs, ys, icon, aspect, rgb, mono_color);
+ UI_icon_draw_ex(xs, ys, icon, aspect, 1.25f, 0.0f, mono_color);
}
- else if ((but->flag & (UI_ACTIVE | UI_SELECT | UI_SELECT_DRAW)) || !UI_but_is_tool(but)) {
- UI_icon_draw_aspect(xs, ys, icon, aspect, alpha, mono_color);
+ else if ((but->flag & (UI_ACTIVE | UI_SELECT | UI_SELECT_DRAW))) {
+ UI_icon_draw_ex(xs, ys, icon, aspect, alpha, 0.0f, mono_color);
+ }
+ else if (!UI_but_is_tool(but)) {
+ UI_icon_draw_ex(xs, ys, icon, aspect, alpha, 0.0f, mono_color);
}
else {
const bTheme *btheme = UI_GetTheme();
- UI_icon_draw_desaturate(
- xs, ys, icon, aspect, alpha, 1.0 - btheme->tui.icon_saturation, mono_color);
+ const float desaturate = 1.0 - btheme->tui.icon_saturation;
+ UI_icon_draw_ex(xs, ys, icon, aspect, alpha, desaturate, mono_color);
}
}
@@ -5201,7 +5203,7 @@ void ui_draw_menu_item(
GPU_blend(true);
/* XXX scale weak get from fstyle? */
- UI_icon_draw_aspect(xs, ys, iconid, aspect, 1.0f, wt->wcol.text);
+ UI_icon_draw_ex(xs, ys, iconid, aspect, 1.0f, 0.0f, wt->wcol.text);
GPU_blend(false);
}
}
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 1bb7bf2fce7..765dfc9dd88 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -203,7 +203,7 @@ static void area_draw_azone_fullscreen(short x1, short y1, short x2, short y2, f
alpha = min_ff(alpha, 0.75f);
- UI_icon_draw_aspect(x, y, ICON_FULLSCREEN_EXIT, 0.7f / UI_DPI_FAC, alpha, NULL);
+ UI_icon_draw_ex(x, y, ICON_FULLSCREEN_EXIT, 0.7f / UI_DPI_FAC, 0.0f, alpha, NULL);
/* debug drawing :
* The click_rect is the same as defined in fullscreen_click_rcti_init
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index bb8680682d2..3b653f8af3b 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -478,7 +478,7 @@ static void file_draw_preview(uiBlock *block,
GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
if (icon) {
- UI_icon_draw_aspect((float)xco, (float)yco, icon, icon_aspect, 1.0f, NULL);
+ UI_icon_draw_ex((float)xco, (float)yco, icon, icon_aspect, 1.0f, 0.0f, NULL);
}
/* border */