diff --git a/headers/os/interface/Menu.h b/headers/os/interface/Menu.h index 4c6d76768a..e853da3905 100644 --- a/headers/os/interface/Menu.h +++ b/headers/os/interface/Menu.h @@ -292,7 +292,9 @@ static bool sAltAsCommandKey; BPoint *fInitMatrixSize; _ExtraMenuData_ *fExtraMenuData; - uint32 _reserved[2]; + uint32 _reserved[1]; + + int32 fSubmenus; char fTrigger; bool fResizeToFit; diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index bcbc1ef5ee..5d7d5efbd8 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -160,6 +160,7 @@ BMenu::BMenu(const char *name, menu_layout layout) fMaxContentWidth(0.0f), fInitMatrixSize(NULL), fExtraMenuData(NULL), + fSubmenus(0), fTrigger(0), fResizeToFit(true), fUseCachedMenuLayout(false), @@ -193,6 +194,7 @@ BMenu::BMenu(const char *name, float width, float height) fMaxContentWidth(0.0f), fInitMatrixSize(NULL), fExtraMenuData(NULL), + fSubmenus(0), fTrigger(0), fResizeToFit(true), fUseCachedMenuLayout(false), @@ -238,6 +240,7 @@ BMenu::BMenu(BMessage *archive) fMaxContentWidth(0.0f), fInitMatrixSize(NULL), fExtraMenuData(NULL), + fSubmenus(0), fTrigger(0), fResizeToFit(true), fUseCachedMenuLayout(false), @@ -983,6 +986,7 @@ BMenu::BMenu(BRect frame, const char *name, uint32 resizingMode, uint32 flags, fMaxContentWidth(0.0f), fInitMatrixSize(NULL), fExtraMenuData(NULL), + fSubmenus(0), fTrigger(0), fResizeToFit(resizeToFit), fUseCachedMenuLayout(false), @@ -1594,7 +1598,7 @@ BMenu::_ComputeColumnLayout(int32 index, bool bestFit, bool moveItems, BRect &fr item->fBounds.top = frame.bottom; item->fBounds.bottom = item->fBounds.top + iHeight + fPad.top + fPad.bottom; - if (item->fSubmenu != NULL) + if (fSubmenus) iWidth += item->Frame().Height(); frame.right = max_c(frame.right, iWidth + fPad.left + fPad.right); diff --git a/src/kits/interface/MenuItem.cpp b/src/kits/interface/MenuItem.cpp index 0ef3fb4c7b..3678c13cd9 100644 --- a/src/kits/interface/MenuItem.cpp +++ b/src/kits/interface/MenuItem.cpp @@ -649,11 +649,16 @@ BMenuItem::SetSuper(BMenu *super) { if (fSuper != NULL && super != NULL) debugger("Error - can't add menu or menu item to more than 1 container (either menu or menubar)."); - - fSuper = super; - if (fSubmenu != NULL) + if (fSubmenu != NULL) { + if (super) + super->fSubmenus++; + else if (fSuper) + fSuper->fSubmenus--; fSubmenu->fSuper = super; + } + + fSuper = super; } @@ -708,12 +713,13 @@ BMenuItem::_DrawMarkSymbol(rgb_color bgColor) void BMenuItem::_DrawShortcutSymbol() { + BMenu *menu = Menu(); BFont font; - Menu()->GetFont(&font); + menu->GetFont(&font); BPoint where = ContentLocation(); - where.x += fBounds.Width() - 28; - if (fSubmenu) - where.x -= fBounds.Height(); + where.x = fBounds.right - font.Size(); + if (menu->fSubmenus) + where.x -= fBounds.Height() - 4; switch (fShortcutChar) { case B_DOWN_ARROW: @@ -730,8 +736,8 @@ BMenuItem::_DrawShortcutSymbol() } where.y += (fBounds.Height() - 11) / 2 - 1; - where.x -= 5; - + where.x -= 4; + if (fModifiers & B_COMMAND_KEY) { BRect rect(0,0,16,10); BBitmap control(rect, B_CMAP8); @@ -775,6 +781,7 @@ BMenuItem::_DrawSubmenuSymbol(rgb_color bgColor) BRect r(fBounds); r.left = r.right - r.Height(); r.InsetBy(2.0, 2.0); + //r.OffsetBy(2.0, 0.0); fSuper->SetHighColor(tint_color(bgColor, kLightBGTint)); fSuper->FillRect(r);