UI: word-wrap for tooltips, broke text alignment
authorCampbell Barton <ideasman42@gmail.com>
Sat, 19 Sep 2015 04:50:35 +0000 (14:50 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 19 Sep 2015 05:22:03 +0000 (15:22 +1000)
This wasn't visible with default settings,
but caused problems w/ pie-menu's & manually adjusted theme font-size.

Now only draw from the bound-box top w/ word-wrap enabled.

source/blender/editors/interface/interface_style.c

index 5d0d82e3b1e1b77eb8653b29f72bba50a9bd517a..25a187c43ad5662ff8a05af53a412866e4d2f01e 100644 (file)
@@ -172,7 +172,14 @@ void UI_fontstyle_draw_ex(
 
        BLF_enable(fs->uifont_id, font_flag);
 
-       yofs = BLI_rcti_size_y(rect) - BLF_height_max(fs->uifont_id);
+       if (fs->word_wrap == 1) {
+               /* draw from boundbox top */
+               yofs = BLI_rcti_size_y(rect) - BLF_height_max(fs->uifont_id);
+       }
+       else {
+               /* draw from boundbox center */
+               yofs = ceil(0.5f * (BLI_rcti_size_y(rect) - BLF_ascender(fs->uifont_id)));
+       }
 
        if (fs->align == UI_STYLE_TEXT_CENTER) {
                xofs = floor(0.5f * (BLI_rcti_size_x(rect) - BLF_width(fs->uifont_id, str, len)));