Fixed BMenuBar drawing. Managed to have BMenu working (partially) with BMenuBar.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10551 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+31
-25
@@ -41,8 +41,8 @@
|
|||||||
menu_info BMenu::sMenuInfo;
|
menu_info BMenu::sMenuInfo;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static property_info sPropList[] =
|
static property_info
|
||||||
{
|
sPropList[] = {
|
||||||
{ "Enabled", { B_GET_PROPERTY, 0 },
|
{ "Enabled", { B_GET_PROPERTY, 0 },
|
||||||
{ B_DIRECT_SPECIFIER, 0 }, "Returns true if menu or menu item is enabled; false "
|
{ B_DIRECT_SPECIFIER, 0 }, "Returns true if menu or menu item is enabled; false "
|
||||||
"otherwise." },
|
"otherwise." },
|
||||||
@@ -426,44 +426,44 @@ BMenu::IndexOf(BMenu *submenu) const
|
|||||||
BMenuItem *
|
BMenuItem *
|
||||||
BMenu::FindItem(const char *label) const
|
BMenu::FindItem(const char *label) const
|
||||||
{
|
{
|
||||||
BMenuItem *item;
|
BMenuItem *item = NULL;
|
||||||
|
|
||||||
for (int32 i = 0; i < CountItems(); i++) {
|
for (int32 i = 0; i < CountItems(); i++) {
|
||||||
item = ItemAt(i);
|
item = ItemAt(i);
|
||||||
|
|
||||||
if (item->Label() && strcmp(item->Label(), label) == 0)
|
if (item->Label() && strcmp(item->Label(), label) == 0)
|
||||||
return item;
|
break;
|
||||||
|
|
||||||
if (item->Submenu()) {
|
if (item->Submenu()) {
|
||||||
item = item->Submenu()->FindItem(label);
|
item = item->Submenu()->FindItem(label);
|
||||||
if (item)
|
if (item)
|
||||||
return item;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BMenuItem *
|
BMenuItem *
|
||||||
BMenu::FindItem(uint32 command) const
|
BMenu::FindItem(uint32 command) const
|
||||||
{
|
{
|
||||||
BMenuItem *item;
|
BMenuItem *item = NULL;
|
||||||
|
|
||||||
for (int32 i = 0; i < CountItems(); i++) {
|
for (int32 i = 0; i < CountItems(); i++) {
|
||||||
item = ItemAt(i);
|
item = ItemAt(i);
|
||||||
|
|
||||||
if (item->Command() == command)
|
if (item->Command() == command)
|
||||||
return item;
|
break;
|
||||||
|
|
||||||
if (item->Submenu()) {
|
if (item->Submenu()) {
|
||||||
item = item->Submenu()->FindItem(command);
|
item = item->Submenu()->FindItem(command);
|
||||||
if (item)
|
if (item)
|
||||||
return item;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -674,7 +674,6 @@ BMenu::KeyDown(const char *bytes, int32 numBytes)
|
|||||||
void
|
void
|
||||||
BMenu::Draw(BRect updateRect)
|
BMenu::Draw(BRect updateRect)
|
||||||
{
|
{
|
||||||
CALLED();
|
|
||||||
DrawBackground(updateRect);
|
DrawBackground(updateRect);
|
||||||
DrawItems(Bounds());
|
DrawItems(Bounds());
|
||||||
}
|
}
|
||||||
@@ -683,7 +682,6 @@ BMenu::Draw(BRect updateRect)
|
|||||||
void
|
void
|
||||||
BMenu::GetPreferredSize(float *width, float *height)
|
BMenu::GetPreferredSize(float *width, float *height)
|
||||||
{
|
{
|
||||||
CALLED();
|
|
||||||
ComputeLayout(0, true, false, width, height);
|
ComputeLayout(0, true, false, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -715,7 +713,6 @@ BMenu::FrameResized(float new_width, float new_height)
|
|||||||
void
|
void
|
||||||
BMenu::InvalidateLayout()
|
BMenu::InvalidateLayout()
|
||||||
{
|
{
|
||||||
CALLED();
|
|
||||||
CacheFontInfo();
|
CacheFontInfo();
|
||||||
LayoutItems(0);
|
LayoutItems(0);
|
||||||
}
|
}
|
||||||
@@ -861,17 +858,14 @@ BPoint
|
|||||||
BMenu::ScreenLocation()
|
BMenu::ScreenLocation()
|
||||||
{
|
{
|
||||||
BMenu *superMenu = Supermenu();
|
BMenu *superMenu = Supermenu();
|
||||||
|
|
||||||
if (superMenu == NULL)
|
|
||||||
return BPoint();
|
|
||||||
|
|
||||||
BMenuItem *superItem = Superitem();
|
BMenuItem *superItem = Superitem();
|
||||||
|
|
||||||
if (superItem == NULL)
|
if (superMenu == NULL && superItem == NULL) {
|
||||||
return BPoint();
|
debugger("BMenu can't determine where to draw."
|
||||||
|
"Override BMenu::ScreenLocation() to determine location.");
|
||||||
BPoint point;
|
}
|
||||||
|
|
||||||
|
BPoint point;
|
||||||
if (superMenu->Layout() == B_ITEMS_IN_COLUMN)
|
if (superMenu->Layout() == B_ITEMS_IN_COLUMN)
|
||||||
point = superItem->Frame().RightTop();
|
point = superItem->Frame().RightTop();
|
||||||
else
|
else
|
||||||
@@ -1073,6 +1067,11 @@ BMenu::_track(int *action, long start)
|
|||||||
do {
|
do {
|
||||||
if (LockLooper()) {
|
if (LockLooper()) {
|
||||||
GetMouse(&location, &buttons);
|
GetMouse(&location, &buttons);
|
||||||
|
if (OverSuper(location)) {
|
||||||
|
UnlockLooper();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
item = HitTestItems(location);
|
item = HitTestItems(location);
|
||||||
|
|
||||||
if (item && fSelected != item) {
|
if (item && fSelected != item) {
|
||||||
@@ -1091,6 +1090,13 @@ BMenu::_track(int *action, long start)
|
|||||||
snooze(50000);
|
snooze(50000);
|
||||||
} while (buttons != 0);
|
} while (buttons != 0);
|
||||||
|
|
||||||
|
if (action != NULL) {
|
||||||
|
if (item != NULL)
|
||||||
|
*action = 5;
|
||||||
|
else
|
||||||
|
*action = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1236,7 +1242,6 @@ BMenu::ScrollIntoView(BMenuItem *item)
|
|||||||
void
|
void
|
||||||
BMenu::DrawItems(BRect updateRect)
|
BMenu::DrawItems(BRect updateRect)
|
||||||
{
|
{
|
||||||
CALLED();
|
|
||||||
for (int i = 0; i < fItems.CountItems(); i++) {
|
for (int i = 0; i < fItems.CountItems(); i++) {
|
||||||
if (ItemAt(i)->Frame().Intersects(updateRect)) {
|
if (ItemAt(i)->Frame().Intersects(updateRect)) {
|
||||||
ItemAt(i)->Draw();
|
ItemAt(i)->Draw();
|
||||||
@@ -1271,11 +1276,13 @@ bool
|
|||||||
BMenu::OverSuper(BPoint loc)
|
BMenu::OverSuper(BPoint loc)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
// TODO: we assume that loc is in screen coords
|
|
||||||
|
ConvertToScreen(&loc);
|
||||||
|
|
||||||
if (!Supermenu())
|
if (!Supermenu())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return Supermenu()->Window()->Frame().Contains(loc);
|
return Supermenu()->Frame().Contains(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1311,7 +1318,6 @@ BMenu::DeleteMenuWindow()
|
|||||||
BMenuItem *
|
BMenuItem *
|
||||||
BMenu::HitTestItems(BPoint where, BPoint slop) const
|
BMenu::HitTestItems(BPoint where, BPoint slop) const
|
||||||
{
|
{
|
||||||
CALLED();
|
|
||||||
for (int i = 0; i < CountItems(); i++)
|
for (int i = 0; i < CountItems(); i++)
|
||||||
if (ItemAt(i)->fBounds.Contains(where))
|
if (ItemAt(i)->fBounds.Contains(where))
|
||||||
return ItemAt(i);
|
return ItemAt(i);
|
||||||
|
|||||||
@@ -145,6 +145,8 @@ BMenuBar::Draw(BRect updateRect)
|
|||||||
} else {
|
} else {
|
||||||
BRect bounds(Bounds());
|
BRect bounds(Bounds());
|
||||||
|
|
||||||
|
PushState();
|
||||||
|
|
||||||
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));
|
||||||
@@ -156,8 +158,10 @@ 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));
|
||||||
|
|
||||||
DrawItems(updateRect);
|
PopState();
|
||||||
|
|
||||||
|
DrawItems(updateRect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user