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,14 +2437,8 @@ 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 frame.OffsetBy(0, -superItem->Frame().Height()
&& dynamic_cast<BMenuBar*>(superMenu) != NULL - frame.Height() - 3);
&& frame.top < (screenFrame.bottom - 80)) {
scroll = true;
} else {
frame.OffsetBy(0, -superItem->Frame().Height()
- frame.Height() - 3);
}
} }
if (frame.right > screenFrame.right) if (frame.right > screenFrame.right)
@ -2928,33 +2922,31 @@ BMenu::_UpdateWindowViewSize(const bool &move)
} else { } else {
BScreen screen(window); BScreen screen(window);
// If we need scrolling, resize the window to fit the screen and // Only scroll on menus not attached to a menubar, or when the
// attach scrollers to our cached BMenuWindow. // menu frame is above the visible screen
if (dynamic_cast<BMenuBar*>(Supermenu()) == NULL || frame.top < 0) { 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.
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
window->AttachScrollers(); if (fLayout == B_ITEMS_IN_COLUMN) {
window->AttachScrollers();
BMenuItem* selectedItem = FindMarked(); BMenuItem* selectedItem = FindMarked();
if (selectedItem != NULL) { if (selectedItem != NULL) {
// scroll to the selected item // scroll to the selected item
if (Supermenu() == NULL) { if (Supermenu() == NULL) {
window->TryScrollTo(selectedItem->Frame().top); window->TryScrollTo(selectedItem->Frame().top);
} else { } else {
BPoint point = selectedItem->Frame().LeftTop(); BPoint point = selectedItem->Frame().LeftTop();
BPoint superPoint = Superitem()->Frame().LeftTop(); BPoint superPoint = Superitem()->Frame().LeftTop();
Supermenu()->ConvertToScreen(&superPoint); Supermenu()->ConvertToScreen(&superPoint);
ConvertToScreen(&point); ConvertToScreen(&point);
window->TryScrollTo(point.y - superPoint.y); window->TryScrollTo(point.y - superPoint.y);
}
} }
} }
} }