Menuitems are layoutted better, fixing bug 526

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17282 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2006-04-30 20:24:30 +00:00
parent 29dfc8d391
commit 4436b7269d
2 changed files with 9 additions and 6 deletions
+7 -5
View File
@@ -1400,22 +1400,24 @@ BMenu::ComputeLayout(int32 index, bool bestFit, bool moveItems,
if (item->fModifiers && item->fShortcutChar) if (item->fModifiers && item->fShortcutChar)
iWidth += 25.0f; iWidth += 25.0f;
if (item->fSubmenu != NULL)
iWidth += 20.0f;
item->fBounds.left = 0.0f; item->fBounds.left = 0.0f;
item->fBounds.top = frame.bottom; item->fBounds.top = frame.bottom;
item->fBounds.bottom = item->fBounds.top + iHeight + fPad.top + fPad.bottom; item->fBounds.bottom = item->fBounds.top + iHeight + fPad.top + fPad.bottom;
frame.right = max_c(frame.right, iWidth + fPad.left + fPad.right + 20); frame.right = max_c(frame.right, iWidth + fPad.left + fPad.right);
frame.bottom = item->fBounds.bottom + 1.0f; frame.bottom = item->fBounds.bottom + 1.0f;
} }
} }
if (fMaxContentWidth > 0) if (fMaxContentWidth > 0)
frame.right = min_c(frame.right, fMaxContentWidth); frame.right = min_c(frame.right, fMaxContentWidth);
//if (moveItems) { if (moveItems) {
for (int32 i = 0; i < fItems.CountItems(); i++) for (int32 i = 0; i < fItems.CountItems(); i++)
ItemAt(i)->fBounds.right = frame.right; ItemAt(i)->fBounds.right = frame.right;
//} }
frame.right = ceilf(frame.right); frame.right = ceilf(frame.right);
frame.bottom--; frame.bottom--;
break; break;
@@ -1441,10 +1443,10 @@ BMenu::ComputeLayout(int32 index, bool bestFit, bool moveItems,
} }
} }
//if (moveItems) { if (moveItems) {
for (int32 i = 0; i < fItems.CountItems(); i++) for (int32 i = 0; i < fItems.CountItems(); i++)
ItemAt(i)->fBounds.bottom = frame.bottom; ItemAt(i)->fBounds.bottom = frame.bottom;
//} }
frame.right = ceilf(frame.right); frame.right = ceilf(frame.right);
break; break;
+2 -1
View File
@@ -119,7 +119,8 @@ BMenuFrame::Draw(BRect updateRect)
font_height height; font_height height;
GetFontHeight(&height); GetFontHeight(&height);
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DISABLED_LABEL_TINT)); SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DISABLED_LABEL_TINT));
DrawString(kEmptyMenuLabel, BPoint(3, ceilf(height.ascent + 2))); BPoint where((Bounds().Width() - fMenu->StringWidth(kEmptyMenuLabel)) / 2, ceilf(height.ascent + 1));
DrawString(kEmptyMenuLabel, where);
} }
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_2_TINT)); SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_2_TINT));