Many visual fixes to BMenu. Now it's almost undistinguable from the real thing. SeparatorItems were being drawn too dark. Fixed.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10585 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2005-01-04 14:42:19 +00:00
parent b282b9018e
commit 4ff5ade253
3 changed files with 17 additions and 14 deletions

View File

@ -1004,7 +1004,7 @@ BMenu::_show(bool selectFirstItem)
fCachedMenuWindow = new BMenuWindow(Name());
fCachedMenuWindow->ChildAt(0)->AddChild(this);
fCachedMenuWindow->ResizeTo(Bounds().Width() + 3, Bounds().Height() + 3);
fCachedMenuWindow->ResizeTo(Bounds().Width() + 4, Bounds().Height() + 4);
fCachedMenuWindow->MoveTo(ScreenLocation());
fCachedMenuWindow->Show();
@ -1181,11 +1181,11 @@ BMenu::ComputeLayout(int32 index, bool bestFit, bool moveItems,
if (item->fModifiers && item->fShortcutChar)
iWidth += 25.0f;
item->fBounds.left = 2.0f;
item->fBounds.left = 0.0f;
item->fBounds.top = frame.bottom;
item->fBounds.bottom = item->fBounds.top + iHeight + fPad.top + fPad.bottom;
frame.right = max_c(frame.right, iWidth + fPad.left + fPad.right);
frame.right = max_c(frame.right, iWidth + fPad.left + fPad.right) + 20;
frame.bottom = item->fBounds.bottom + 1.0f;
}
}
@ -1193,8 +1193,8 @@ BMenu::ComputeLayout(int32 index, bool bestFit, bool moveItems,
for (int32 i = 0; i < fItems.CountItems(); i++)
ItemAt(i)->fBounds.right = frame.right;
frame.right = (float)ceil(frame.right) + 2.0f;
frame.bottom += 1.0f;
frame.right = (float)ceil(frame.right);
frame.bottom--;
break;
}
@ -1244,11 +1244,12 @@ BMenu::ComputeLayout(int32 index, bool bestFit, bool moveItems,
break;
}
// This is for BMenuBar.
if ((ResizingMode() & B_FOLLOW_LEFT_RIGHT) == B_FOLLOW_LEFT_RIGHT) {
if (Parent())
*width = Parent()->Frame().Width();
*width = Parent()->Frame().Width() + 1;
else
*width = Window()->Frame().Width();
*width = Window()->Frame().Width() + 1;
*height = frame.Height();
} else {

View File

@ -26,8 +26,6 @@
//------------------------------------------------------------------------------
// TODO: Add scrollers
#include <stdio.h>
#include <Menu.h>
#include <MenuWindow.h>
@ -35,10 +33,11 @@
// this should go to some private header.
const window_feel kMenuWindowFeel = (window_feel)1025;
// This draws the frame around the BMenu
class BMenuFrame : public BView {
public:
BMenuFrame() :
BView(BRect(0, 0, 0, 0), "menu frame", B_FOLLOW_ALL_SIDES, B_WILL_DRAW)
BView(BRect(0, 0, 1, 1), "menu frame", B_FOLLOW_ALL_SIDES, B_WILL_DRAW)
{
};
@ -57,9 +56,12 @@ public:
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_2_TINT));
StrokeLine(BPoint(bounds.left + 2, bounds.bottom - 1),
BPoint(bounds.right - 1, bounds.bottom - 1));
StrokeLine(BPoint(bounds.right - 1, bounds.top + 1),
BPoint(bounds.right - 1, bounds.bottom - 1));
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_LIGHTEN_2_TINT));
StrokeLine(BPoint(bounds.left + 1, bounds.top + 1),
BPoint(bounds.right - 2, bounds.top + 1));
BPoint(bounds.right - 2, bounds.top + 1));
};
};

View File

@ -95,7 +95,7 @@ BSeparatorItem::Draw()
case 0:
// TODO: Check if drawing is pixel perfect
menu->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
B_DARKEN_2_TINT));
B_DARKEN_1_TINT));
menu->StrokeLine(BPoint(bounds.left + 1.0f, bounds.top + 4.0f),
BPoint(bounds.right - 1.0f, bounds.top + 4.0f));
menu->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
@ -108,7 +108,7 @@ BSeparatorItem::Draw()
case 1:
// TODO: Check if drawing is pixel perfect
menu->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
B_DARKEN_2_TINT));
B_DARKEN_1_TINT));
menu->StrokeLine(BPoint(bounds.left + 9.0f, bounds.top + 4.0f),
BPoint(bounds.right - 9.0f, bounds.top + 4.0f));
menu->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
@ -120,7 +120,7 @@ BSeparatorItem::Draw()
case 2:
menu->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
B_DARKEN_2_TINT));
B_DARKEN_1_TINT));
menu->StrokeLine(BPoint(bounds.left + 9.0f, bounds.top + 4.0f),
BPoint(bounds.right - 9.0f, bounds.top + 4.0f));
menu->StrokeLine(BPoint(bounds.left + 10.0f, bounds.top + 5.0f),