BMenu: BMenuBar submenus at screen edge moved onscreen instead of scrolling

Fixes #9093
Change-Id: I1322c0cd8ba4bbfddace037ed8a8ef666ebe7fe3
This commit is contained in:
David Murphy 2018-07-17 04:34:19 -04:00 committed by waddlesplash
parent b19fc3b65d
commit 9ece492008

View File

@ -2437,15 +2437,9 @@ BMenu::_CalcFrame(BPoint where, bool* scrollOn)
frame.OffsetBy(0, screenFrame.bottom - frame.bottom);
} else {
if (frame.bottom > screenFrame.bottom) {
if (scrollOn != NULL && superMenu != NULL
&& dynamic_cast<BMenuBar*>(superMenu) != NULL
&& frame.top < (screenFrame.bottom - 80)) {
scroll = true;
} else {
frame.OffsetBy(0, -superItem->Frame().Height()
- frame.Height() - 3);
}
}
if (frame.right > screenFrame.right)
frame.OffsetBy(screenFrame.right - frame.right, 0);
@ -2928,20 +2922,17 @@ BMenu::_UpdateWindowViewSize(const bool &move)
} else {
BScreen screen(window);
// Only scroll on menus not attached to a menubar, or when the
// menu frame is above the visible screen
if (dynamic_cast<BMenuBar*>(Supermenu()) == NULL || frame.top < 0) {
// If we need scrolling, resize the window to fit the screen and
// attach scrollers to our cached BMenuWindow.
if (dynamic_cast<BMenuBar*>(Supermenu()) == NULL || frame.top < 0) {
window->ResizeTo(Bounds().Width(), screen.Frame().Height());
frame.top = 0;
} else {
// Or, in case our parent was a BMenuBar enable scrolling with
// normal size.
window->ResizeTo(Bounds().Width(),
screen.Frame().bottom - frame.top);
}
if (fLayout == B_ITEMS_IN_COLUMN) {
// we currently only support scrolling for B_ITEMS_IN_COLUMN
if (fLayout == B_ITEMS_IN_COLUMN) {
window->AttachScrollers();
BMenuItem* selectedItem = FindMarked();
@ -2959,6 +2950,7 @@ BMenu::_UpdateWindowViewSize(const bool &move)
}
}
}
}
} else {
_CacheFontInfo();
window->ResizeTo(StringWidth(BPrivate::kEmptyMenuLabel)