BControlLook::DrawLabel(): Fix off-by-one error
* BFont::TruncateString() expects a pixel count (as opposed to a pixel distance). That would cause a tightly fitting string to be truncated. * Round the result of StringWidth() to avoid drawing at a non-integer location.
This commit is contained in:
@@ -1889,7 +1889,7 @@ BControlLook::DrawLabel(BView* view, const char* label, const BBitmap* icon,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// label, possibly with icon
|
// label, possibly with icon
|
||||||
float availableWidth = rect.Width();
|
float availableWidth = rect.Width() + 1;
|
||||||
float width = 0;
|
float width = 0;
|
||||||
float textOffset = 0;
|
float textOffset = 0;
|
||||||
float height = 0;
|
float height = 0;
|
||||||
@@ -1908,7 +1908,7 @@ BControlLook::DrawLabel(BView* view, const char* label, const BBitmap* icon,
|
|||||||
view->GetFont(&font);
|
view->GetFont(&font);
|
||||||
|
|
||||||
font.TruncateString(&truncatedLabel, B_TRUNCATE_END, availableWidth);
|
font.TruncateString(&truncatedLabel, B_TRUNCATE_END, availableWidth);
|
||||||
width += font.StringWidth(truncatedLabel.String());
|
width += ceilf(font.StringWidth(truncatedLabel.String()));
|
||||||
|
|
||||||
font_height fontHeight;
|
font_height fontHeight;
|
||||||
font.GetHeight(&fontHeight);
|
font.GetHeight(&fontHeight);
|
||||||
|
|||||||
Reference in New Issue
Block a user