diff --git a/headers/os/interface/Menu.h b/headers/os/interface/Menu.h index 60ba113883..4ef27a77f5 100644 --- a/headers/os/interface/Menu.h +++ b/headers/os/interface/Menu.h @@ -214,7 +214,7 @@ private: bool moveItems, float* width, float* height); void _ComputeColumnLayout(int32 index, bool bestFit, - bool moveItems, BRect& outRect); + bool moveItems, BRect* override, BRect& outRect); void _ComputeRowLayout(int32 index, bool bestFit, bool moveItems, BRect& outRect); void _ComputeMatrixLayout(BRect& outRect); diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index 7221611f5d..e8b7283e72 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -2119,9 +2119,18 @@ BMenu::_ComputeLayout(int32 index, bool bestFit, bool moveItems, switch (fLayout) { case B_ITEMS_IN_COLUMN: - _ComputeColumnLayout(index, bestFit, moveItems, frame); - break; + { + BRect parentFrame; + BRect* overrideFrame = NULL; + if (dynamic_cast<_BMCMenuBar_*>(Supermenu()) != NULL) { + parentFrame = Supermenu()->Bounds(); + overrideFrame = &parentFrame; + } + _ComputeColumnLayout(index, bestFit, moveItems, overrideFrame, + frame); + break; + } case B_ITEMS_IN_ROW: _ComputeRowLayout(index, bestFit, moveItems, frame); break; @@ -2164,7 +2173,7 @@ BMenu::_ComputeLayout(int32 index, bool bestFit, bool moveItems, void BMenu::_ComputeColumnLayout(int32 index, bool bestFit, bool moveItems, - BRect& frame) + BRect* overrideFrame, BRect& frame) { BFont font; GetFont(&font); @@ -2174,7 +2183,9 @@ BMenu::_ComputeColumnLayout(int32 index, bool bestFit, bool moveItems, bool option = false; if (index > 0) frame = ItemAt(index - 1)->Frame(); - else + else if (overrideFrame != NULL) { + frame.Set(0, 0, overrideFrame->right, -1); + } else frame.Set(0, 0, 0, -1); for (; index < fItems.CountItems(); index++) { @@ -2326,13 +2337,12 @@ BMenu::_CalcFrame(BPoint where, bool* scrollOn) BMenu* superMenu = Supermenu(); BMenuItem* superItem = Superitem(); - bool scroll = false; - // TODO: Horrible hack: // When added to a BMenuField, a BPopUpMenu is the child of // a _BMCMenuBar_ to "fake" the menu hierarchy - if (superMenu == NULL || superItem == NULL - || dynamic_cast<_BMCMenuBar_*>(superMenu) != NULL) { + bool inMenuField = dynamic_cast<_BMCMenuBar_*>(superMenu) != NULL; + bool scroll = false; + if (superMenu == NULL || superItem == NULL || inMenuField) { // just move the window on screen if (frame.bottom > screenFrame.bottom)