From ff39fef2a41d56cebbbcc0666cbc4a9d1736a33c Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Fri, 22 Jun 2007 21:52:53 +0000 Subject: [PATCH] * ceilf() both font ascent and descent individually before adding them up to compute the vertical space requirement of the label. * Use a better algorithm for vertically aligning the label. The menu bar (or item) seems to use another algorithm. So, ATM the label is not necessarily aligned with the menu bar text. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21495 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/MenuField.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/kits/interface/MenuField.cpp b/src/kits/interface/MenuField.cpp index 69edfb823a..6762420e6c 100644 --- a/src/kits/interface/MenuField.cpp +++ b/src/kits/interface/MenuField.cpp @@ -790,8 +790,11 @@ BMenuField::DrawLabel(BRect bounds, BRect update) break; } - // vertical alignment -- center the ascent - float y = floor((Bounds().Height() + fh.ascent) / 2); + // vertical alignment + float y = Bounds().top + + (Bounds().Height() + 1 - fh.ascent - fh.descent) / 2 + + fh.ascent; + y = floor(y + 0.5); SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), IsEnabled() ? B_DARKEN_MAX_TINT : B_DISABLED_LABEL_TINT)); @@ -905,7 +908,7 @@ BMenuField::_ValidateLayoutData() GetFontHeight(&fh); fLayoutData->label_width = (Label() ? ceilf(StringWidth(Label())) : 0); - fLayoutData->label_height = ceilf(fh.ascent + fh.descent); + fLayoutData->label_height = ceilf(fh.ascent) + ceilf(fh.descent); // compute the minimal divider float divider = 0;