[Bf-blender-cvs] [aad16afb56d] temp-benchmark: Benchmark: add link button drawing, with underline on hover.
Brecht Van Lommel
noreply at git.blender.org
Tue Aug 7 20:11:25 CEST 2018
Commit: aad16afb56d8f4121d4dff115554511075cfc7e8
Author: Brecht Van Lommel
Date: Tue Aug 7 20:06:04 2018 +0200
Branches: temp-benchmark
https://developer.blender.org/rBaad16afb56d8f4121d4dff115554511075cfc7e8
Benchmark: add link button drawing, with underline on hover.
===================================================================
M source/blender/editors/include/UI_interface.h
M source/blender/editors/interface/interface_widgets.c
M source/blender/makesrna/intern/rna_ui.c
===================================================================
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index d174a78ee23..04c14beecdb 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -103,6 +103,7 @@ enum {
UI_EMBOSS_NONE = 1, /* Nothing, only icon and/or text */
UI_EMBOSS_PULLDOWN = 2, /* Pulldown menu style */
UI_EMBOSS_RADIAL = 3, /* Pie Menu */
+ UI_EMBOSS_LINK = 4, /* Benchmark: special link drawing */
UI_EMBOSS_UNDEFINED = 255, /* For layout engine, use emboss from block. */
};
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:
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c
index a271df464b7..80b49af0e9e 100644
--- a/source/blender/makesrna/intern/rna_ui.c
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -997,6 +997,7 @@ static void rna_def_ui_layout(BlenderRNA *brna)
{UI_EMBOSS_NONE, "NONE", 0, "None", "Draw only text and icons"},
{UI_EMBOSS_PULLDOWN, "PULLDOWN_MENU", 0, "Pulldown Menu", "Draw pulldown menu style"},
{UI_EMBOSS_RADIAL, "RADIAL_MENU", 0, "Radial Menu", "Draw radial menu style"},
+ {UI_EMBOSS_LINK, "LINK", 0, "Link", "Draw button as link"},
{0, NULL, 0, NULL, NULL}
};
More information about the Bf-blender-cvs
mailing list