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
+1
View File
@@ -194,6 +194,7 @@ virtual void _ReservedMenu6();
int32 count, int32 count,
BMenuItem *item, BMenuItem *item,
bool del = false); bool del = false);
bool RelayoutIfNeeded();
void LayoutItems(int32 index); void LayoutItems(int32 index);
void ComputeLayout(int32 index, bool bestFit, bool moveItems, void ComputeLayout(int32 index, bool bestFit, bool moveItems,
float* width, float* height); float* width, float* height);
+17 -5
View File
@@ -744,10 +744,7 @@ BMenu::KeyDown(const char *bytes, int32 numBytes)
void void
BMenu::Draw(BRect updateRect) BMenu::Draw(BRect updateRect)
{ {
if (!fUseCachedMenuLayout) { if (RelayoutIfNeeded()) {
fUseCachedMenuLayout = true;
CacheFontInfo();
LayoutItems(0);
Invalidate(); Invalidate();
return; 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 void
BMenu::LayoutItems(int32 index) BMenu::LayoutItems(int32 index)
{ {
@@ -1725,10 +1735,12 @@ BMenu::ItemMarked(BMenuItem *item)
{ {
if (IsRadioMode()) { if (IsRadioMode()) {
for (int32 i = 0; i < CountItems(); i++) for (int32 i = 0; i < CountItems(); i++)
if (ItemAt(i) != item) if (ItemAt(i) != item)
ItemAt(i)->SetMarked(false); ItemAt(i)->SetMarked(false);
InvalidateLayout();
} }
if (IsLabelFromMarked() && Superitem()) if (IsLabelFromMarked() && Superitem())
Superitem()->SetLabel(item->Label()); Superitem()->SetLabel(item->Label());
} }
+5
View File
@@ -119,6 +119,11 @@ BMenuBar::Border() const
void void
BMenuBar::Draw(BRect updateRect) BMenuBar::Draw(BRect updateRect)
{ {
if (RelayoutIfNeeded()) {
Invalidate();
return;
}
// TODO: implement additional border styles // TODO: implement additional border styles
rgb_color color = HighColor(); rgb_color color = HighColor();