Added a new method RelayoutIfNeeded(), which does the real Layout invalidation, it's called by menubar and menu. This fixes the menufields not being resized. Note that a problem still remains, will be fixed shortly (hopefully)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17405 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2006-05-09 21:48:51 +00:00
parent 17187587df
commit 925479d7b3
3 changed files with 23 additions and 5 deletions

View File

@ -194,6 +194,7 @@ virtual void _ReservedMenu6();
int32 count,
BMenuItem *item,
bool del = false);
bool RelayoutIfNeeded();
void LayoutItems(int32 index);
void ComputeLayout(int32 index, bool bestFit, bool moveItems,
float* width, float* height);

View File

@ -744,10 +744,7 @@ BMenu::KeyDown(const char *bytes, int32 numBytes)
void
BMenu::Draw(BRect updateRect)
{
if (!fUseCachedMenuLayout) {
fUseCachedMenuLayout = true;
CacheFontInfo();
LayoutItems(0);
if (RelayoutIfNeeded()) {
Invalidate();
return;
}
@ -1374,6 +1371,19 @@ BMenu::RemoveItems(int32 index, int32 count, BMenuItem *item, bool deleteItems)
}
bool
BMenu::RelayoutIfNeeded()
{
if (!fUseCachedMenuLayout) {
fUseCachedMenuLayout = true;
CacheFontInfo();
LayoutItems(0);
return true;
}
return false;
}
void
BMenu::LayoutItems(int32 index)
{
@ -1725,10 +1735,12 @@ BMenu::ItemMarked(BMenuItem *item)
{
if (IsRadioMode()) {
for (int32 i = 0; i < CountItems(); i++)
if (ItemAt(i) != item)
if (ItemAt(i) != item)
ItemAt(i)->SetMarked(false);
InvalidateLayout();
}
if (IsLabelFromMarked() && Superitem())
Superitem()->SetLabel(item->Label());
}

View File

@ -119,6 +119,11 @@ BMenuBar::Border() const
void
BMenuBar::Draw(BRect updateRect)
{
if (RelayoutIfNeeded()) {
Invalidate();
return;
}
// TODO: implement additional border styles
rgb_color color = HighColor();