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
This commit is contained in:
@@ -332,7 +332,7 @@ BMenu::AttachedToWindow()
|
|||||||
if (!fAttachAborted) {
|
if (!fAttachAborted) {
|
||||||
CacheFontInfo();
|
CacheFontInfo();
|
||||||
LayoutItems(0);
|
LayoutItems(0);
|
||||||
//UpdateWindowViewSize();
|
UpdateWindowViewSize(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,6 +365,7 @@ BMenu::AddItem(BMenuItem *item, int32 index)
|
|||||||
if (LockLooper()) {
|
if (LockLooper()) {
|
||||||
if (!Window()->IsHidden()) {
|
if (!Window()->IsHidden()) {
|
||||||
LayoutItems(index);
|
LayoutItems(index);
|
||||||
|
UpdateWindowViewSize(false);
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
UnlockLooper();
|
UnlockLooper();
|
||||||
@@ -483,7 +484,7 @@ BMenu::AddList(BList *list, int32 index)
|
|||||||
if (locked && Window() != NULL && !Window()->IsHidden()) {
|
if (locked && Window() != NULL && !Window()->IsHidden()) {
|
||||||
// Make sure we update the layout if needed.
|
// Make sure we update the layout if needed.
|
||||||
LayoutItems(index);
|
LayoutItems(index);
|
||||||
//UpdateWindowViewSize();
|
UpdateWindowViewSize(false);
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1202,7 +1203,7 @@ BMenu::_show(bool selectFirstItem)
|
|||||||
if (dynamic_cast<BMenuWindow *>(window) != NULL)
|
if (dynamic_cast<BMenuWindow *>(window) != NULL)
|
||||||
MoveTo(1, 1);
|
MoveTo(1, 1);
|
||||||
|
|
||||||
UpdateWindowViewSize();
|
UpdateWindowViewSize(true);
|
||||||
window->Show();
|
window->Show();
|
||||||
|
|
||||||
if (selectFirstItem)
|
if (selectFirstItem)
|
||||||
@@ -1485,7 +1486,7 @@ BMenu::RemoveItems(int32 index, int32 count, BMenuItem *item, bool deleteItems)
|
|||||||
|
|
||||||
if (invalidateLayout && locked && window != NULL) {
|
if (invalidateLayout && locked && window != NULL) {
|
||||||
LayoutItems(0);
|
LayoutItems(0);
|
||||||
//UpdateWindowViewSize();
|
UpdateWindowViewSize(false);
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1655,6 +1656,7 @@ BMenu::ItemLocInRect(BRect frame) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Assumes the SuperMenu to be locked (due to calling ConvertToScreen())
|
||||||
BPoint
|
BPoint
|
||||||
BMenu::ScreenLocation()
|
BMenu::ScreenLocation()
|
||||||
{
|
{
|
||||||
@@ -2110,8 +2112,12 @@ BMenu::UpdateWindowViewSize(bool upWind)
|
|||||||
if (window == NULL)
|
if (window == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (dynamic_cast<BMenuBar *>(this) != NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
bool scroll;
|
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());
|
ResizeTo(frame.Width(), frame.Height());
|
||||||
|
|
||||||
if (fItems.CountItems() > 0) {
|
if (fItems.CountItems() > 0) {
|
||||||
@@ -2139,7 +2145,8 @@ BMenu::UpdateWindowViewSize(bool upWind)
|
|||||||
fFontHeight + fPad.top + fPad.bottom);
|
fFontHeight + fPad.top + fPad.bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
window->MoveTo(frame.LeftTop());
|
if (upWind)
|
||||||
|
window->MoveTo(frame.LeftTop());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user