From b0d01b5f78336ce86555eed4d4824de02f5db163 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Thu, 30 Dec 2004 13:27:00 +0000 Subject: [PATCH] MenuWindow now uses the private window_feel "1025", which I guess we'll need to implement server side too, since it behaves differently than B_MODAL_WINDOW_FEEL. Menu items added to a menubar didn't appear immediately, so I forced an Invalidate(). Could be made better, I think. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10552 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Menu.cpp | 20 +++++++++++++------- src/kits/interface/MenuWindow.cpp | 5 ++++- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index a3a7733ff2..21e484d759 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -173,7 +173,8 @@ BMenu::BMenu(BMessage *archive) } -BArchivable *BMenu::Instantiate(BMessage *data) +BArchivable * +BMenu::Instantiate(BMessage *data) { if (validate_instantiation(data, "BMenu")) return new BMenu(data); @@ -872,7 +873,7 @@ BMenu::ScreenLocation() point = superItem->Frame().LeftBottom() + BPoint(0.0f, 1.0f); superMenu->ConvertToScreen(&point); - + return point; } @@ -1121,10 +1122,11 @@ BMenu::LayoutItems(int32 index) CalcTriggers(); float width, height; - ComputeLayout(index, true, true, &width, &height); ResizeTo(width, height); + + Invalidate(); } @@ -1318,9 +1320,13 @@ BMenu::DeleteMenuWindow() BMenuItem * BMenu::HitTestItems(BPoint where, BPoint slop) const { - for (int i = 0; i < CountItems(); i++) - if (ItemAt(i)->fBounds.Contains(where)) - return ItemAt(i); + // TODO: Take "slop" into account ? + int32 itemCount = CountItems(); + for (int32 i = 0; i < itemCount; i++) { + BMenuItem *item = ItemAt(i); + if (item->fBounds.Contains(where)) + return item; + } return NULL; } @@ -1345,7 +1351,7 @@ BMenu::CacheFontInfo() GetFontHeight(&fh); fAscent = fh.ascent; fDescent = fh.descent; - fFontHeight = (float)ceil(fh.ascent + fh.descent + 0.5f); + fFontHeight = (float)ceil(fh.ascent + fh.descent + fh.leading); } diff --git a/src/kits/interface/MenuWindow.cpp b/src/kits/interface/MenuWindow.cpp index 82e9c28391..28bbb1c7ee 100644 --- a/src/kits/interface/MenuWindow.cpp +++ b/src/kits/interface/MenuWindow.cpp @@ -30,10 +30,13 @@ #include +// TODO: taken from Deskbar's WindowMenu.cpp. +// this should go to some private header. +const window_feel kMenuWindowFeel = (window_feel)1025; BMenuWindow::BMenuWindow(BRect frame, BMenu *menu) : - BWindow(frame, "Menu", B_NO_BORDER_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, + BWindow(frame, "Menu", B_NO_BORDER_WINDOW_LOOK, kMenuWindowFeel, B_NOT_ZOOMABLE) { fMenu = menu;