diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-08-07 21:06:04 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-08-07 21:10:55 +0300 |
commit | aad16afb56d8f4121d4dff115554511075cfc7e8 (patch) | |
tree | 77606ecd3d222734764e694ec06857fe53e23786 /source/blender/editors/interface/interface_widgets.c | |
parent | dfa2cf6f3d8f78f9ae2254276cd0dbb4fc098f22 (diff) |
Benchmark: add link button drawing, with underline on hover.
Diffstat (limited to 'source/blender/editors/interface/interface_widgets.c')
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index d0cdba49536..f9dbd9dec01 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1316,7 +1316,7 @@ static void widget_draw_icon_ex( /* special case - icon_only pie buttons */ if (ui_block_is_pie_menu(but->block) && !ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_POPOVER) && but->str && but->str[0] == '\0') xs = rect->xmin + 2.0f * ofs; - else if (but->dt == UI_EMBOSS_NONE || but->type == UI_BTYPE_LABEL) + else if (ELEM(but->dt, UI_EMBOSS_NONE, UI_EMBOSS_LINK) || but->type == UI_BTYPE_LABEL) xs = rect->xmin + 2.0f * ofs; else xs = rect->xmin + 4.0f * ofs; @@ -1954,6 +1954,17 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b UI_fontstyle_draw_ex(fstyle, rect, drawstr + but->ofs, (unsigned char *)wcol->text, drawlen, &font_xofs, &font_yofs); + if (but->dt == UI_EMBOSS_LINK && (but->flag & UI_ACTIVE)) { + float underline_col[4]; + int underline_width = UI_fontstyle_string_width(fstyle, drawstr + but->ofs); + int rect_x = BLI_rcti_size_x(rect); + + rgba_uchar_to_float(underline_col, (unsigned char *)wcol->text); + GPU_blend(true); + UI_draw_text_underline(rect->xmin + font_xofs, rect->ymin + 8 * U.pixelsize, min_ii(underline_width, rect_x - 2), 1, underline_col); + GPU_blend(false); + } + if (but->menu_key != '\0') { char fixedbuf[128]; const char *str; @@ -4063,7 +4074,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct break; } } - else if (but->dt == UI_EMBOSS_NONE) { + else if (ELEM(but->dt, UI_EMBOSS_NONE, UI_EMBOSS_LINK)) { /* "nothing" */ switch (but->type) { case UI_BTYPE_LABEL: |