From 2a5bad15418179e562d81f9750336f35a1a5a514 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Thu, 9 Feb 2006 20:58:15 +0000 Subject: [PATCH] Avoid menus in menufields going out of the screen in the upper part git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16316 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Menu.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index 38278b204a..2790209c84 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -1463,6 +1463,12 @@ BMenu::CalcFrame(BPoint where, bool *scrollOn) BMenu *superMenu = Supermenu(); BMenuItem *superItem = Superitem(); + if (scrollOn != NULL) { + // basically, if this returns false, it means + // that the menu frame won't fit completely inside the screen + *scrollOn = !screenFrame.Contains(bounds); + } + // TODO: Horrible hack: // When added to a BMenuField, a BPopUpMenu is the child of // a _BMCItem_ inside a _BMCMenuBar_ to "fake" the menu hierarchy @@ -1472,9 +1478,13 @@ BMenu::CalcFrame(BPoint where, bool *scrollOn) if (frame.bottom > screenFrame.bottom) frame.OffsetBy(0, screenFrame.bottom - frame.bottom); - + else if (frame.top < screenFrame.top) + frame.OffsetBy(0, -frame.top); + if (frame.right > screenFrame.right) frame.OffsetBy(screenFrame.right - frame.right, 0); + else if (frame.left < screenFrame.left) + frame.OffsetBy(-frame.left, 0); return frame; }