Diskusage: avoid glitch in "open with..." menu

* Fixes #13097.
This commit is contained in:
Janus
2016-11-29 21:46:19 +01:00
parent 738ca0a3a3
commit 04a05cf1f6
+9 -12
View File
@@ -100,27 +100,24 @@ AppMenuItem::~AppMenuItem()
void
AppMenuItem::GetContentSize(float* _width, float* _height)
{
BMenuItem::GetContentSize(_width, _height);
if (_width)
*_width = fIcon->Bounds().Width()
+ be_plain_font->StringWidth(Label());
if (_height) {
struct font_height fh;
be_plain_font->GetHeight(&fh);
float fontHeight = ceilf(fh.ascent) + ceilf(fh.descent)
+ ceilf(fh.leading);
*_height = max_c(fontHeight, fIcon->Bounds().Height());
}
*_width += fIcon->Bounds().Width();
if (_height)
*_height = max_c(*_height, fIcon->Bounds().Height());
}
void
AppMenuItem::DrawContent()
{
float yOffset, height;
GetContentSize(NULL, &height);
yOffset = (height - fIcon->Bounds().Height()) / 2;
Menu()->SetDrawingMode(B_OP_OVER);
Menu()->MovePenBy(0.0, -1.0);
Menu()->MovePenBy(0.0, yOffset);
Menu()->DrawBitmap(fIcon);
Menu()->MovePenBy(fIcon->Bounds().Width() + kSmallHMargin, 0.0);
Menu()->MovePenBy(fIcon->Bounds().Width() + kSmallHMargin, -yOffset);
BMenuItem::DrawContent();
}