Reverted to r16487 due to various problems. I'll recommit the code once it's fully working.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16850 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+22
-37
@@ -14,7 +14,6 @@
|
||||
#include <File.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <Menu.h>
|
||||
#include <MenuBar.h>
|
||||
#include <MenuItem.h>
|
||||
#include <Path.h>
|
||||
#include <PropertyInfo.h>
|
||||
@@ -276,10 +275,8 @@ BMenu::AttachedToWindow()
|
||||
} while (AddDynamicItem(B_PROCESSING));
|
||||
}
|
||||
|
||||
if (!fAttachAborted) {
|
||||
LayoutItems(0);
|
||||
UpdateWindowViewSize();
|
||||
}
|
||||
if (!fAttachAborted)
|
||||
InvalidateLayout();
|
||||
}
|
||||
|
||||
|
||||
@@ -570,7 +567,6 @@ void
|
||||
BMenu::SetMaxContentWidth(float width)
|
||||
{
|
||||
fMaxContentWidth = width;
|
||||
InvalidateLayout();
|
||||
}
|
||||
|
||||
|
||||
@@ -735,13 +731,6 @@ BMenu::KeyDown(const char *bytes, int32 numBytes)
|
||||
void
|
||||
BMenu::Draw(BRect updateRect)
|
||||
{
|
||||
if (!fUseCachedMenuLayout) {
|
||||
LayoutItems(0);
|
||||
UpdateWindowViewSize(true);
|
||||
Sync();
|
||||
Invalidate();
|
||||
return;
|
||||
}
|
||||
DrawBackground(updateRect);
|
||||
DrawItems(updateRect);
|
||||
}
|
||||
@@ -778,10 +767,9 @@ BMenu::FrameResized(float new_width, float new_height)
|
||||
void
|
||||
BMenu::InvalidateLayout()
|
||||
{
|
||||
/*CacheFontInfo();
|
||||
CacheFontInfo();
|
||||
LayoutItems(0);
|
||||
Invalidate();*/
|
||||
fUseCachedMenuLayout = false;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
|
||||
@@ -1089,7 +1077,7 @@ BMenu::_show(bool selectFirstItem)
|
||||
if (fSuper != NULL)
|
||||
fSuperbounds = fSuper->ConvertToScreen(fSuper->Bounds());
|
||||
|
||||
//UpdateWindowViewSize();
|
||||
UpdateWindowViewSize();
|
||||
window->Show();
|
||||
|
||||
if (window->IsLocked())
|
||||
@@ -1222,7 +1210,12 @@ BMenu::_AddItem(BMenuItem *item, int32 index)
|
||||
|
||||
item->SetSuper(this);
|
||||
|
||||
InvalidateLayout();
|
||||
// Make sure we update the layout in case we are already attached.
|
||||
if (fResizeToFit && locked && Window() != NULL /*&& !Window()->IsHidden()*/) {
|
||||
LayoutItems(index);
|
||||
//UpdateWindowViewSize();
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
// Find the root menu window, so we can install this item.
|
||||
// ToDo: this shouldn't be necessary - the first supermenu is
|
||||
@@ -1290,7 +1283,7 @@ BMenu::RemoveItems(int32 index, int32 count, BMenuItem *item, bool del)
|
||||
}
|
||||
}
|
||||
|
||||
if (invalidateLayout)
|
||||
if (invalidateLayout && Window() != NULL && fResizeToFit)
|
||||
InvalidateLayout();
|
||||
|
||||
return success;
|
||||
@@ -1300,17 +1293,13 @@ BMenu::RemoveItems(int32 index, int32 count, BMenuItem *item, bool del)
|
||||
void
|
||||
BMenu::LayoutItems(int32 index)
|
||||
{
|
||||
if (!fUseCachedMenuLayout && CountItems() > 0) {
|
||||
fUseCachedMenuLayout = true;
|
||||
if (fLayout != B_ITEMS_IN_MATRIX) {
|
||||
CalcTriggers();
|
||||
|
||||
float width, height;
|
||||
ComputeLayout(index, fResizeToFit, true, &width, &height);
|
||||
if (fResizeToFit)
|
||||
ResizeTo(width, height);
|
||||
}
|
||||
}
|
||||
CalcTriggers();
|
||||
|
||||
float width, height;
|
||||
ComputeLayout(index, true, true, &width, &height);
|
||||
|
||||
ResizeTo(width, height);
|
||||
|
||||
// Move the BMenu to 1, 1, if it's attached to a BMenuWindow,
|
||||
// (that means it's a BMenu, BMenuBars are attached to regular BWindows).
|
||||
// This is needed to be able to draw the frame around the BMenu.
|
||||
@@ -1323,7 +1312,7 @@ void
|
||||
BMenu::ComputeLayout(int32 index, bool bestFit, bool moveItems,
|
||||
float* _width, float* _height)
|
||||
{
|
||||
// TODO: Take "bestFit", "index" into account,
|
||||
// TODO: Take "bestFit", "moveItems", "index" into account,
|
||||
// Recalculate only the needed items,
|
||||
// not the whole layout every time
|
||||
|
||||
@@ -1409,6 +1398,8 @@ BMenu::ComputeLayout(int32 index, bool bestFit, bool moveItems,
|
||||
break;
|
||||
}
|
||||
|
||||
// This is for BMenuBar
|
||||
|
||||
if (_width) {
|
||||
if ((ResizingMode() & B_FOLLOW_LEFT_RIGHT) == B_FOLLOW_LEFT_RIGHT) {
|
||||
if (Parent())
|
||||
@@ -1830,12 +1821,6 @@ BMenu::ChooseTrigger(const char *title, BList *chars)
|
||||
void
|
||||
BMenu::UpdateWindowViewSize(bool upWind)
|
||||
{
|
||||
// BMenuBar doesn't need to do anything.
|
||||
// TODO: another not_so_great hack: BMenu shouldn't know
|
||||
// about his inherited BMenuBar class.
|
||||
if (dynamic_cast<BMenuBar *>(this) != NULL)
|
||||
return;
|
||||
|
||||
BWindow *window = Window();
|
||||
bool scroll;
|
||||
BRect frame = CalcFrame(ScreenLocation(), &scroll);
|
||||
|
||||
Reference in New Issue
Block a user