Remove pre-ControlLook drawing code in menu classes
This commit is contained in:
parent
d218f0f822
commit
6c1452071c
@ -136,119 +136,24 @@ _BMCMenuBar_::AttachedToWindow()
|
|||||||
void
|
void
|
||||||
_BMCMenuBar_::Draw(BRect updateRect)
|
_BMCMenuBar_::Draw(BRect updateRect)
|
||||||
{
|
{
|
||||||
if (be_control_look != NULL) {
|
float height;
|
||||||
BRect rect(Bounds());
|
GetPreferredSize(NULL, &height);
|
||||||
rgb_color base = ui_color(B_MENU_BACKGROUND_COLOR);
|
ResizeTo(fMenuField->_MenuBarWidth(), height);
|
||||||
uint32 flags = 0;
|
// Set the width to the menu field width because the menubar
|
||||||
if (!IsEnabled())
|
// bounds are expanded by the selected menu item.
|
||||||
flags |= BControlLook::B_DISABLED;
|
BRect rect(Bounds());
|
||||||
if (IsFocus())
|
|
||||||
flags |= BControlLook::B_FOCUSED;
|
|
||||||
be_control_look->DrawMenuFieldBackground(this, rect,
|
|
||||||
updateRect, base, fShowPopUpMarker, flags);
|
|
||||||
|
|
||||||
_DrawItems(updateRect);
|
rgb_color base = ui_color(B_MENU_BACKGROUND_COLOR);
|
||||||
|
uint32 flags = 0;
|
||||||
|
if (!IsEnabled())
|
||||||
|
flags |= BControlLook::B_DISABLED;
|
||||||
|
if (IsFocus())
|
||||||
|
flags |= BControlLook::B_FOCUSED;
|
||||||
|
|
||||||
return;
|
be_control_look->DrawMenuFieldBackground(this, rect,
|
||||||
}
|
updateRect, base, fShowPopUpMarker, flags);
|
||||||
|
|
||||||
if (!fShowPopUpMarker) {
|
_DrawItems(updateRect);
|
||||||
BMenuBar::Draw(updateRect);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// draw the right side with the popup marker
|
|
||||||
|
|
||||||
// prevent the original BMenuBar's Draw from
|
|
||||||
// drawing in those parts
|
|
||||||
BRect bounds(Bounds());
|
|
||||||
bounds.right -= 10.0;
|
|
||||||
bounds.bottom -= 1.0;
|
|
||||||
|
|
||||||
BRegion clipping(bounds);
|
|
||||||
ConstrainClippingRegion(&clipping);
|
|
||||||
|
|
||||||
BMenuBar::Draw(updateRect);
|
|
||||||
|
|
||||||
// restore clipping
|
|
||||||
ConstrainClippingRegion(NULL);
|
|
||||||
bounds.right += 10.0;
|
|
||||||
bounds.bottom += 1.0;
|
|
||||||
|
|
||||||
// prepare some colors
|
|
||||||
rgb_color normalNoTint = LowColor();
|
|
||||||
rgb_color noTint = tint_color(normalNoTint, 0.74);
|
|
||||||
rgb_color darken4;
|
|
||||||
rgb_color normalDarken4;
|
|
||||||
rgb_color darken1;
|
|
||||||
rgb_color lighten1;
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -279,44 +279,14 @@ BMenuBar::Draw(BRect updateRect)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (be_control_look != NULL) {
|
BRect rect(Bounds());
|
||||||
BRect rect(Bounds());
|
rgb_color base = LowColor();
|
||||||
rgb_color base = LowColor();
|
uint32 flags = 0;
|
||||||
uint32 flags = 0;
|
|
||||||
|
|
||||||
be_control_look->DrawBorder(this, rect, updateRect, base,
|
be_control_look->DrawBorder(this, rect, updateRect, base,
|
||||||
B_PLAIN_BORDER, flags, BControlLook::B_BOTTOM_BORDER);
|
B_PLAIN_BORDER, flags, BControlLook::B_BOTTOM_BORDER);
|
||||||
|
|
||||||
be_control_look->DrawMenuBarBackground(this, rect, updateRect, base);
|
be_control_look->DrawMenuBarBackground(this, rect, updateRect, base);
|
||||||
|
|
||||||
_DrawItems(updateRect);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: implement additional border styles
|
|
||||||
rgb_color color = HighColor();
|
|
||||||
|
|
||||||
BRect bounds(Bounds());
|
|
||||||
// Restore the background of the previously selected menuitem
|
|
||||||
DrawBackground(bounds & updateRect);
|
|
||||||
|
|
||||||
rgb_color noTint = LowColor();
|
|
||||||
|
|
||||||
SetHighColor(tint_color(noTint, B_LIGHTEN_2_TINT));
|
|
||||||
StrokeLine(BPoint(0.0f, bounds.bottom - 2.0f), BPoint(0.0f, 0.0f));
|
|
||||||
StrokeLine(BPoint(bounds.right, 0.0f));
|
|
||||||
|
|
||||||
SetHighColor(tint_color(noTint, B_DARKEN_1_TINT));
|
|
||||||
StrokeLine(BPoint(1.0f, bounds.bottom - 1.0f),
|
|
||||||
BPoint(bounds.right, bounds.bottom - 1.0f));
|
|
||||||
|
|
||||||
SetHighColor(tint_color(noTint, B_DARKEN_2_TINT));
|
|
||||||
StrokeLine(BPoint(0.0f, bounds.bottom),
|
|
||||||
BPoint(bounds.right, bounds.bottom));
|
|
||||||
StrokeLine(BPoint(bounds.right, 0.0f), BPoint(bounds.right, bounds.bottom));
|
|
||||||
|
|
||||||
SetHighColor(color);
|
|
||||||
// revert to previous used color (cheap PushState()/PopState())
|
|
||||||
|
|
||||||
_DrawItems(updateRect);
|
_DrawItems(updateRect);
|
||||||
}
|
}
|
||||||
|
@ -454,15 +454,10 @@ BMenuItem::Draw()
|
|||||||
// set low color and fill background if selected
|
// set low color and fill background if selected
|
||||||
bool activated = selected && (enabled || Submenu());
|
bool activated = selected && (enabled || Submenu());
|
||||||
if (activated) {
|
if (activated) {
|
||||||
if (be_control_look != NULL) {
|
BRect rect = Frame();
|
||||||
BRect rect = Frame();
|
be_control_look->DrawMenuItemBackground(fSuper, rect, rect,
|
||||||
be_control_look->DrawMenuItemBackground(fSuper, rect, rect,
|
ui_color(B_MENU_SELECTED_BACKGROUND_COLOR),
|
||||||
ui_color(B_MENU_SELECTED_BACKGROUND_COLOR),
|
BControlLook::B_ACTIVATED);
|
||||||
BControlLook::B_ACTIVATED);
|
|
||||||
} else {
|
|
||||||
fSuper->SetLowColor(ui_color(B_MENU_SELECTED_BACKGROUND_COLOR));
|
|
||||||
fSuper->FillRect(Frame(), B_SOLID_LOW);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set high color
|
// set high color
|
||||||
|
Loading…
Reference in New Issue
Block a user