* DefaultDecorator:

- Introduced a virtual GetComponentColors(), that returns an array with the
    current colors for the specified component.
  - Removed all rgb_color members. Replaced the ones that were actually
    constant by const (or static const) ones and made use of
    GetComponentColors() where the non-constant ones were used.
* SATDecorator:
  - Turned rgb_color members into constants and added an overriding version
    of GetComponentColors().
  - HighlightBorders(): Invalidate the tab, too, as we use the border
    colors for drawing the outer lines of the tab (was this intented?).
    Fixes artifacts when breaking apart titled windows.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39630 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2010-11-25 20:07:32 +00:00
parent 2ee2a8ede4
commit e3ab8648d1
4 changed files with 287 additions and 151 deletions
@@ -1,9 +1,10 @@
/*
* Copyright 2010, Haiku.
* Copyright 2010, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* Clemens Zeidler <[email protected]>
* Ingo Weinhold <[email protected]>
*/
@@ -27,6 +28,23 @@
static const float kResizeKnobSize = 18.0;
static const rgb_color kHighlightFrameColors[6] = {
{ 152, 0, 0, 255 },
{ 240, 0, 0, 255 },
{ 224, 0, 0, 255 },
{ 208, 0, 0, 255 },
{ 152, 0, 0, 255 },
{ 108, 0, 0, 255 }
};
static const rgb_color kHighlightTabColor = { 255, 0, 0, 255 };
static const rgb_color kHighlightTabColorLight = tint_color(kHighlightTabColor,
(B_LIGHTEN_MAX_TINT + B_LIGHTEN_2_TINT) / 2);
static const rgb_color kHighlightTabColorBevel = tint_color(kHighlightTabColor,
B_LIGHTEN_2_TINT);
static const rgb_color kHighlightTabColorShadow = tint_color(kHighlightTabColor,
(B_DARKEN_1_TINT + B_NO_TINT) / 2);
SATDecorAddOn::SATDecorAddOn(image_id id, const char* name)
:
@@ -73,40 +91,12 @@ SATDecorator::SATDecorator(DesktopSettings& settings, BRect frame,
fStackedTabLength(0)
{
fStackedDrawZoom = IsFocus();
// all colors are state based
fNonHighlightFrameColors[0] = (rgb_color){ 152, 152, 152, 255 };
fNonHighlightFrameColors[1] = (rgb_color){ 240, 240, 240, 255 };
fNonHighlightFrameColors[2] = (rgb_color){ 152, 152, 152, 255 };
fNonHighlightFrameColors[3] = (rgb_color){ 108, 108, 108, 255 };
fHighlightFrameColors[0] = (rgb_color){ 152, 0, 0, 255 };
fHighlightFrameColors[1] = (rgb_color){ 240, 0, 0, 255 };
fHighlightFrameColors[2] = (rgb_color){ 224, 0, 0, 255 };
fHighlightFrameColors[3] = (rgb_color){ 208, 0, 0, 255 };
fHighlightFrameColors[4] = (rgb_color){ 152, 0, 0, 255 };
fHighlightFrameColors[5] = (rgb_color){ 108, 0, 0, 255 };
// initial colors
fFrameColors[0] = fNonHighlightFrameColors[0];
fFrameColors[1] = fNonHighlightFrameColors[1];
fFrameColors[4] = fNonHighlightFrameColors[2];
fFrameColors[5] = fNonHighlightFrameColors[3];
fHighlightTabColor = (rgb_color){ 255, 0, 0, 255 };
}
void
SATDecorator::HighlightTab(bool active, BRegion* dirty)
{
if (active)
fTabColor = fHighlightTabColor;
else if (IsFocus())
fTabColor = fFocusTabColor;
else
fTabColor = fNonFocusTabColor;
dirty->Include(fTabRect);
fTabHighlighted = active;
}
@@ -115,28 +105,8 @@ SATDecorator::HighlightTab(bool active, BRegion* dirty)
void
SATDecorator::HighlightBorders(bool active, BRegion* dirty)
{
if (active) {
fFrameColors[0] = fHighlightFrameColors[0];
fFrameColors[1] = fHighlightFrameColors[1];
fFrameColors[2] = fHighlightFrameColors[2];
fFrameColors[3] = fHighlightFrameColors[3];
fFrameColors[4] = fHighlightFrameColors[4];
fFrameColors[5] = fHighlightFrameColors[5];
} else if (IsFocus()) {
fFrameColors[0] = fNonHighlightFrameColors[0];
fFrameColors[1] = fNonHighlightFrameColors[1];
fFrameColors[2] = fFocusFrameColors[0];
fFrameColors[3] = fFocusFrameColors[1];
fFrameColors[4] = fNonHighlightFrameColors[2];
fFrameColors[5] = fNonHighlightFrameColors[3];
} else {
fFrameColors[0] = fNonHighlightFrameColors[0];
fFrameColors[1] = fNonHighlightFrameColors[1];
fFrameColors[2] = fNonFocusFrameColors[0];
fFrameColors[3] = fNonFocusFrameColors[1];
fFrameColors[4] = fNonHighlightFrameColors[2];
fFrameColors[5] = fNonHighlightFrameColors[3];
}
dirty->Include(fTabRect);
// for the frame lines
dirty->Include(fLeftBorder);
dirty->Include(fRightBorder);
dirty->Include(fTopBorder);
@@ -483,6 +453,62 @@ SATDecorator::DrawButtons(const BRect& invalid)
}
void
SATDecorator::GetComponentColors(Region component, ComponentColors _colors)
{
switch (component) {
case REGION_TAB:
if (fBordersHighlighted) {
_colors[COLOR_TAB_FRAME_LIGHT] = kHighlightFrameColors[0];
_colors[COLOR_TAB_FRAME_DARK] = kHighlightFrameColors[5];
} else {
_colors[COLOR_TAB_FRAME_LIGHT] = kFrameColors[0];
_colors[COLOR_TAB_FRAME_DARK] = kFrameColors[3];
}
if (fTabHighlighted) {
_colors[COLOR_TAB] = kHighlightTabColor;
_colors[COLOR_TAB_LIGHT] = kHighlightTabColorLight;
_colors[COLOR_TAB_BEVEL] = kHighlightTabColorBevel;
_colors[COLOR_TAB_SHADOW] = kHighlightTabColorShadow;
_colors[COLOR_TAB_TEXT] = kFocusTextColor;
} else if (fButtonFocus) {
_colors[COLOR_TAB] = kFocusTabColor;
_colors[COLOR_TAB_LIGHT] = kFocusTabColorLight;
_colors[COLOR_TAB_BEVEL] = kFocusTabColorBevel;
_colors[COLOR_TAB_SHADOW] = kFocusTabColorShadow;
_colors[COLOR_TAB_TEXT] = kFocusTextColor;
} else {
_colors[COLOR_TAB] = kNonFocusTabColor;
_colors[COLOR_TAB_LIGHT] = kNonFocusTabColorLight;
_colors[COLOR_TAB_BEVEL] = kNonFocusTabColorBevel;
_colors[COLOR_TAB_SHADOW] = kNonFocusTabColorShadow;
_colors[COLOR_TAB_TEXT] = kNonFocusTextColor;
}
break;
case REGION_LEFT_BORDER:
case REGION_RIGHT_BORDER:
case REGION_TOP_BORDER:
case REGION_BOTTOM_BORDER:
case REGION_RIGHT_BOTTOM_CORNER:
default:
if (!fBordersHighlighted) {
DefaultDecorator::GetComponentColors(component, _colors);
return;
}
_colors[0] = kHighlightFrameColors[0];
_colors[1] = kHighlightFrameColors[1];
_colors[2] = kHighlightFrameColors[2];
_colors[3] = kHighlightFrameColors[3];
_colors[4] = kHighlightFrameColors[4];
_colors[5] = kHighlightFrameColors[5];
break;
}
}
extern "C" DecorAddOn* (instantiate_decor_addon)(image_id id, const char* name)
{
return new (std::nothrow)SATDecorAddOn(id, name);
@@ -1,5 +1,5 @@
/*
* Copyright 2010, Haiku.
* Copyright 2010, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -63,13 +63,12 @@ protected:
void _SetFocus();
virtual void DrawButtons(const BRect& invalid);
virtual void GetComponentColors(Region component,
ComponentColors _colors);
private:
bool fTabHighlighted;
bool fBordersHighlighted;
rgb_color fHighlightTabColor;
rgb_color fNonHighlightFrameColors[4];
rgb_color fHighlightFrameColors[6];
bool fStackedMode;
bool fStackedDrawZoom;
+177 -81
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2001-2010, Haiku.
* Copyright 2001-2010, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -65,33 +65,52 @@ blend_color_value(uint8 a, uint8 b, float position)
// #pragma mark -
const rgb_color DefaultDecorator::kFrameColors[4] = {
{ 152, 152, 152, 255 },
{ 240, 240, 240, 255 },
{ 152, 152, 152, 255 },
{ 108, 108, 108, 255 }
};
const rgb_color DefaultDecorator::kFocusFrameColors[2] = {
{ 224, 224, 224, 255 },
{ 208, 208, 208, 255 }
};
const rgb_color DefaultDecorator::kNonFocusFrameColors[2] = {
{ 232, 232, 232, 255 },
{ 232, 232, 232, 255 }
};
// TODO: get rid of DesktopSettings here, and introduce private accessor
// methods to the Decorator base class
DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect,
window_look look, uint32 flags)
: Decorator(settings, rect, look, flags),
window_look look, uint32 flags)
:
Decorator(settings, rect, look, flags),
// focus color constants
kFocusTabColor(settings.UIColor(B_WINDOW_TAB_COLOR)),
kFocusTabColorLight(tint_color(kFocusTabColor,
(B_LIGHTEN_MAX_TINT + B_LIGHTEN_2_TINT) / 2)),
kFocusTabColorBevel(tint_color(kFocusTabColor, B_LIGHTEN_2_TINT)),
kFocusTabColorShadow(tint_color(kFocusTabColor,
(B_DARKEN_1_TINT + B_NO_TINT) / 2)),
kFocusTextColor(settings.UIColor(B_WINDOW_TEXT_COLOR)),
// non-focus color constants
kNonFocusTabColor(settings.UIColor(B_WINDOW_INACTIVE_TAB_COLOR)),
kNonFocusTabColorLight(tint_color(kNonFocusTabColor,
(B_LIGHTEN_MAX_TINT + B_LIGHTEN_2_TINT) / 2)),
kNonFocusTabColorBevel(tint_color(kNonFocusTabColor, B_LIGHTEN_2_TINT)),
kNonFocusTabColorShadow(tint_color(kNonFocusTabColor,
(B_DARKEN_1_TINT + B_NO_TINT) / 2)),
kNonFocusTextColor(settings.UIColor(B_WINDOW_INACTIVE_TEXT_COLOR)),
fTabOffset(0),
fTabLocation(0.0)
{
_UpdateFont(settings);
// common colors to both focus and non focus state
fFrameColors[0] = (rgb_color){ 152, 152, 152, 255 };
fFrameColors[1] = (rgb_color){ 240, 240, 240, 255 };
fFrameColors[4] = (rgb_color){ 152, 152, 152, 255 };
fFrameColors[5] = (rgb_color){ 108, 108, 108, 255 };
// state based colors
fFocusFrameColors[0] = (rgb_color){ 224, 224, 224, 255 };
fFocusFrameColors[1] = (rgb_color){ 208, 208, 208, 255 };
fNonFocusFrameColors[0] = (rgb_color){ 232, 232, 232, 255 };
fNonFocusFrameColors[1] = fNonFocusFrameColors[0];
fFocusTabColor = settings.UIColor(B_WINDOW_TAB_COLOR);
fFocusTextColor = settings.UIColor(B_WINDOW_TEXT_COLOR);
fNonFocusTabColor = settings.UIColor(B_WINDOW_INACTIVE_TAB_COLOR);
fNonFocusTextColor = settings.UIColor(B_WINDOW_INACTIVE_TEXT_COLOR);
fCloseBitmaps[0] = fCloseBitmaps[1] = fCloseBitmaps[2] = fCloseBitmaps[3]
= fZoomBitmaps[0] = fZoomBitmaps[1] = fZoomBitmaps[2] = fZoomBitmaps[3]
= NULL;
@@ -418,9 +437,12 @@ DefaultDecorator::_DrawFrame(BRect invalid)
{
// top
if (invalid.Intersects(fTopBorder)) {
ComponentColors colors;
GetComponentColors(REGION_TOP_BORDER, colors);
for (int8 i = 0; i < 5; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
BPoint(r.right - i, r.top + i), fFrameColors[i]);
BPoint(r.right - i, r.top + i), colors[i]);
}
if (fTabRect.IsValid()) {
// grey along the bottom of the tab
@@ -428,30 +450,39 @@ DefaultDecorator::_DrawFrame(BRect invalid)
fDrawingEngine->StrokeLine(
BPoint(fTabRect.left + 2, fTabRect.bottom + 1),
BPoint(fTabRect.right - 2, fTabRect.bottom + 1),
fFrameColors[2]);
colors[2]);
}
}
// left
if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
ComponentColors colors;
GetComponentColors(REGION_LEFT_BORDER, colors);
for (int8 i = 0; i < 5; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
BPoint(r.left + i, r.bottom - i), fFrameColors[i]);
BPoint(r.left + i, r.bottom - i), colors[i]);
}
}
// bottom
if (invalid.Intersects(fBottomBorder)) {
ComponentColors colors;
GetComponentColors(REGION_BOTTOM_BORDER, colors);
for (int8 i = 0; i < 5; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.bottom - i),
BPoint(r.right - i, r.bottom - i),
fFrameColors[(4 - i) == 4 ? 5 : (4 - i)]);
colors[(4 - i) == 4 ? 5 : (4 - i)]);
}
}
// right
if (invalid.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) {
ComponentColors colors;
GetComponentColors(REGION_RIGHT_BORDER, colors);
for (int8 i = 0; i < 5; i++) {
fDrawingEngine->StrokeLine(BPoint(r.right - i, r.top + i),
BPoint(r.right - i, r.bottom - i),
fFrameColors[(4 - i) == 4 ? 5 : (4 - i)]);
colors[(4 - i) == 4 ? 5 : (4 - i)]);
}
}
break;
@@ -462,9 +493,12 @@ DefaultDecorator::_DrawFrame(BRect invalid)
{
// top
if (invalid.Intersects(fTopBorder)) {
ComponentColors colors;
GetComponentColors(REGION_TOP_BORDER, colors);
for (int8 i = 0; i < 3; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
BPoint(r.right - i, r.top + i), fFrameColors[i * 2]);
BPoint(r.right - i, r.top + i), colors[i * 2]);
}
if (fTabRect.IsValid() && fLook != kLeftTitledWindowLook) {
// grey along the bottom of the tab
@@ -472,14 +506,17 @@ DefaultDecorator::_DrawFrame(BRect invalid)
fDrawingEngine->StrokeLine(
BPoint(fTabRect.left + 2, fTabRect.bottom + 1),
BPoint(fTabRect.right - 2, fTabRect.bottom + 1),
fFrameColors[2]);
colors[2]);
}
}
// left
if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
ComponentColors colors;
GetComponentColors(REGION_LEFT_BORDER, colors);
for (int8 i = 0; i < 3; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
BPoint(r.left + i, r.bottom - i), fFrameColors[i * 2]);
BPoint(r.left + i, r.bottom - i), colors[i * 2]);
}
if (fLook == kLeftTitledWindowLook && fTabRect.IsValid()) {
// grey along the right side of the tab
@@ -487,31 +524,43 @@ DefaultDecorator::_DrawFrame(BRect invalid)
fDrawingEngine->StrokeLine(
BPoint(fTabRect.right + 1, fTabRect.top + 2),
BPoint(fTabRect.right + 1, fTabRect.bottom - 2),
fFrameColors[2]);
colors[2]);
}
}
// bottom
if (invalid.Intersects(fBottomBorder)) {
ComponentColors colors;
GetComponentColors(REGION_BOTTOM_BORDER, colors);
for (int8 i = 0; i < 3; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.bottom - i),
BPoint(r.right - i, r.bottom - i),
fFrameColors[(2 - i) == 2 ? 5 : (2 - i) * 2]);
colors[(2 - i) == 2 ? 5 : (2 - i) * 2]);
}
}
// right
if (invalid.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) {
ComponentColors colors;
GetComponentColors(REGION_RIGHT_BORDER, colors);
for (int8 i = 0; i < 3; i++) {
fDrawingEngine->StrokeLine(BPoint(r.right - i, r.top + i),
BPoint(r.right - i, r.bottom - i),
fFrameColors[(2 - i) == 2 ? 5 : (2 - i) * 2]);
colors[(2 - i) == 2 ? 5 : (2 - i) * 2]);
}
}
break;
}
case B_BORDERED_WINDOW_LOOK:
fDrawingEngine->StrokeRect(r, fFrameColors[5]);
{
// TODO: Draw the borders individually!
ComponentColors colors;
GetComponentColors(REGION_LEFT_BORDER, colors);
fDrawingEngine->StrokeRect(r, colors[5]);
break;
}
default:
// don't draw a border frame
@@ -522,6 +571,9 @@ DefaultDecorator::_DrawFrame(BRect invalid)
if (!(fFlags & B_NOT_RESIZABLE)) {
r = fResizeRect;
ComponentColors colors;
GetComponentColors(REGION_RIGHT_BOTTOM_CORNER, colors);
switch (fLook) {
case B_DOCUMENT_WINDOW_LOOK:
{
@@ -536,19 +588,19 @@ DefaultDecorator::_DrawFrame(BRect invalid)
BGradientLinear gradient;
gradient.SetStart(bg.LeftTop());
gradient.SetEnd(bg.RightBottom());
gradient.AddColor(fFrameColors[1], 0);
gradient.AddColor(fFrameColors[2], 255);
gradient.AddColor(colors[1], 0);
gradient.AddColor(colors[2], 255);
fDrawingEngine->FillRect(bg, gradient);
fDrawingEngine->StrokeLine(BPoint(x - 15, y - 15),
BPoint(x - 15, y - 2), fFrameColors[0]);
BPoint(x - 15, y - 2), colors[0]);
fDrawingEngine->StrokeLine(BPoint(x - 14, y - 14),
BPoint(x - 14, y - 1), fFrameColors[1]);
BPoint(x - 14, y - 1), colors[1]);
fDrawingEngine->StrokeLine(BPoint(x - 15, y - 15),
BPoint(x - 2, y - 15), fFrameColors[0]);
BPoint(x - 2, y - 15), colors[0]);
fDrawingEngine->StrokeLine(BPoint(x - 14, y - 14),
BPoint(x - 1, y - 14), fFrameColors[1]);
BPoint(x - 1, y - 14), colors[1]);
if (!IsFocus())
break;
@@ -559,7 +611,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
for (int8 j = 1; j <= i; j++) {
BPoint pt1(x - (3 * j) + 1, y - (3 * (5 - i)) + 1);
BPoint pt2(x - (3 * j) + 2, y - (3 * (5 - i)) + 2);
fDrawingEngine->StrokePoint(pt1, fFrameColors[0]);
fDrawingEngine->StrokePoint(pt1, colors[0]);
fDrawingEngine->StrokePoint(pt2, kWhite);
}
}
@@ -579,11 +631,11 @@ DefaultDecorator::_DrawFrame(BRect invalid)
fDrawingEngine->StrokeLine(
BPoint(fRightBorder.left, fBottomBorder.bottom - kBorderResizeLength),
BPoint(fRightBorder.right - 1, fBottomBorder.bottom - kBorderResizeLength),
fFrameColors[0]);
colors[0]);
fDrawingEngine->StrokeLine(
BPoint(fRightBorder.right - kBorderResizeLength, fBottomBorder.top),
BPoint(fRightBorder.right - kBorderResizeLength, fBottomBorder.bottom - 1),
fFrameColors[0]);
colors[0]);
break;
}
@@ -605,43 +657,48 @@ DefaultDecorator::_DrawTab(BRect invalid)
if (!fTabRect.IsValid() || !invalid.Intersects(fTabRect))
return;
ComponentColors colors;
GetComponentColors(REGION_TAB, colors);
// outer frame
fDrawingEngine->StrokeLine(fTabRect.LeftTop(), fTabRect.LeftBottom(),
fFrameColors[0]);
colors[COLOR_TAB_FRAME_LIGHT]);
fDrawingEngine->StrokeLine(fTabRect.LeftTop(), fTabRect.RightTop(),
fFrameColors[0]);
colors[COLOR_TAB_FRAME_LIGHT]);
if (fLook != kLeftTitledWindowLook) {
fDrawingEngine->StrokeLine(fTabRect.RightTop(), fTabRect.RightBottom(),
fFrameColors[5]);
colors[COLOR_TAB_FRAME_DARK]);
} else {
fDrawingEngine->StrokeLine(fTabRect.LeftBottom(),
fTabRect.RightBottom(), fFrameColors[5]);
fTabRect.RightBottom(), colors[COLOR_TAB_FRAME_DARK]);
}
// bevel
fDrawingEngine->StrokeLine(BPoint(fTabRect.left + 1, fTabRect.top + 1),
BPoint(fTabRect.left + 1,
fTabRect.bottom - (fLook == kLeftTitledWindowLook ? 1 : 0)),
fTabColorBevel);
colors[COLOR_TAB_BEVEL]);
fDrawingEngine->StrokeLine(BPoint(fTabRect.left + 1, fTabRect.top + 1),
BPoint(fTabRect.right - (fLook == kLeftTitledWindowLook ? 0 : 1),
fTabRect.top + 1),
fTabColorBevel);
colors[COLOR_TAB_BEVEL]);
if (fLook != kLeftTitledWindowLook) {
fDrawingEngine->StrokeLine(BPoint(fTabRect.right - 1, fTabRect.top + 2),
BPoint(fTabRect.right - 1, fTabRect.bottom), fTabColorShadow);
BPoint(fTabRect.right - 1, fTabRect.bottom),
colors[COLOR_TAB_SHADOW]);
} else {
fDrawingEngine->StrokeLine(
BPoint(fTabRect.left + 2, fTabRect.bottom - 1),
BPoint(fTabRect.right, fTabRect.bottom - 1), fTabColorShadow);
BPoint(fTabRect.right, fTabRect.bottom - 1),
colors[COLOR_TAB_SHADOW]);
}
// fill
BGradientLinear gradient;
gradient.SetStart(fTabRect.LeftTop());
gradient.AddColor(fTabColorLight, 0);
gradient.AddColor(fTabColor, 255);
gradient.AddColor(colors[COLOR_TAB_LIGHT], 0);
gradient.AddColor(colors[COLOR_TAB], 255);
if (fLook != kLeftTitledWindowLook) {
gradient.SetEnd(fTabRect.LeftBottom());
@@ -682,8 +739,11 @@ DefaultDecorator::_DrawTitle(BRect r)
{
STRACE(("_DrawTitle(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom));
ComponentColors colors;
GetComponentColors(REGION_TAB, colors);
fDrawingEngine->SetDrawingMode(B_OP_OVER);
fDrawingEngine->SetHighColor(fTextColor);
fDrawingEngine->SetHighColor(colors[COLOR_TAB_TEXT]);
fDrawingEngine->SetFont(fDrawState.Font());
// figure out position of text
@@ -812,30 +872,9 @@ DefaultDecorator::_SetFlags(uint32 flags, BRegion* updateRegion)
void
DefaultDecorator::_SetFocus()
{
// SetFocus() performs necessary duties for color swapping and
// other things when a window is deactivated or activated.
if (IsFocus()
fButtonFocus = IsFocus()
|| ((fLook == B_FLOATING_WINDOW_LOOK || fLook == kLeftTitledWindowLook)
&& (fFlags & B_AVOID_FOCUS) != 0)) {
fTabColor = fFocusTabColor;
fTextColor = fFocusTextColor;
fFrameColors[2] = fFocusFrameColors[0];
fFrameColors[3] = fFocusFrameColors[1];
fButtonFocus = true;
} else {
fTabColor = fNonFocusTabColor;
fTextColor = fNonFocusTextColor;
fFrameColors[2] = fNonFocusFrameColors[0];
fFrameColors[3] = fNonFocusFrameColors[1];
fButtonFocus = false;
}
fTabColorBevel = tint_color(fTabColor,
(B_LIGHTEN_MAX_TINT + B_LIGHTEN_2_TINT) / 2);
fTabColorLight = tint_color(fTabColor, B_LIGHTEN_2_TINT);
fTabColorShadow = tint_color(fTabColor,
(B_DARKEN_1_TINT + B_NO_TINT) / 2);
&& (fFlags & B_AVOID_FOCUS) != 0);
}
@@ -1097,6 +1136,59 @@ DefaultDecorator::DrawButtons(const BRect& invalid)
}
/*! Returns the frame colors for the specified decorator component.
The meaning of the color array elements depends on the specified component.
For some components some array elements are unused.
\param region The region for which to return the frame colors.
\param colors An array of colors to be initialized by the function.
*/
void
DefaultDecorator::GetComponentColors(Region component, ComponentColors _colors)
{
switch (component) {
case REGION_TAB:
_colors[COLOR_TAB_FRAME_LIGHT] = kFrameColors[0];
_colors[COLOR_TAB_FRAME_DARK] = kFrameColors[3];
if (fButtonFocus) {
_colors[COLOR_TAB] = kFocusTabColor;
_colors[COLOR_TAB_LIGHT] = kFocusTabColorLight;
_colors[COLOR_TAB_BEVEL] = kFocusTabColorBevel;
_colors[COLOR_TAB_SHADOW] = kFocusTabColorShadow;
_colors[COLOR_TAB_TEXT] = kFocusTextColor;
} else {
_colors[COLOR_TAB] = kNonFocusTabColor;
_colors[COLOR_TAB_LIGHT] = kNonFocusTabColorLight;
_colors[COLOR_TAB_BEVEL] = kNonFocusTabColorBevel;
_colors[COLOR_TAB_SHADOW] = kNonFocusTabColorShadow;
_colors[COLOR_TAB_TEXT] = kNonFocusTextColor;
}
break;
case REGION_LEFT_BORDER:
case REGION_RIGHT_BORDER:
case REGION_TOP_BORDER:
case REGION_BOTTOM_BORDER:
case REGION_RIGHT_BOTTOM_CORNER:
default:
// common colors to both focus and non focus state
_colors[0] = kFrameColors[0];
_colors[1] = kFrameColors[1];
if (fButtonFocus) {
_colors[2] = kFocusFrameColors[0];
_colors[3] = kFocusFrameColors[1];
} else {
_colors[2] = kNonFocusFrameColors[0];
_colors[3] = kNonFocusFrameColors[1];
}
_colors[4] = kFrameColors[2];
_colors[5] = kFrameColors[3];
break;
}
}
void
DefaultDecorator::_UpdateFont(DesktopSettings& settings)
{
@@ -1137,12 +1229,16 @@ void
DefaultDecorator::_DrawBlendedRect(DrawingEngine* engine, BRect rect,
bool down, bool focus)
{
ComponentColors colors;
GetComponentColors(REGION_TAB, colors);
// figure out which colors to use
rgb_color startColor, endColor;
rgb_color tabColor = focus ? fFocusTabColor : fNonFocusTabColor;
rgb_color tabColor = focus ? kFocusTabColor : kNonFocusTabColor;
// TODO: Use GetComponentColors() only!
if (down) {
startColor = tint_color(tabColor, B_DARKEN_1_TINT);
endColor = fTabColorLight;
endColor = colors[COLOR_TAB_LIGHT];
} else {
startColor = tint_color(tabColor, B_LIGHTEN_MAX_TINT);
endColor = tabColor;
@@ -1273,8 +1369,8 @@ DefaultDecorator::_GetBitmapForButton(Region item, bool down, bool focus,
if (current->item == item && current->down == down
&& current->focus == focus && current->width == width
&& current->height == height
&& current->focusColor == object->fFocusTabColor
&& current->nonFocusColor == object->fNonFocusTabColor) {
&& current->focusColor == object->kFocusTabColor
&& current->nonFocusColor == object->kNonFocusTabColor) {
return current->bitmap;
}
@@ -1343,8 +1439,8 @@ DefaultDecorator::_GetBitmapForButton(Region item, bool down, bool focus,
entry->width = width;
entry->height = height;
entry->bitmap = bitmap;
entry->focusColor = object->fFocusTabColor;
entry->nonFocusColor = object->fNonFocusTabColor;
entry->focusColor = object->kFocusTabColor;
entry->nonFocusColor = object->kNonFocusTabColor;
entry->next = sBitmapList;
sBitmapList = entry;
return bitmap;
+30 -15
View File
@@ -1,11 +1,12 @@
/*
* Copyright 2001-2010, Haiku.
* Copyright 2001-2010, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* DarkWyrm <bpmagic@columbus.rr.com>
* Stephan Aßmus <superstippi@gmx.de>
* Clemens Zeidler <haiku@clemens-zeidler.de>
* Ingo Weinhold <ingo_weinhold@gmx.de>
*/
#ifndef DEFAULT_DECORATOR_H
#define DEFAULT_DECORATOR_H
@@ -42,6 +43,19 @@ public:
float BorderWidth();
float TabHeight();
protected:
enum {
COLOR_TAB_FRAME_LIGHT = 0,
COLOR_TAB_FRAME_DARK = 1,
COLOR_TAB = 2,
COLOR_TAB_LIGHT = 3,
COLOR_TAB_BEVEL = 4,
COLOR_TAB_SHADOW = 5,
COLOR_TAB_TEXT = 6
};
typedef rgb_color ComponentColors[7];
protected:
virtual void _DoLayout();
@@ -82,6 +96,8 @@ protected:
// DefaultDecorator customization points
virtual void DrawButtons(const BRect& invalid);
virtual void GetComponentColors(Region component,
ComponentColors _colors);
private:
void _UpdateFont(DesktopSettings& settings);
@@ -96,22 +112,21 @@ private:
DefaultDecorator* object);
protected:
rgb_color fButtonHighColor;
rgb_color fButtonLowColor;
rgb_color fTabColor;
rgb_color fFocusTabColor;
rgb_color fNonFocusTabColor;
rgb_color fTextColor;
rgb_color fFocusTextColor;
rgb_color fNonFocusTextColor;
static const rgb_color kFrameColors[4];
static const rgb_color kFocusFrameColors[2];
static const rgb_color kNonFocusFrameColors[2];
rgb_color fTabColorLight;
rgb_color fTabColorBevel;
rgb_color fTabColorShadow;
const rgb_color kFocusTabColor;
const rgb_color kFocusTabColorLight;
const rgb_color kFocusTabColorBevel;
const rgb_color kFocusTabColorShadow;
const rgb_color kFocusTextColor;
rgb_color fFrameColors[6];
rgb_color fFocusFrameColors[2];
rgb_color fNonFocusFrameColors[2];
const rgb_color kNonFocusTabColor;
const rgb_color kNonFocusTabColorLight;
const rgb_color kNonFocusTabColorBevel;
const rgb_color kNonFocusTabColorShadow;
const rgb_color kNonFocusTextColor;
bool fButtonFocus;
ServerBitmap* fCloseBitmaps[4];