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 21:21:40 +00:00
committed by waddlesplash
parent b19fc3b65d
commit 9ece492008
+6 -14
View File
@@ -2437,15 +2437,9 @@ BMenu::_CalcFrame(BPoint where, bool* scrollOn)
frame.OffsetBy(0, screenFrame.bottom - frame.bottom); frame.OffsetBy(0, screenFrame.bottom - frame.bottom);
} else { } else {
if (frame.bottom > screenFrame.bottom) { 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.OffsetBy(0, -superItem->Frame().Height()
- frame.Height() - 3); - frame.Height() - 3);
} }
}
if (frame.right > screenFrame.right) if (frame.right > screenFrame.right)
frame.OffsetBy(screenFrame.right - frame.right, 0); frame.OffsetBy(screenFrame.right - frame.right, 0);
@@ -2928,20 +2922,17 @@ BMenu::_UpdateWindowViewSize(const bool &move)
} else { } else {
BScreen screen(window); 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 // If we need scrolling, resize the window to fit the screen and
// attach scrollers to our cached BMenuWindow. // attach scrollers to our cached BMenuWindow.
if (dynamic_cast<BMenuBar*>(Supermenu()) == NULL || frame.top < 0) {
window->ResizeTo(Bounds().Width(), screen.Frame().Height()); window->ResizeTo(Bounds().Width(), screen.Frame().Height());
frame.top = 0; 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 // we currently only support scrolling for B_ITEMS_IN_COLUMN
if (fLayout == B_ITEMS_IN_COLUMN) {
window->AttachScrollers(); window->AttachScrollers();
BMenuItem* selectedItem = FindMarked(); BMenuItem* selectedItem = FindMarked();
@@ -2959,6 +2950,7 @@ BMenu::_UpdateWindowViewSize(const bool &move)
} }
} }
} }
}
} else { } else {
_CacheFontInfo(); _CacheFontInfo();
window->ResizeTo(StringWidth(BPrivate::kEmptyMenuLabel) window->ResizeTo(StringWidth(BPrivate::kEmptyMenuLabel)