From 797d1a66fa05bd68a2bb475b4786af13038e9b16 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Tue, 10 Jan 2006 16:00:07 +0000 Subject: [PATCH] menufields should default to B_ITEMS_IN_COLUMN. This fixes the workspaces menu (in Screen) opened at the wrong position. As a consequence of this, I had to change the drawing code a bit git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15892 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/BMCPrivate.cpp | 10 +++++++--- src/kits/interface/MenuItem.cpp | 4 ++-- src/kits/interface/PopUpMenu.cpp | 13 ++++++------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/kits/interface/BMCPrivate.cpp b/src/kits/interface/BMCPrivate.cpp index 10ef677bcb..93d87e15ff 100644 --- a/src/kits/interface/BMCPrivate.cpp +++ b/src/kits/interface/BMCPrivate.cpp @@ -69,12 +69,16 @@ BArchivable *_BMCItem_::Instantiate(BMessage *data) //------------------------------------------------------------------------------ void _BMCItem_::Draw() { - BMenuItem::Draw(); + BMenu *menu = Menu(); + + // Copy / pasted from BMenuItem::Draw(). We can't use it directly + // because we want to skip the Submenu symbol and the rest + menu->MovePenTo(ContentLocation()); + DrawContent(); if (!fShowPopUpMarker) return; - BMenu *menu = Menu(); BRect rect(menu->Bounds()); rect.right -= 4; @@ -119,7 +123,7 @@ _BMCFilter_ &_BMCFilter_::operator=(const _BMCFilter_ &) }*/ //------------------------------------------------------------------------------ _BMCMenuBar_::_BMCMenuBar_(BRect frame, bool fixed_size, BMenuField *menuField) - : BMenuBar(frame, "_mc_mb_", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_ITEMS_IN_ROW, + : BMenuBar(frame, "_mc_mb_", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_ITEMS_IN_COLUMN, !fixed_size) { SetFlags(Flags() | B_FRAME_EVENTS); diff --git a/src/kits/interface/MenuItem.cpp b/src/kits/interface/MenuItem.cpp index ae7902f69f..617615f049 100644 --- a/src/kits/interface/MenuItem.cpp +++ b/src/kits/interface/MenuItem.cpp @@ -356,6 +356,8 @@ BMenuItem::TruncateLabel(float maxWidth, char *newLabel) void BMenuItem::DrawContent() { + fSuper->CacheFontInfo(); + fSuper->MovePenBy(0, fSuper->fAscent); BPoint lineStart = fSuper->PenLocation(); @@ -400,8 +402,6 @@ BMenuItem::Draw() // TODO: Cleanup bool enabled = IsEnabled(); - fSuper->CacheFontInfo(); - if (IsSelected() && (enabled || Submenu()) /*&& fSuper->fRedrawAfterSticky*/) { fSuper->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_2_TINT)); diff --git a/src/kits/interface/PopUpMenu.cpp b/src/kits/interface/PopUpMenu.cpp index c36b671e5e..2f641389ae 100644 --- a/src/kits/interface/PopUpMenu.cpp +++ b/src/kits/interface/PopUpMenu.cpp @@ -252,15 +252,14 @@ BPopUpMenu::ScreenLocation() if (fUseWhere) return fWhere; - BMenuItem *item = Superitem(); - BMenu *menu = Supermenu(); - BMenuItem *selectedItem = FindItem(item->Label()); - BRect rect = item->Frame(); - BPoint point = rect.LeftTop(); + BMenuItem *superItem = Superitem(); + BMenu *superMenu = Supermenu(); + BMenuItem *selectedItem = FindItem(superItem->Label()); + BPoint point = superItem->Frame().LeftTop(); - menu->ConvertToScreen(&point); + superMenu->ConvertToScreen(&point); - if (selectedItem) + if (selectedItem != NULL) point.y -= selectedItem->Frame().top; return point;