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
path: root/source
diff options
context:
space:
mode:
authorJulian Eisel <eiseljulian@gmail.com>2018-07-06 00:30:53 +0300
committerJulian Eisel <eiseljulian@gmail.com>2018-07-06 20:33:13 +0300
commit2a199f5093cf6dc537047f9456adffa52b6aa005 (patch)
tree579ec0a3a548dcbc19663159604db6d66d5f945b /source
parentd360eced65ba0919e0f2d6e24aaa766c07866846 (diff)
UI: Use flat triangle drawing for indicating submenus
Left the RIGHTARROW_THIN icon in, even though it's not used in C code anymore. However add-ons may do (e.g. Amaranth does).
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/interface/interface_intern.h3
-rw-r--r--source/blender/editors/interface/interface_panel.c35
-rw-r--r--source/blender/editors/interface/interface_widgets.c62
3 files changed, 60 insertions, 40 deletions
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 04e9e2b18b4..10b4ff58224 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -744,8 +744,7 @@ struct Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased);
struct Gwn_Batch *ui_batch_roundbox_widget_get(int tria);
struct Gwn_Batch *ui_batch_roundbox_shadow_get(void);
-void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy,
- float rad, bool use_alpha, const float color[4]);
+void ui_draw_anti_tria_rect(const rctf *rect, char dir, const float color[4]);
void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect);
void ui_draw_popover_back(ARegion *ar, struct uiStyle *style, uiBlock *block, rcti *rect);
void ui_draw_pie_center(uiBlock *block);
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index a99a6610e88..b930b39ba02 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -469,23 +469,6 @@ void UI_draw_icon_tri(float x, float y, char dir, const float color[4])
}
}
-/* triangle 'icon' inside rect */
-static void ui_draw_tria_rect(const rctf *rect, char dir)
-{
- float color[4];
- UI_GetThemeColor3fv(TH_TITLE, color);
- color[3] = 1.0f;
-
- if (dir == 'h') {
- float half = 0.5f * BLI_rctf_size_y(rect);
- UI_draw_anti_tria(rect->xmin, rect->ymin, rect->xmin, rect->ymax, rect->xmax, rect->ymin + half, color);
- }
- else {
- float half = 0.5f * BLI_rctf_size_x(rect);
- UI_draw_anti_tria(rect->xmin, rect->ymax, rect->xmax, rect->ymax, rect->xmin + half, rect->ymin, color);
- }
-}
-
static void ui_draw_anti_x(unsigned int pos, float x1, float y1, float x2, float y2)
{
@@ -853,12 +836,18 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
BLI_rctf_scale(&itemrect, 0.25f);
- if (is_closed_y)
- ui_draw_tria_rect(&itemrect, 'h');
- else if (is_closed_x)
- ui_draw_tria_rect(&itemrect, 'h');
- else
- ui_draw_tria_rect(&itemrect, 'v');
+ {
+ float tria_color[4];
+ UI_GetThemeColor3fv(TH_TITLE, tria_color);
+ tria_color[3] = 1.0f;
+
+ if (is_closed_y)
+ ui_draw_anti_tria_rect(&itemrect, 'h', tria_color);
+ else if (is_closed_x)
+ ui_draw_anti_tria_rect(&itemrect, 'h', tria_color);
+ else
+ ui_draw_anti_tria_rect(&itemrect, 'v', tria_color);
+ }
}
/************************** panel alignment *************************/
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index c390c3fdda8..c70b9b72a07 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -532,6 +532,20 @@ void UI_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y
GPU_blend(false);
}
+/* triangle 'icon' inside rect */
+void ui_draw_anti_tria_rect(const rctf *rect, char dir, const float color[4])
+{
+ if (dir == 'h') {
+ float half = 0.5f * BLI_rctf_size_y(rect);
+ UI_draw_anti_tria(rect->xmin, rect->ymin, rect->xmin, rect->ymax, rect->xmax, rect->ymin + half, color);
+ }
+ else {
+ float half = 0.5f * BLI_rctf_size_x(rect);
+ UI_draw_anti_tria(rect->xmin, rect->ymax, rect->xmax, rect->ymax, rect->xmin + half, rect->ymin, color);
+ }
+}
+
+
void UI_draw_anti_fan(float tri_array[][2], unsigned int length, const float color[4])
{
float draw_color[4];
@@ -1255,8 +1269,8 @@ static int ui_but_draw_menu_icon(const uiBut *but)
/* icons have been standardized... and this call draws in untransformed coordinates */
static void widget_draw_icon_ex(
- const uiBut *but, BIFIconID icon, float alpha, const rcti *rect, const bool show_menu_icon,
- const int icon_size)
+ const uiBut *but, BIFIconID icon, float alpha,
+ const rcti *rect, const int icon_size)
{
float xs = 0.0f, ys = 0.0f;
float aspect, height;
@@ -1331,20 +1345,35 @@ static void widget_draw_icon_ex(
}
}
- if (show_menu_icon) {
- xs = rect->xmax - UI_DPI_ICON_SIZE - aspect;
- ys = (rect->ymin + rect->ymax - height) / 2.0f;
-
- UI_icon_draw_aspect(xs, ys, ICON_RIGHTARROW_THIN, aspect, alpha);
- }
-
GPU_blend(false);
}
static void widget_draw_icon(
- const uiBut *but, BIFIconID icon, float alpha, const rcti *rect, const bool show_menu_icon)
+ const uiBut *but, BIFIconID icon, float alpha, const rcti *rect)
{
- widget_draw_icon_ex(but, icon, alpha, rect, show_menu_icon, ICON_DEFAULT_HEIGHT);
+ widget_draw_icon_ex(but, icon, alpha, rect, ICON_DEFAULT_HEIGHT);
+}
+
+static void widget_draw_submenu_tria(const uiBut *but, const rcti *rect, const uiWidgetColors *wcol)
+{
+ const float aspect = but->block->aspect / UI_DPI_FAC;
+ const int tria_height = (int)(ICON_DEFAULT_HEIGHT / aspect);
+ const int tria_width = (int)(ICON_DEFAULT_WIDTH / aspect) - 2 * U.pixelsize;
+ const int xs = rect->xmax - UI_DPI_ICON_SIZE - aspect;
+ const int ys = (rect->ymin + rect->ymax - tria_height) / 2.0f;
+ float col[4];
+ rctf tria_rect;
+
+ rgba_uchar_to_float(col, (const uchar *)wcol->text);
+ col[3] *= 0.8f;
+
+ BLI_rctf_init(&tria_rect, xs, xs + tria_width, ys, ys + tria_height);
+ BLI_rctf_scale(&tria_rect, 0.4f);
+
+ GPU_blend(true);
+ UI_widgetbase_draw_cache_flush();
+ GPU_blend(false);
+ ui_draw_anti_tria_rect(&tria_rect, 'h', col);
}
static void ui_text_clip_give_prev_off(uiBut *but, const char *str)
@@ -1987,7 +2016,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
if (ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_POPOVER) && (but->flag & UI_BUT_NODE_LINK)) {
rcti temp = *rect;
temp.xmin = rect->xmax - BLI_rcti_size_y(rect) - 1;
- widget_draw_icon(but, ICON_LAYER_USED, alpha, &temp, false);
+ widget_draw_icon(but, ICON_LAYER_USED, alpha, &temp);
rect->xmax = temp.xmin;
}
@@ -2057,7 +2086,10 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
else if (ui_block_is_menu(but->block))
rect->xmin += 0.3f * U.widget_unit;
- widget_draw_icon(but, icon, alpha, rect, show_menu_icon);
+ widget_draw_icon(but, icon, alpha, rect);
+ if (show_menu_icon) {
+ widget_draw_submenu_tria(but, rect, wcol);
+ }
#ifdef USE_UI_TOOLBAR_HACK
but->block->aspect = aspect_orig;
@@ -2084,10 +2116,10 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
temp.xmin = temp.xmax - (BLI_rcti_size_y(rect) * 1.08f);
if (extra_icon_type == UI_BUT_ICONEXTRA_CLEAR) {
- widget_draw_icon(but, ICON_PANEL_CLOSE, alpha, &temp, false);
+ widget_draw_icon(but, ICON_PANEL_CLOSE, alpha, &temp);
}
else if (extra_icon_type == UI_BUT_ICONEXTRA_EYEDROPPER) {
- widget_draw_icon(but, ICON_EYEDROPPER, alpha, &temp, false);
+ widget_draw_icon(but, ICON_EYEDROPPER, alpha, &temp);
}
else {
BLI_assert(0);