diff --git a/headers/os/interface/Menu.h b/headers/os/interface/Menu.h index 419fa406fd..99af9b3bf7 100644 --- a/headers/os/interface/Menu.h +++ b/headers/os/interface/Menu.h @@ -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); diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index d771e5d4fe..6ae8c101f2 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -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()); } diff --git a/src/kits/interface/MenuBar.cpp b/src/kits/interface/MenuBar.cpp index 25b515ed35..842e49d112 100644 --- a/src/kits/interface/MenuBar.cpp +++ b/src/kits/interface/MenuBar.cpp @@ -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();