* 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
This commit is contained in:
Ingo Weinhold 2007-06-22 21:52:53 +00:00
parent 20bda75303
commit ff39fef2a4

View File

@ -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;