* _BMCItem_ is no longer used, but I didn't remove it

yet, just commented it out in BMenuField. As was expected,
  nothing changed in any obvious way
* made the _BMCMenuBar_ draw the popup marked. I changed it
  a bit, inspired from some mockup I saw, sorry I don't
  remember where. I hope you like it (it is easily changed
  back if you don't).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16444 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2006-02-16 22:57:19 +00:00
parent ccf81dc9d2
commit f282009d15
2 changed files with 115 additions and 61 deletions
+93 -41
View File
@@ -1,28 +1,13 @@
//------------------------------------------------------------------------------ /*
// Copyright (c) 2001-2002, OpenBeOS * Copyright 2001-2006, Haiku Inc.
// * Distributed under the terms of the MIT License.
// Permission is hereby granted, free of charge, to any person obtaining a *
// copy of this software and associated documentation files (the "Software"), * Authors:
// to deal in the Software without restriction, including without limitation * Marc Flerackers ([email protected])
// the rights to use, copy, modify, merge, publish, distribute, sublicense, * Stephan Aßmus <[email protected]>
// and/or sell copies of the Software, and to permit persons to whom the */
// Software is furnished to do so, subject to the following conditions:
// #include <stdio.h>
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: BMCPrivate.cpp
// Author: Marc Flerackers ([email protected])
// Description: The BMCPrivate classes are used by BMenuField.
//------------------------------------------------------------------------------
#include <BMCPrivate.h> #include <BMCPrivate.h>
#include <MenuField.h> #include <MenuField.h>
@@ -31,11 +16,11 @@
#include <Region.h> #include <Region.h>
#include <Window.h> #include <Window.h>
_BMCItem_::_BMCItem_(BMenu *menu) _BMCItem_::_BMCItem_(BMenu *menu)
: BMenuItem(menu), : BMenuItem(menu),
fShowPopUpMarker(true) fShowPopUpMarker(true)
{ {
printf("_BMCItem_::_BMCItem_()\n");
} }
@@ -70,7 +55,7 @@ _BMCItem_::Draw()
if (!fShowPopUpMarker) if (!fShowPopUpMarker)
return; return;
return;
BRect rect(menu->Bounds()); BRect rect(menu->Bounds());
rect.right -= 4; rect.right -= 4;
@@ -187,31 +172,98 @@ _BMCMenuBar_::AttachedToWindow()
void void
_BMCMenuBar_::Draw(BRect updateRect) _BMCMenuBar_::Draw(BRect updateRect)
{ {
// draw the right and bottom line here in a darker tint // draw the right side with the popup marker
BRect bounds(Bounds());
bounds.right -= 2.0;
bounds.bottom -= 1.0;
// prevent the original BMenuBar's Draw from // prevent the original BMenuBar's Draw from
// drawing in those parts // drawing in those parts
BRect bounds(Bounds());
bounds.right -= 10.0;
bounds.bottom -= 1.0;
BRegion clipping(bounds); BRegion clipping(bounds);
ConstrainClippingRegion(&clipping); ConstrainClippingRegion(&clipping);
BMenuBar::Draw(updateRect); BMenuBar::Draw(updateRect);
// restore clipping
ConstrainClippingRegion(NULL); ConstrainClippingRegion(NULL);
bounds.right += 10.0;
bounds.right += 2.0;
bounds.bottom += 1.0; bounds.bottom += 1.0;
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_4_TINT)); // prepare some colors
StrokeLine(BPoint(bounds.left, bounds.bottom), rgb_color normalNoTint = ui_color(B_MENU_BACKGROUND_COLOR);
BPoint(bounds.right, bounds.bottom)); rgb_color noTint = tint_color(normalNoTint, 0.74);
StrokeLine(BPoint(bounds.right, bounds.bottom - 1), rgb_color darken4;
BPoint(bounds.right, bounds.top)); rgb_color normalDarken4;
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_1_TINT)); rgb_color darken1;
StrokeLine(BPoint(bounds.right - 1, bounds.bottom - 1), rgb_color lighten1;
BPoint(bounds.right - 1, bounds.top + 1)); rgb_color lighten2;
if (IsEnabled()) {
darken4 = tint_color(noTint, B_DARKEN_4_TINT);
normalDarken4 = tint_color(normalNoTint, B_DARKEN_4_TINT);
darken1 = tint_color(noTint, B_DARKEN_1_TINT);
lighten1 = tint_color(noTint, B_LIGHTEN_1_TINT);
lighten2 = tint_color(noTint, B_LIGHTEN_2_TINT);
} else {
darken4 = tint_color(noTint, B_DARKEN_2_TINT);
normalDarken4 = tint_color(normalNoTint, B_DARKEN_2_TINT);
darken1 = tint_color(noTint, (B_NO_TINT + B_DARKEN_1_TINT) / 2.0);
lighten1 = tint_color(noTint, (B_NO_TINT + B_LIGHTEN_1_TINT) / 2.0);
lighten2 = tint_color(noTint, B_LIGHTEN_1_TINT);
}
BRect r(bounds);
r.left = r.right - 10.0;
BeginLineArray(6);
// bottom below item text, darker then BMenuBar
// would normaly draw it
AddLine(BPoint(bounds.left, r.bottom),
BPoint(r.left - 1.0, r.bottom), normalDarken4);
// bottom below popup marker
AddLine(BPoint(r.left, r.bottom),
BPoint(r.right, r.bottom), darken4);
// right of popup marker
AddLine(BPoint(r.right, r.bottom - 1),
BPoint(r.right, r.top), darken4);
// top above popup marker
AddLine(BPoint(r.left, r.top),
BPoint(r.right - 2, r.top), lighten2);
r.top += 1;
r.bottom -= 1;
r.right -= 1;
// bottom below popup marker
AddLine(BPoint(r.left, r.bottom),
BPoint(r.right, r.bottom), darken1);
// right of popup marker
AddLine(BPoint(r.right, r.bottom - 1),
BPoint(r.right, r.top), darken1);
EndLineArray();
r.bottom -= 1;
r.right -= 1;
SetHighColor(noTint);
FillRect(r);
// popup marker
BPoint center(roundf((r.left + r.right) / 2.0),
roundf((r.top + r.bottom) / 2.0));
BPoint triangle[3];
triangle[0] = center + BPoint(-2.5, -0.5);
triangle[1] = center + BPoint(2.5, -0.5);
triangle[2] = center + BPoint(0.0, 2.0);
uint32 flags = Flags();
SetFlags(flags | B_SUBPIXEL_PRECISE);
SetHighColor(normalDarken4);
FillTriangle(triangle[0], triangle[1], triangle[2]);
SetFlags(flags);
} }
+22 -20
View File
@@ -35,7 +35,8 @@ BMenuField::BMenuField(BRect frame, const char *name, const char *label,
false, this); false, this);
AddChild(fMenuBar); AddChild(fMenuBar);
fMenuBar->AddItem(new _BMCItem_(menu)); // fMenuBar->AddItem(new _BMCItem_(menu));
fMenuBar->AddItem(menu);
fMenuBar->SetFont(be_plain_font); fMenuBar->SetFont(be_plain_font);
@@ -60,7 +61,8 @@ BMenuField::BMenuField(BRect frame, const char *name, const char *label,
fixedSize, this); fixedSize, this);
AddChild(fMenuBar); AddChild(fMenuBar);
fMenuBar->AddItem(new _BMCItem_(menu)); // fMenuBar->AddItem(new _BMCItem_(menu));
fMenuBar->AddItem(menu);
fMenuBar->SetFont(be_plain_font); fMenuBar->SetFont(be_plain_font);
@@ -95,17 +97,17 @@ BMenuField::BMenuField(BMessage *data)
if (data->FindBool("be:fixeds", &fixed) == B_OK) if (data->FindBool("be:fixeds", &fixed) == B_OK)
fFixedSizeMB = fixed; fFixedSizeMB = fixed;
BMenuItem *item = fMenuBar->ItemAt(0); // BMenuItem *item = fMenuBar->ItemAt(0);
if (!item) // if (!item)
return; // return;
//
_BMCItem_ *bmcitem = dynamic_cast<_BMCItem_*>(item); // _BMCItem_ *bmcitem = dynamic_cast<_BMCItem_*>(item);
if (!bmcitem) // if (!bmcitem)
return; // return;
//
bool dmark; // bool dmark;
if (data->FindBool("be:dmark", &dmark)) // if (data->FindBool("be:dmark", &dmark))
bmcitem->fShowPopUpMarker = dmark; // bmcitem->fShowPopUpMarker = dmark;
} }
@@ -145,13 +147,13 @@ BMenuField::Archive(BMessage *data, bool deep) const
if (fFixedSizeMB) if (fFixedSizeMB)
data->AddBool("be:fixeds", true); data->AddBool("be:fixeds", true);
BMenuItem *item = fMenuBar->ItemAt(0); // BMenuItem *item = fMenuBar->ItemAt(0);
if (!item) // if (!item)
return B_OK; // return B_OK;
//
_BMCItem_ *bmcitem = dynamic_cast<_BMCItem_*>(item); // _BMCItem_ *bmcitem = dynamic_cast<_BMCItem_*>(item);
if (bmcitem && !bmcitem->fShowPopUpMarker) // if (bmcitem && !bmcitem->fShowPopUpMarker)
data->AddBool("be:dmark", false); // data->AddBool("be:dmark", false);
return B_OK; return B_OK;
} }