From 63cd2925a05555013e0c40224246b5a82d3e91f6 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Thu, 22 Mar 2007 14:48:03 +0000 Subject: [PATCH] Update the window size when adding and removing items. This fix bug #683, but makes bug #582 look even more funny. Oh, well I hope I'll fix it one day. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20403 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Menu.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index c60b5c74c3..67bf1bb903 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -332,7 +332,7 @@ BMenu::AttachedToWindow() if (!fAttachAborted) { CacheFontInfo(); LayoutItems(0); - //UpdateWindowViewSize(); + UpdateWindowViewSize(false); } } @@ -365,6 +365,7 @@ BMenu::AddItem(BMenuItem *item, int32 index) if (LockLooper()) { if (!Window()->IsHidden()) { LayoutItems(index); + UpdateWindowViewSize(false); Invalidate(); } UnlockLooper(); @@ -483,7 +484,7 @@ BMenu::AddList(BList *list, int32 index) if (locked && Window() != NULL && !Window()->IsHidden()) { // Make sure we update the layout if needed. LayoutItems(index); - //UpdateWindowViewSize(); + UpdateWindowViewSize(false); Invalidate(); } @@ -1202,7 +1203,7 @@ BMenu::_show(bool selectFirstItem) if (dynamic_cast(window) != NULL) MoveTo(1, 1); - UpdateWindowViewSize(); + UpdateWindowViewSize(true); window->Show(); if (selectFirstItem) @@ -1485,7 +1486,7 @@ BMenu::RemoveItems(int32 index, int32 count, BMenuItem *item, bool deleteItems) if (invalidateLayout && locked && window != NULL) { LayoutItems(0); - //UpdateWindowViewSize(); + UpdateWindowViewSize(false); Invalidate(); } @@ -1655,6 +1656,7 @@ BMenu::ItemLocInRect(BRect frame) const } +// Assumes the SuperMenu to be locked (due to calling ConvertToScreen()) BPoint BMenu::ScreenLocation() { @@ -2110,8 +2112,12 @@ BMenu::UpdateWindowViewSize(bool upWind) if (window == NULL) return; + if (dynamic_cast(this) != NULL) + return; + bool scroll; - BRect frame = CalcFrame(ScreenLocation(), &scroll); + const BPoint screenLocation = upWind ? ScreenLocation() : window->Frame().LeftTop(); + BRect frame = CalcFrame(screenLocation, &scroll); ResizeTo(frame.Width(), frame.Height()); if (fItems.CountItems() > 0) { @@ -2139,7 +2145,8 @@ BMenu::UpdateWindowViewSize(bool upWind) fFontHeight + fPad.top + fPad.bottom); } - window->MoveTo(frame.LeftTop()); + if (upWind) + window->MoveTo(frame.LeftTop()); }