SetEnabled() enables or disables the parent menu too, SetRadioMode() and SetLabelFromMarked() call each other if needed, BMenuBar::Draw() doesn't make a difference if the menubar is disabled or not, should even fix bug #87 as it was calling LayoutItems() every cycle. Work done by John Drinkwater and me
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15988 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -530,6 +530,14 @@ BMenu::SetEnabled(bool enabled)
|
|||||||
{
|
{
|
||||||
fEnabled = enabled;
|
fEnabled = enabled;
|
||||||
|
|
||||||
|
|
||||||
|
if (fSuper) {
|
||||||
|
// Can't use fSuper->SetEnabled() here, as
|
||||||
|
// it would call SetEnabled() on us again, thus
|
||||||
|
// entering an infinite loop
|
||||||
|
fSuper->fEnabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
for (int32 i = 0; i < CountItems(); i++)
|
for (int32 i = 0; i < CountItems(); i++)
|
||||||
ItemAt(i)->SetEnabled(enabled);
|
ItemAt(i)->SetEnabled(enabled);
|
||||||
}
|
}
|
||||||
@@ -539,6 +547,8 @@ void
|
|||||||
BMenu::SetRadioMode(bool flag)
|
BMenu::SetRadioMode(bool flag)
|
||||||
{
|
{
|
||||||
fRadioMode = flag;
|
fRadioMode = flag;
|
||||||
|
if (!flag)
|
||||||
|
SetLabelFromMarked(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -560,6 +570,8 @@ void
|
|||||||
BMenu::SetLabelFromMarked(bool flag)
|
BMenu::SetLabelFromMarked(bool flag)
|
||||||
{
|
{
|
||||||
fDynamicName = flag;
|
fDynamicName = flag;
|
||||||
|
if (flag)
|
||||||
|
SetRadioMode(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -935,7 +947,7 @@ BMenu::Hide()
|
|||||||
BMenuItem *
|
BMenuItem *
|
||||||
BMenu::Track(bool openAnyway, BRect *clickToOpenRect)
|
BMenu::Track(bool openAnyway, BRect *clickToOpenRect)
|
||||||
{
|
{
|
||||||
if (IsStickyPrefOn())
|
if (!IsStickyPrefOn())
|
||||||
openAnyway = false;
|
openAnyway = false;
|
||||||
|
|
||||||
SetStickyMode(openAnyway);
|
SetStickyMode(openAnyway);
|
||||||
|
|||||||
@@ -136,34 +136,28 @@ void
|
|||||||
BMenuBar::Draw(BRect updateRect)
|
BMenuBar::Draw(BRect updateRect)
|
||||||
{
|
{
|
||||||
// TODO: implement additional border styles
|
// TODO: implement additional border styles
|
||||||
if (IsEnabled()) {
|
rgb_color color = HighColor();
|
||||||
rgb_color color = HighColor();
|
|
||||||
|
BRect bounds(Bounds());
|
||||||
|
// Restore the background of the previously selected menuitem
|
||||||
|
DrawBackground(bounds & updateRect);
|
||||||
|
|
||||||
BRect bounds(Bounds());
|
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_LIGHTEN_2_TINT));
|
||||||
// Restore the background of the previously selected menuitem
|
StrokeLine(BPoint(0.0f, bounds.bottom - 2.0f), BPoint(0.0f, 0.0f));
|
||||||
DrawBackground(bounds & updateRect);
|
StrokeLine(BPoint(bounds.right, 0.0f));
|
||||||
|
|
||||||
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_LIGHTEN_2_TINT));
|
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_1_TINT));
|
||||||
StrokeLine(BPoint(0.0f, bounds.bottom - 2.0f), BPoint(0.0f, 0.0f));
|
StrokeLine(BPoint(1.0f, bounds.bottom - 1.0f),
|
||||||
StrokeLine(BPoint(bounds.right, 0.0f));
|
BPoint(bounds.right, bounds.bottom - 1.0f));
|
||||||
|
|
||||||
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_1_TINT));
|
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_2_TINT));
|
||||||
StrokeLine(BPoint(1.0f, bounds.bottom - 1.0f),
|
StrokeLine(BPoint(0.0f, bounds.bottom), BPoint(bounds.right, bounds.bottom));
|
||||||
BPoint(bounds.right, bounds.bottom - 1.0f));
|
StrokeLine(BPoint(bounds.right, 0.0f), BPoint(bounds.right, bounds.bottom));
|
||||||
|
|
||||||
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_2_TINT));
|
SetHighColor(color);
|
||||||
StrokeLine(BPoint(0.0f, bounds.bottom), BPoint(bounds.right, bounds.bottom));
|
// revert to previous used color (cheap PushState()/PopState())
|
||||||
StrokeLine(BPoint(bounds.right, 0.0f), BPoint(bounds.right, bounds.bottom));
|
|
||||||
|
|
||||||
SetHighColor(color);
|
DrawItems(updateRect);
|
||||||
// revert to previous used color (cheap PushState()/PopState())
|
|
||||||
|
|
||||||
DrawItems(updateRect);
|
|
||||||
} else {
|
|
||||||
LayoutItems(0);
|
|
||||||
Sync();
|
|
||||||
Invalidate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user