From c8773f97a0894317f219e347abda1379d8b54b86 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Wed, 10 May 2006 19:29:35 +0000 Subject: [PATCH] Invalidate less in BMenuBar::FrameResized() and a bit more in _BMCMenuBar_::FrameResized(), removed unused _BMCItem_ git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17417 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/interface/BMCPrivate.h | 33 +--------- src/kits/interface/BMCPrivate.cpp | 85 +++++--------------------- src/kits/interface/MenuBar.cpp | 8 ++- 3 files changed, 23 insertions(+), 103 deletions(-) diff --git a/headers/private/interface/BMCPrivate.h b/headers/private/interface/BMCPrivate.h index df60e7a3c7..035cfafed1 100644 --- a/headers/private/interface/BMCPrivate.h +++ b/headers/private/interface/BMCPrivate.h @@ -34,33 +34,6 @@ #include #include -// Project Includes ------------------------------------------------------------ - -// Local Includes -------------------------------------------------------------- - -// Local Defines --------------------------------------------------------------- - -// Globals --------------------------------------------------------------------- - -//------------------------------------------------------------------------------ -class _BMCItem_ : public BMenuItem { - -public: - _BMCItem_(BMenu *menu); - _BMCItem_(BMessage *message); -virtual ~_BMCItem_(); - -static BArchivable *Instantiate(BMessage *data); - - void Draw(); - void GetContentSize(float *width, float *height); - -private: -friend class BMenuField; - - bool fShowPopUpMarker; -}; -//------------------------------------------------------------------------------ /*//------------------------------------------------------------------------------ _BMCFilter_::_BMCFilter_(BMenuField *menuField, uint32) @@ -101,9 +74,9 @@ virtual void MouseDown(BPoint where); private: _BMCMenuBar_&operator=(const _BMCMenuBar_ &); - - BMenuField *fMenuField; - bool fFixedSize; + + BMenuField *fMenuField; + bool fFixedSize; BMessageRunner *fRunner; }; //------------------------------------------------------------------------------ diff --git a/src/kits/interface/BMCPrivate.cpp b/src/kits/interface/BMCPrivate.cpp index 35346d3e5d..34d1de96f4 100644 --- a/src/kits/interface/BMCPrivate.cpp +++ b/src/kits/interface/BMCPrivate.cpp @@ -16,75 +16,6 @@ #include #include -_BMCItem_::_BMCItem_(BMenu *menu) - : BMenuItem(menu), - fShowPopUpMarker(true) -{ - printf("_BMCItem_::_BMCItem_()\n"); -} - - -_BMCItem_::_BMCItem_(BMessage *message) - : BMenuItem(message), - fShowPopUpMarker(true) -{ -} - - -_BMCItem_::~_BMCItem_() -{ -} - - -BArchivable * -_BMCItem_::Instantiate(BMessage *data) -{ - if (validate_instantiation(data, "_BMCItem_")) - return new _BMCItem_(data); - else - return NULL; -} - - -void -_BMCItem_::Draw() -{ - BMenu *menu = Menu(); - - BMenuItem::Draw(); - - if (!fShowPopUpMarker) - return; -return; - BRect rect(menu->Bounds()); - - rect.right -= 4; - rect.bottom -= 5; - rect.left = rect.right - 4; - rect.top = rect.bottom - 2; - - if (IsEnabled()) - menu->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), - B_DARKEN_4_TINT)); - else - menu->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), - B_DARKEN_4_TINT)); - - menu->StrokeLine(BPoint(rect.left, rect.top), BPoint(rect.right, rect.top)); - menu->StrokeLine(BPoint(rect.left + 1.0f, rect.top + 1.0f), - BPoint(rect.right - 1.0f, rect.top + 1.0f)); - menu->StrokeLine(BPoint(rect.left + 2.0f, rect.bottom), - BPoint(rect.left + 2.0f, rect.bottom)); -} - - -void -_BMCItem_::GetContentSize(float *width, float *height) -{ - BMenuItem::GetContentSize(width, height); -} - - /* _BMCFilter_::_BMCFilter_(BMenuField *menuField, uint32) { @@ -278,12 +209,18 @@ _BMCMenuBar_::FrameResized(float width, float height) float diff = Frame().right - fMenuField->Bounds().right; if (Window()) { if (diff > 0) { - // clean up the dirty right top corner of + // clean up the dirty right border of // the menu field when enlarging BRect dirty(fMenuField->Bounds()); dirty.left = dirty.right - 2; - dirty.bottom = Frame().top - 1; fMenuField->Invalidate(dirty); + + // clean up the arrow part + dirty = Bounds(); + dirty.right -= diff; + dirty.left = dirty.right - 12; + Invalidate(dirty); + } else if (diff < 0) { // clean up the dirty right line of // the menu field when shrinking @@ -291,8 +228,14 @@ _BMCMenuBar_::FrameResized(float width, float height) dirty.left = dirty.right + diff + 1; dirty.right = dirty.left + 1; fMenuField->Invalidate(dirty); + + // clean up the arrow part + dirty = Bounds(); + dirty.left = dirty.right - 12; + Invalidate(dirty); } } + // we have been shrinked or enlarged and need to take // of the size of the parent menu field as well // NOTE: no worries about follow mode, we follow left and top diff --git a/src/kits/interface/MenuBar.cpp b/src/kits/interface/MenuBar.cpp index 568114d1bc..f3ea0f8bd6 100644 --- a/src/kits/interface/MenuBar.cpp +++ b/src/kits/interface/MenuBar.cpp @@ -214,9 +214,13 @@ BMenuBar::FrameMoved(BPoint newPosition) void BMenuBar::FrameResized(float newWidth, float newHeight) { + BRect bounds(Bounds()); + BRect rect(fLastBounds->right - 2, fLastBounds->top, bounds.right, bounds.bottom); fLastBounds->Set(0, 0, newWidth, newHeight); - if (Window()) - Invalidate(Bounds()); + + if (rect.IsValid() && Window() != NULL) + Invalidate(rect); + BMenu::FrameResized(newWidth, newHeight); }