From 9ece492008f17e7b05ae10cbc7922e67cddfb548 Mon Sep 17 00:00:00 2001 From: David Murphy Date: Tue, 17 Jul 2018 04:34:19 -0400 Subject: [PATCH] BMenu: BMenuBar submenus at screen edge moved onscreen instead of scrolling Fixes #9093 Change-Id: I1322c0cd8ba4bbfddace037ed8a8ef666ebe7fe3 --- src/kits/interface/Menu.cpp | 50 ++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index 84fbaba73a..8a36f77ce0 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -2437,14 +2437,8 @@ 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(superMenu) != NULL - && frame.top < (screenFrame.bottom - 80)) { - scroll = true; - } else { - frame.OffsetBy(0, -superItem->Frame().Height() - - frame.Height() - 3); - } + frame.OffsetBy(0, -superItem->Frame().Height() + - frame.Height() - 3); } if (frame.right > screenFrame.right) @@ -2928,33 +2922,31 @@ BMenu::_UpdateWindowViewSize(const bool &move) } else { BScreen screen(window); - // If we need scrolling, resize the window to fit the screen and - // attach scrollers to our cached BMenuWindow. + // Only scroll on menus not attached to a menubar, or when the + // menu frame is above the visible screen if (dynamic_cast(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()); 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 - window->AttachScrollers(); + if (fLayout == B_ITEMS_IN_COLUMN) { + window->AttachScrollers(); - BMenuItem* selectedItem = FindMarked(); - if (selectedItem != NULL) { - // scroll to the selected item - if (Supermenu() == NULL) { - window->TryScrollTo(selectedItem->Frame().top); - } else { - BPoint point = selectedItem->Frame().LeftTop(); - BPoint superPoint = Superitem()->Frame().LeftTop(); - Supermenu()->ConvertToScreen(&superPoint); - ConvertToScreen(&point); - window->TryScrollTo(point.y - superPoint.y); + BMenuItem* selectedItem = FindMarked(); + if (selectedItem != NULL) { + // scroll to the selected item + if (Supermenu() == NULL) { + window->TryScrollTo(selectedItem->Frame().top); + } else { + BPoint point = selectedItem->Frame().LeftTop(); + BPoint superPoint = Superitem()->Frame().LeftTop(); + Supermenu()->ConvertToScreen(&superPoint); + ConvertToScreen(&point); + window->TryScrollTo(point.y - superPoint.y); + } } } }