The MenuBar background is now drawn correctly when selected.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13319 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
843c11c953
commit
0c26ddbc29
|
@ -132,17 +132,19 @@ BMenuBar::Border() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BMenuBar::Draw(BRect updateRect)
|
BMenuBar::Draw(BRect updateRect)
|
||||||
{
|
{
|
||||||
// TODO: implement additional border styles
|
// TODO: implement additional border styles
|
||||||
if (IsEnabled()) {
|
if (IsEnabled()) {
|
||||||
PushState();
|
// ToDo: this is a work-around for broken PushState()/PopState()
|
||||||
|
// PushState();
|
||||||
|
rgb_color color = HighColor();
|
||||||
|
|
||||||
BRect bounds(Bounds());
|
BRect bounds(Bounds());
|
||||||
// Restore the background of the previously selected menuitem
|
// Restore the background of the previously selected menuitem
|
||||||
DrawBackground(bounds & updateRect);
|
DrawBackground(bounds & updateRect);
|
||||||
|
|
||||||
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_LIGHTEN_2_TINT));
|
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_LIGHTEN_2_TINT));
|
||||||
StrokeLine(BPoint(0.0f, bounds.bottom - 2.0f), BPoint(0.0f, 0.0f));
|
StrokeLine(BPoint(0.0f, bounds.bottom - 2.0f), BPoint(0.0f, 0.0f));
|
||||||
StrokeLine(BPoint(bounds.right, 0.0f));
|
StrokeLine(BPoint(bounds.right, 0.0f));
|
||||||
|
@ -154,20 +156,20 @@ BMenuBar::Draw(BRect updateRect)
|
||||||
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_2_TINT));
|
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_2_TINT));
|
||||||
StrokeLine(BPoint(0.0f, bounds.bottom), BPoint(bounds.right, bounds.bottom));
|
StrokeLine(BPoint(0.0f, bounds.bottom), BPoint(bounds.right, bounds.bottom));
|
||||||
StrokeLine(BPoint(bounds.right, 0.0f), BPoint(bounds.right, bounds.bottom));
|
StrokeLine(BPoint(bounds.right, 0.0f), BPoint(bounds.right, bounds.bottom));
|
||||||
|
|
||||||
PopState();
|
// PopState();
|
||||||
|
SetHighColor(color);
|
||||||
|
|
||||||
DrawItems(updateRect);
|
DrawItems(updateRect);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
LayoutItems(0);
|
LayoutItems(0);
|
||||||
Sync();
|
Sync();
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BMenuBar::AttachedToWindow()
|
BMenuBar::AttachedToWindow()
|
||||||
{
|
{
|
||||||
Install(Window());
|
Install(Window());
|
||||||
|
@ -397,16 +399,17 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
|
||||||
BMenuItem *resultItem = NULL;
|
BMenuItem *resultItem = NULL;
|
||||||
BWindow *window = Window();
|
BWindow *window = Window();
|
||||||
int localAction = MENU_ACT_NONE;
|
int localAction = MENU_ACT_NONE;
|
||||||
do {
|
|
||||||
|
while (true) {
|
||||||
bigtime_t snoozeAmount = 30000;
|
bigtime_t snoozeAmount = 30000;
|
||||||
if (window->LockWithTimeout(200000) < B_OK)
|
if (window->LockWithTimeout(200000) < B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
BPoint where;
|
BPoint where;
|
||||||
ulong buttons;
|
ulong buttons;
|
||||||
GetMouse(&where, &buttons);
|
GetMouse(&where, &buttons);
|
||||||
|
|
||||||
BMenuItem *menuItem = HitTestItems(where, B_ORIGIN);
|
BMenuItem *menuItem = HitTestItems(where, B_ORIGIN);
|
||||||
if (menuItem != NULL && menuItem != fSelected) {
|
if (menuItem != NULL && menuItem != fSelected) {
|
||||||
// only select the item
|
// only select the item
|
||||||
SelectItem(menuItem, -1);
|
SelectItem(menuItem, -1);
|
||||||
|
@ -416,7 +419,7 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
|
||||||
SelectItem(menuItem);
|
SelectItem(menuItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fSelected != NULL) {
|
if (fSelected != NULL) {
|
||||||
BMenu *menu = fSelected->Submenu();
|
BMenu *menu = fSelected->Submenu();
|
||||||
if (menu != NULL) {
|
if (menu != NULL) {
|
||||||
|
@ -429,17 +432,16 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window->Unlock();
|
window->Unlock();
|
||||||
|
|
||||||
if (localAction == MENU_ACT_CLOSE)
|
if (localAction == MENU_ACT_CLOSE)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (snoozeAmount > 0)
|
if (snoozeAmount > 0)
|
||||||
snooze(snoozeAmount);
|
snooze(snoozeAmount);
|
||||||
|
}
|
||||||
} while (true);
|
|
||||||
|
|
||||||
if (window->Lock()) {
|
if (window->Lock()) {
|
||||||
if (fSelected != NULL)
|
if (fSelected != NULL)
|
||||||
SelectItem(NULL);
|
SelectItem(NULL);
|
||||||
|
@ -447,10 +449,10 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
|
||||||
resultItem->Invoke();
|
resultItem->Invoke();
|
||||||
window->Unlock();
|
window->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action != NULL)
|
if (action != NULL)
|
||||||
*action = static_cast<int32>(localAction);
|
*action = static_cast<int32>(localAction);
|
||||||
|
|
||||||
return resultItem;
|
return resultItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue