Added support for colored window tabs in the default decorator.

This commit is contained in:
John Scipione 2011-10-28 04:14:28 -04:00
parent 20db27ba98
commit 30d17caa9d
8 changed files with 54 additions and 38 deletions

View File

@ -322,7 +322,10 @@ enum color_which {
B_WINDOW_TAB_COLOR = 3, B_WINDOW_TAB_COLOR = 3,
B_WINDOW_TEXT_COLOR = 22, B_WINDOW_TEXT_COLOR = 22,
B_WINDOW_INACTIVE_TAB_COLOR = 23, B_WINDOW_INACTIVE_TAB_COLOR = 23,
B_WINDOW_INACTIVE_TEXT_COLOR = 24 B_WINDOW_INACTIVE_TEXT_COLOR = 24,
B_WINDOW_BORDER_COLOR = 25,
B_WINDOW_INACTIVE_BORDER_COLOR = 26
}; };

View File

@ -26,10 +26,10 @@ static inline int32
color_which_to_index(color_which which) color_which_to_index(color_which which)
{ {
// NOTE: this must be kept in sync with InterfaceDefs.h color_which! // NOTE: this must be kept in sync with InterfaceDefs.h color_which!
if (which <= B_WINDOW_INACTIVE_TEXT_COLOR) if (which <= B_WINDOW_INACTIVE_BORDER_COLOR)
return which - 1; return which - 1;
if (which >= B_SUCCESS_COLOR && which <= B_FAILURE_COLOR) if (which >= B_SUCCESS_COLOR && which <= B_FAILURE_COLOR)
return which - B_SUCCESS_COLOR + B_WINDOW_INACTIVE_TEXT_COLOR; return which - B_SUCCESS_COLOR + B_WINDOW_INACTIVE_BORDER_COLOR;
return -1; return -1;
} }
@ -38,10 +38,10 @@ static inline color_which
index_to_color_which(int32 index) index_to_color_which(int32 index)
{ {
if (index >= 0 && index < kNumColors) { if (index >= 0 && index < kNumColors) {
if ((color_which)index < B_WINDOW_INACTIVE_TEXT_COLOR) if ((color_which)index < B_WINDOW_INACTIVE_BORDER_COLOR)
return (color_which)(index + 1); return (color_which)(index + 1);
else else
return (color_which)(index + B_SUCCESS_COLOR - B_WINDOW_INACTIVE_TEXT_COLOR); return (color_which)(index + B_SUCCESS_COLOR - B_WINDOW_INACTIVE_BORDER_COLOR);
} }
return (color_which)-1; return (color_which)-1;

View File

@ -63,6 +63,8 @@ static struct option const kLongOptions[] = {
I(window_text_color, B_WINDOW_TEXT_COLOR), I(window_text_color, B_WINDOW_TEXT_COLOR),
I(window_inactive_tab_color, B_WINDOW_INACTIVE_TAB_COLOR), I(window_inactive_tab_color, B_WINDOW_INACTIVE_TAB_COLOR),
I(window_inactive_text_color, B_WINDOW_INACTIVE_TEXT_COLOR), I(window_inactive_text_color, B_WINDOW_INACTIVE_TEXT_COLOR),
I(window_border_color, B_WINDOW_BORDER_COLOR),
I(window_inactive_border_color, B_WINDOW_INACTIVE_BORDER_COLOR),
{"sum", required_argument, 0, 's'}, {"sum", required_argument, 0, 's'},
{"refresh", no_argument, 0, 'r'}, {"refresh", no_argument, 0, 'r'},
{"help", no_argument, 0, 'h'}, {"help", no_argument, 0, 'h'},

View File

@ -94,6 +94,8 @@ static const rgb_color _kDefaultColors[kNumColors] = {
{0, 0, 0, 255}, // B_WINDOW_TEXT_COLOR {0, 0, 0, 255}, // B_WINDOW_TEXT_COLOR
{232, 232, 232, 255}, // B_WINDOW_INACTIVE_TAB_COLOR {232, 232, 232, 255}, // B_WINDOW_INACTIVE_TAB_COLOR
{80, 80, 80, 255}, // B_WINDOW_INACTIVE_TEXT_COLOR {80, 80, 80, 255}, // B_WINDOW_INACTIVE_TEXT_COLOR
{224, 224, 224, 255}, // B_WINDOW_BORDER_COLOR
{232, 232, 232, 255}, // B_WINDOW_INACTIVE_BORDER_COLOR
// 100... // 100...
{0, 255, 0, 255}, // B_SUCCESS_COLOR {0, 255, 0, 255}, // B_SUCCESS_COLOR
{255, 0, 0, 255}, // B_FAILURE_COLOR {255, 0, 0, 255}, // B_FAILURE_COLOR

View File

@ -54,7 +54,10 @@ static ColorDescription sColorDescriptionTable[] =
{ B_WINDOW_TEXT_COLOR, B_TRANSLATE_MARK("Window tab text") }, { B_WINDOW_TEXT_COLOR, B_TRANSLATE_MARK("Window tab text") },
{ B_WINDOW_INACTIVE_TAB_COLOR, B_TRANSLATE_MARK("Inactive window tab") }, { B_WINDOW_INACTIVE_TAB_COLOR, B_TRANSLATE_MARK("Inactive window tab") },
{ B_WINDOW_INACTIVE_TEXT_COLOR, { B_WINDOW_INACTIVE_TEXT_COLOR,
B_TRANSLATE_MARK("Inactive window tab text") } B_TRANSLATE_MARK("Inactive window tab text") },
{ B_WINDOW_BORDER_COLOR, B_TRANSLATE_MARK("Window border") },
{ B_WINDOW_INACTIVE_BORDER_COLOR,
B_TRANSLATE_MARK("Inactive window border") }
}; };
const int32 sColorDescriptionCount = sizeof(sColorDescriptionTable) const int32 sColorDescriptionCount = sizeof(sColorDescriptionTable)
@ -117,7 +120,6 @@ ColorSet::DefaultColorSet(void)
set.fColors[which] = set.fColors[which] =
BPrivate::kDefaultColors[color_which_to_index(which)]; BPrivate::kDefaultColors[color_which_to_index(which)];
} }
return set; return set;
} }

View File

@ -15,6 +15,7 @@
#include "Desktop.h" #include "Desktop.h"
#include "DrawingEngine.h" #include "DrawingEngine.h"
#include "DrawState.h" #include "DrawState.h"
#include "InterfaceDefs.h"
#include "ServerApp.h" #include "ServerApp.h"
#include "Window.h" #include "Window.h"
#include "Workspace.h" #include "Workspace.h"
@ -207,7 +208,8 @@ WorkspacesView::_DrawWindow(DrawingEngine* drawingEngine,
_DarkenColor(white); _DarkenColor(white);
} }
if (window == fSelectedWindow) { if (window == fSelectedWindow) {
frameColor = navColor; frameColor = ui_color(B_WINDOW_BORDER_COLOR);
//frameColor = navColor;
} }
if (tabFrame.left < frame.left) if (tabFrame.left < frame.left)

View File

@ -87,17 +87,6 @@ const rgb_color DefaultDecorator::kFrameColors[4] = {
{ 108, 108, 108, 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 // TODO: get rid of DesktopSettings here, and introduce private accessor
// methods to the Decorator base class // methods to the Decorator base class
@ -105,6 +94,9 @@ DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect)
: :
Decorator(settings, rect), Decorator(settings, rect),
// focus color constants // focus color constants
kFocusFrameColor(settings.UIColor(B_WINDOW_BORDER_COLOR)),
kFocusFrameColorBevel(tint_color(kFocusFrameColor, B_LIGHTEN_2_TINT)),
kFocusFrameColorDark(tint_color(kFocusFrameColor, B_DARKEN_1_TINT)),
kFocusTabColor(settings.UIColor(B_WINDOW_TAB_COLOR)), kFocusTabColor(settings.UIColor(B_WINDOW_TAB_COLOR)),
kFocusTabColorLight(tint_color(kFocusTabColor, kFocusTabColorLight(tint_color(kFocusTabColor,
(B_LIGHTEN_MAX_TINT + B_LIGHTEN_2_TINT) / 2)), (B_LIGHTEN_MAX_TINT + B_LIGHTEN_2_TINT) / 2)),
@ -113,6 +105,9 @@ DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect)
(B_DARKEN_1_TINT + B_NO_TINT) / 2)), (B_DARKEN_1_TINT + B_NO_TINT) / 2)),
kFocusTextColor(settings.UIColor(B_WINDOW_TEXT_COLOR)), kFocusTextColor(settings.UIColor(B_WINDOW_TEXT_COLOR)),
// non-focus color constants // non-focus color constants
kNonFocusFrameColor(settings.UIColor(B_WINDOW_INACTIVE_BORDER_COLOR)),
kNonFocusFrameColorBevel(tint_color(kNonFocusFrameColor, B_LIGHTEN_2_TINT)),
kNonFocusFrameColorDark(tint_color(kNonFocusFrameColor, B_DARKEN_1_TINT)),
kNonFocusTabColor(settings.UIColor(B_WINDOW_INACTIVE_TAB_COLOR)), kNonFocusTabColor(settings.UIColor(B_WINDOW_INACTIVE_TAB_COLOR)),
kNonFocusTabColorLight(tint_color(kNonFocusTabColor, kNonFocusTabColorLight(tint_color(kNonFocusTabColor,
(B_LIGHTEN_MAX_TINT + B_LIGHTEN_2_TINT) / 2)), (B_LIGHTEN_MAX_TINT + B_LIGHTEN_2_TINT) / 2)),
@ -143,7 +138,7 @@ DefaultDecorator::TabLocation(int32 tab) const
{ {
DefaultDecorator::Tab* decoratorTab = _TabAt(tab); DefaultDecorator::Tab* decoratorTab = _TabAt(tab);
if (decoratorTab == NULL) if (decoratorTab == NULL)
return 0.; return 0.0f;
return (float)decoratorTab->tabOffset; return (float)decoratorTab->tabOffset;
} }
@ -666,7 +661,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
// top // top
if (invalid.Intersects(fTopBorder)) { if (invalid.Intersects(fTopBorder)) {
ComponentColors colors; ComponentColors colors;
_GetComponentColors(COMPONENT_TOP_BORDER, colors); _GetComponentColors(COMPONENT_TOP_BORDER, colors, fTopTab);
for (int8 i = 0; i < 5; i++) { for (int8 i = 0; i < 5; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i), fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
@ -686,7 +681,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
// left // left
if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) { if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
ComponentColors colors; ComponentColors colors;
_GetComponentColors(COMPONENT_LEFT_BORDER, colors); _GetComponentColors(COMPONENT_LEFT_BORDER, colors, fTopTab);
for (int8 i = 0; i < 5; i++) { for (int8 i = 0; i < 5; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i), fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
@ -696,7 +691,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
// bottom // bottom
if (invalid.Intersects(fBottomBorder)) { if (invalid.Intersects(fBottomBorder)) {
ComponentColors colors; ComponentColors colors;
_GetComponentColors(COMPONENT_BOTTOM_BORDER, colors); _GetComponentColors(COMPONENT_BOTTOM_BORDER, colors, fTopTab);
for (int8 i = 0; i < 5; i++) { for (int8 i = 0; i < 5; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.bottom - i), fDrawingEngine->StrokeLine(BPoint(r.left + i, r.bottom - i),
@ -707,7 +702,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
// right // right
if (invalid.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) { if (invalid.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) {
ComponentColors colors; ComponentColors colors;
_GetComponentColors(COMPONENT_RIGHT_BORDER, colors); _GetComponentColors(COMPONENT_RIGHT_BORDER, colors, fTopTab);
for (int8 i = 0; i < 5; i++) { for (int8 i = 0; i < 5; i++) {
fDrawingEngine->StrokeLine(BPoint(r.right - i, r.top + i), fDrawingEngine->StrokeLine(BPoint(r.right - i, r.top + i),
@ -724,7 +719,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
// top // top
if (invalid.Intersects(fTopBorder)) { if (invalid.Intersects(fTopBorder)) {
ComponentColors colors; ComponentColors colors;
_GetComponentColors(COMPONENT_TOP_BORDER, colors); _GetComponentColors(COMPONENT_TOP_BORDER, colors, fTopTab);
for (int8 i = 0; i < 3; i++) { for (int8 i = 0; i < 3; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i), fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
@ -744,7 +739,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
// left // left
if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) { if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
ComponentColors colors; ComponentColors colors;
_GetComponentColors(COMPONENT_LEFT_BORDER, colors); _GetComponentColors(COMPONENT_LEFT_BORDER, colors, fTopTab);
for (int8 i = 0; i < 3; i++) { for (int8 i = 0; i < 3; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i), fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
@ -764,7 +759,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
// bottom // bottom
if (invalid.Intersects(fBottomBorder)) { if (invalid.Intersects(fBottomBorder)) {
ComponentColors colors; ComponentColors colors;
_GetComponentColors(COMPONENT_BOTTOM_BORDER, colors); _GetComponentColors(COMPONENT_BOTTOM_BORDER, colors, fTopTab);
for (int8 i = 0; i < 3; i++) { for (int8 i = 0; i < 3; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.bottom - i), fDrawingEngine->StrokeLine(BPoint(r.left + i, r.bottom - i),
@ -775,7 +770,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
// right // right
if (invalid.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) { if (invalid.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) {
ComponentColors colors; ComponentColors colors;
_GetComponentColors(COMPONENT_RIGHT_BORDER, colors); _GetComponentColors(COMPONENT_RIGHT_BORDER, colors, fTopTab);
for (int8 i = 0; i < 3; i++) { for (int8 i = 0; i < 3; i++) {
fDrawingEngine->StrokeLine(BPoint(r.right - i, r.top + i), fDrawingEngine->StrokeLine(BPoint(r.right - i, r.top + i),
@ -790,7 +785,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
{ {
// TODO: Draw the borders individually! // TODO: Draw the borders individually!
ComponentColors colors; ComponentColors colors;
_GetComponentColors(COMPONENT_LEFT_BORDER, colors); _GetComponentColors(COMPONENT_LEFT_BORDER, colors, fTopTab);
fDrawingEngine->StrokeRect(r, colors[5]); fDrawingEngine->StrokeRect(r, colors[5]);
break; break;
@ -806,7 +801,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
r = fResizeRect; r = fResizeRect;
ComponentColors colors; ComponentColors colors;
_GetComponentColors(COMPONENT_RESIZE_CORNER, colors); _GetComponentColors(COMPONENT_RESIZE_CORNER, colors, fTopTab);
switch ((int)fTopTab->look) { switch ((int)fTopTab->look) {
case B_DOCUMENT_WINDOW_LOOK: case B_DOCUMENT_WINDOW_LOOK:
@ -1534,15 +1529,19 @@ DefaultDecorator::GetComponentColors(Component component, uint8 highlight,
case COMPONENT_RESIZE_CORNER: case COMPONENT_RESIZE_CORNER:
default: default:
_colors[0] = kFrameColors[0]; _colors[0] = kFrameColors[0];
_colors[1] = kFrameColors[1]; //_colors[1] = kFrameColors[1];
if (tab && tab->buttonFocus) { if (tab && tab->buttonFocus) {
_colors[2] = kFocusFrameColors[0]; _colors[1] = kFocusFrameColorBevel;
_colors[3] = kFocusFrameColors[1]; _colors[2] = kFocusFrameColor;
_colors[3] = kFocusFrameColor;
_colors[4] = kFocusFrameColorDark;
} else { } else {
_colors[2] = kNonFocusFrameColors[0]; _colors[1] = kFocusFrameColorBevel;
_colors[3] = kNonFocusFrameColors[1]; _colors[2] = kNonFocusFrameColor;
_colors[3] = kNonFocusFrameColor;
_colors[4] = kNonFocusFrameColorDark;
} }
_colors[4] = kFrameColors[2]; //_colors[4] = kFrameColors[2];
_colors[5] = kFrameColors[3]; _colors[5] = kFrameColors[3];
// for the resize-border highlight dye everything bluish. // for the resize-border highlight dye everything bluish.

View File

@ -186,8 +186,10 @@ private:
void _CalculateTabsRegion(); void _CalculateTabsRegion();
protected: protected:
static const rgb_color kFrameColors[4]; static const rgb_color kFrameColors[4];
static const rgb_color kFocusFrameColors[2];
static const rgb_color kNonFocusFrameColors[2]; const rgb_color kFocusFrameColor;
const rgb_color kFocusFrameColorBevel;
const rgb_color kFocusFrameColorDark;
const rgb_color kFocusTabColor; const rgb_color kFocusTabColor;
const rgb_color kFocusTabColorLight; const rgb_color kFocusTabColorLight;
@ -195,6 +197,10 @@ protected:
const rgb_color kFocusTabColorShadow; const rgb_color kFocusTabColorShadow;
const rgb_color kFocusTextColor; const rgb_color kFocusTextColor;
const rgb_color kNonFocusFrameColor;
const rgb_color kNonFocusFrameColorBevel;
const rgb_color kNonFocusFrameColorDark;
const rgb_color kNonFocusTabColor; const rgb_color kNonFocusTabColor;
const rgb_color kNonFocusTabColorLight; const rgb_color kNonFocusTabColorLight;
const rgb_color kNonFocusTabColorBevel; const rgb_color kNonFocusTabColorBevel;