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:
authorCampbell Barton <ideasman42@gmail.com>2015-01-20 07:48:40 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-01-20 07:50:20 +0300
commit289960787ea70b1d1acd528bee71e8f8439bf369 (patch)
treed6479b09269c5e22f9a2cfa3086205a378a9019c /source/blender/editors/interface/interface_style.c
parent09eec627ed730532905b45d409f9009023623437 (diff)
Fix UI glitches drawing text at different sizes
Font height was ignoring DPI in some cases (camera-name & eyedropper).
Diffstat (limited to 'source/blender/editors/interface/interface_style.c')
-rw-r--r--source/blender/editors/interface/interface_style.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index 2fe44b2a9b6..c42c911cd5c 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -45,6 +45,7 @@
#include "BKE_global.h"
+#include "BIF_gl.h"
#include "BLF_api.h"
#ifdef WITH_INTERNATIONAL
@@ -277,6 +278,47 @@ void UI_fontstyle_draw_simple(const uiFontStyle *fs, float x, float y, const cha
BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
}
+/**
+ * Same as #UI_fontstyle_draw but draw a colored backdrop.
+ */
+void UI_fontstyle_draw_simple_backdrop(
+ const uiFontStyle *fs, float x, float y, const char *str,
+ const unsigned char fg[4], const unsigned char bg[4])
+{
+ if (fs->kerning == 1)
+ BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
+
+ UI_fontstyle_set(fs);
+
+ {
+ const float width = BLF_width(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
+ const float height = BLF_height_max(fs->uifont_id);
+ const float decent = BLF_descender(fs->uifont_id);
+ const float margin = height / 4.0f;
+
+ /* backdrop */
+ glColor4ubv(bg);
+
+ UI_draw_roundbox_corner_set(UI_CNR_ALL | UI_RB_ALPHA);
+ UI_draw_roundbox(
+ x - margin,
+ (y + decent) - margin,
+ x + width + margin,
+ (y + decent) + height + margin,
+ margin);
+
+ glColor4ubv(fg);
+ }
+
+
+ BLF_position(fs->uifont_id, x, y, 0.0f);
+ BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
+
+ if (fs->kerning == 1)
+ BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
+}
+
+
/* ************** helpers ************************ */
/* XXX: read a style configure */
uiStyle *UI_style_get(void)
@@ -329,6 +371,13 @@ int UI_fontstyle_string_width(const uiFontStyle *fs, const char *str)
return width;
}
+int UI_fontstyle_height_max(const uiFontStyle *fs)
+{
+ UI_fontstyle_set(fs);
+ return BLF_height_max(fs->uifont_id);
+}
+
+
/* ************** init exit ************************ */
/* called on each startup.blend read */