Ticket #5801: Workspace_color_1.diff

File Workspace_color_1.diff, 15.9 KB (added by jscipione, 13 years ago)

Adds constants to set the window border to the Appearance Preferences panel and updates the default decorator to use those constants to color the window frame

  • headers/os/interface/InterfaceDefs.h

    diff --git headers/os/interface/InterfaceDefs.h headers/os/interface/InterfaceDefs.h
    index 40f2d89..0f85a48 100644
    enum color_which {  
    322322    B_WINDOW_TAB_COLOR = 3,
    323323    B_WINDOW_TEXT_COLOR = 22,
    324324    B_WINDOW_INACTIVE_TAB_COLOR = 23,
    325     B_WINDOW_INACTIVE_TEXT_COLOR = 24
     325    B_WINDOW_INACTIVE_TEXT_COLOR = 24,
     326
     327    B_WINDOW_BORDER_COLOR = 25,
     328    B_WINDOW_INACTIVE_BORDER_COLOR = 26
    326329};
    327330
    328331
  • headers/private/app/ServerReadOnlyMemory.h

    diff --git headers/private/app/ServerReadOnlyMemory.h headers/private/app/ServerReadOnlyMemory.h
    index e0bb817..477ee4c 100644
    static inline int32  
    2626color_which_to_index(color_which which)
    2727{
    2828    // NOTE: this must be kept in sync with InterfaceDefs.h color_which!
    29     if (which <= B_WINDOW_INACTIVE_TEXT_COLOR)
     29    if (which <= B_WINDOW_INACTIVE_BORDER_COLOR)
    3030        return which - 1;
    3131    if (which >= B_SUCCESS_COLOR && which <= B_FAILURE_COLOR)
    32         return which - B_SUCCESS_COLOR + B_WINDOW_INACTIVE_TEXT_COLOR;
     32        return which - B_SUCCESS_COLOR + B_WINDOW_INACTIVE_BORDER_COLOR;
    3333
    3434    return -1;
    3535}
    static inline color_which  
    3838index_to_color_which(int32 index)
    3939{
    4040    if (index >= 0 && index < kNumColors) {
    41         if ((color_which)index < B_WINDOW_INACTIVE_TEXT_COLOR)
     41        if ((color_which)index < B_WINDOW_INACTIVE_BORDER_COLOR)
    4242            return (color_which)(index + 1);
    4343        else
    44             return (color_which)(index + B_SUCCESS_COLOR - B_WINDOW_INACTIVE_TEXT_COLOR);
     44            return (color_which)(index + B_SUCCESS_COLOR - B_WINDOW_INACTIVE_BORDER_COLOR);
    4545    }
    4646
    4747    return (color_which)-1;
  • src/bin/WindowShade.cpp

    diff --git src/bin/WindowShade.cpp src/bin/WindowShade.cpp
    index 9b5bc31..dcca8d2 100644
    static struct option const kLongOptions[] = {  
    6363    I(window_text_color, B_WINDOW_TEXT_COLOR),
    6464    I(window_inactive_tab_color, B_WINDOW_INACTIVE_TAB_COLOR),
    6565    I(window_inactive_text_color, B_WINDOW_INACTIVE_TEXT_COLOR),
     66    I(window_border_color, B_WINDOW_BORDER_COLOR),
     67    I(window_inactive_border_color, B_WINDOW_INACTIVE_BORDER_COLOR),
    6668    {"sum", required_argument, 0, 's'},
    6769    {"refresh", no_argument, 0, 'r'},
    6870    {"help", no_argument, 0, 'h'},
  • src/kits/interface/InterfaceDefs.cpp

    diff --git src/kits/interface/InterfaceDefs.cpp src/kits/interface/InterfaceDefs.cpp
    index ed61c2f..1c53538 100644
    static const rgb_color _kDefaultColors[kNumColors] = {  
    9494    {0, 0, 0, 255},         // B_WINDOW_TEXT_COLOR
    9595    {232, 232, 232, 255},   // B_WINDOW_INACTIVE_TAB_COLOR
    9696    {80, 80, 80, 255},      // B_WINDOW_INACTIVE_TEXT_COLOR
     97    {224, 224, 224, 255},   // B_WINDOW_BORDER_COLOR
     98    {232, 232, 232, 255},   // B_WINDOW_INACTIVE_BORDER_COLOR
    9799    // 100...
    98100    {0, 255, 0, 255},       // B_SUCCESS_COLOR
    99101    {255, 0, 0, 255},       // B_FAILURE_COLOR
  • src/preferences/appearance/ColorSet.cpp

    diff --git src/preferences/appearance/ColorSet.cpp src/preferences/appearance/ColorSet.cpp
    index 653eba5..9840693 100644
    static ColorDescription sColorDescriptionTable[] =  
    5252    { B_WINDOW_TEXT_COLOR, B_TRANSLATE_MARK("Window tab text") },
    5353    { B_WINDOW_INACTIVE_TAB_COLOR, B_TRANSLATE_MARK("Inactive window tab") },
    5454    { B_WINDOW_INACTIVE_TEXT_COLOR,
    55         B_TRANSLATE_MARK("Inactive window tab text") }
     55        B_TRANSLATE_MARK("Inactive window tab text") },
     56    { B_WINDOW_BORDER_COLOR, B_TRANSLATE_MARK("Window border") },
     57    { B_WINDOW_INACTIVE_BORDER_COLOR,
     58        B_TRANSLATE_MARK("Inactive window border") }
    5659};
    5760
    5861const int32 sColorDescriptionCount = sizeof(sColorDescriptionTable)
    ColorSet::DefaultColorSet(void)  
    134137    set.fColors[B_WINDOW_TEXT_COLOR] = make_color(0, 0, 0);
    135138    set.fColors[B_WINDOW_INACTIVE_TAB_COLOR] = make_color(232, 232, 232);
    136139    set.fColors[B_WINDOW_INACTIVE_TEXT_COLOR] = make_color(80, 80, 80);
     140    set.fColors[B_WINDOW_BORDER_COLOR] = make_color(224, 224, 224);
     141    set.fColors[B_WINDOW_INACTIVE_BORDER_COLOR] = make_color(232, 232, 232);
    137142
    138143    return set;
    139144}
  • src/servers/app/WorkspacesView.cpp

    diff --git src/servers/app/WorkspacesView.cpp src/servers/app/WorkspacesView.cpp
    index 76045b8..c20e12c 100644
     
    1515#include "Desktop.h"
    1616#include "DrawingEngine.h"
    1717#include "DrawState.h"
     18#include "InterfaceDefs.h"
    1819#include "ServerApp.h"
    1920#include "Window.h"
    2021#include "Workspace.h"
    WorkspacesView::_WindowFrame(const BRect& workspaceFrame,  
    166167void
    167168WorkspacesView::_DrawWindow(DrawingEngine* drawingEngine,
    168169    const BRect& workspaceFrame, const BRect& screenFrame, ::Window* window,
    169     BPoint windowPosition, BRegion& backgroundRegion, bool active)
     170    BPoint windowPosition, BRegion& backgroundRegion, bool workspaceActive)
    170171{
    171172    if (window->Feel() == kDesktopWindowFeel || window->IsHidden())
    172173        return;
    WorkspacesView::_DrawWindow(DrawingEngine* drawingEngine,  
    188189    rgb_color activeTabColor = (rgb_color){ 255, 203, 0, 255 };
    189190    rgb_color inactiveTabColor = (rgb_color){ 232, 232, 232, 255 };
    190191    rgb_color navColor = (rgb_color){ 0, 0, 229, 255 };
     192    rgb_color activeFrameColor = (rgb_color){ 180, 180, 180, 255 };
     193    rgb_color inactiveFrameColor = (rgb_color){ 180, 180, 180, 255 };
    191194    if (decorator != NULL) {
    192195        activeTabColor = decorator->UIColor(B_WINDOW_TAB_COLOR);
    193196        inactiveTabColor = decorator->UIColor(B_WINDOW_INACTIVE_TAB_COLOR);
    194197        navColor = decorator->UIColor(B_NAVIGATION_BASE_COLOR);
     198        activeFrameColor = decorator->UIColor(B_WINDOW_BORDER_COLOR);
     199        inactiveFrameColor = decorator->UIColor(B_WINDOW_INACTIVE_BORDER_COLOR);
    195200    }
    196     // TODO: let decorator do this!
    197     rgb_color frameColor = (rgb_color){ 180, 180, 180, 255 };
     201
    198202    rgb_color white = (rgb_color){ 255, 255, 255, 255 };
    199203
    200204    rgb_color tabColor = inactiveTabColor;
    201     if (window->IsFocus())
     205    rgb_color frameColor = inactiveFrameColor;
     206    if (window->IsFocus()) {
    202207        tabColor = activeTabColor;
     208        frameColor = activeFrameColor;
     209    }
    203210
    204     if (!active) {
     211    if (!workspaceActive) {
    205212        _DarkenColor(tabColor);
    206213        _DarkenColor(frameColor);
    207214        _DarkenColor(white);
    208215    }
    209     if (window == fSelectedWindow) {
    210         frameColor = navColor;
    211     }
    212216
    213217    if (tabFrame.left < frame.left)
    214218        tabFrame.left = frame.left;
    WorkspacesView::_DrawWorkspace(DrawingEngine* drawingEngine,  
    274278    BRect rect = _WorkspaceAt(index);
    275279
    276280    Workspace workspace(*Window()->Desktop(), index);
    277     bool active = workspace.IsCurrent();
    278     if (active) {
     281    bool workspaceActive = workspace.IsCurrent();
     282    if (workspaceActive) {
    279283        // draw active frame
    280284        rgb_color black = (rgb_color){ 0, 0, 0, 255 };
    281285        drawingEngine->StrokeRect(rect, black);
    WorkspacesView::_DrawWorkspace(DrawingEngine* drawingEngine,  
    287291    rect.InsetBy(1, 1);
    288292
    289293    rgb_color color = workspace.Color();
    290     if (!active)
     294    if (!workspaceActive)
    291295        _DarkenColor(color);
    292296
    293297    // draw windows
    WorkspacesView::_DrawWorkspace(DrawingEngine* drawingEngine,  
    317321    BPoint leftTop;
    318322    while (workspace.GetPreviousWindow(window, leftTop) == B_OK) {
    319323        _DrawWindow(drawingEngine, rect, screenFrame, window,
    320             leftTop, backgroundRegion, active);
     324            leftTop, backgroundRegion, workspaceActive);
    321325    }
    322326
    323327    // draw background
  • src/servers/app/WorkspacesView.h

    diff --git src/servers/app/WorkspacesView.h src/servers/app/WorkspacesView.h
    index a34b54a..179e6cb 100644
    private:  
    4545            void    _DrawWindow(DrawingEngine* drawingEngine,
    4646                        const BRect& workspaceFrame, const BRect& screenFrame,
    4747                        ::Window* window, BPoint windowPosition,
    48                         BRegion& backgroundRegion, bool active);
     48                        BRegion& backgroundRegion, bool workspaceActive);
    4949            void    _DrawWorkspace(DrawingEngine* drawingEngine,
    5050                        BRegion& redraw, int32 index);
    5151
  • src/servers/app/decorator/DefaultDecorator.cpp

    diff --git src/servers/app/decorator/DefaultDecorator.cpp src/servers/app/decorator/DefaultDecorator.cpp
    index ea93151..05e693d 100644
    const rgb_color DefaultDecorator::kFrameColors[4] = {  
    8787    { 108, 108, 108, 255 }
    8888};
    8989
    90 const rgb_color DefaultDecorator::kFocusFrameColors[2] = {
    91     { 224, 224, 224, 255 },
    92     { 208, 208, 208, 255 }
    93 };
    94 
    95 const rgb_color DefaultDecorator::kNonFocusFrameColors[2] = {
    96     { 232, 232, 232, 255 },
    97     { 232, 232, 232, 255 }
    98 };
    99 
    100 
    10190
    10291// TODO: get rid of DesktopSettings here, and introduce private accessor
    10392//  methods to the Decorator base class
    DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect)  
    10594    :
    10695    Decorator(settings, rect),
    10796    // focus color constants
     97    kFocusFrameColor(settings.UIColor(B_WINDOW_BORDER_COLOR)),
    10898    kFocusTabColor(settings.UIColor(B_WINDOW_TAB_COLOR)),
    10999    kFocusTabColorLight(tint_color(kFocusTabColor,
    110100        (B_LIGHTEN_MAX_TINT + B_LIGHTEN_2_TINT) / 2)),
    DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect)  
    113103        (B_DARKEN_1_TINT + B_NO_TINT) / 2)),
    114104    kFocusTextColor(settings.UIColor(B_WINDOW_TEXT_COLOR)),
    115105    // non-focus color constants
     106    kNonFocusFrameColor(settings.UIColor(B_WINDOW_INACTIVE_BORDER_COLOR)),
    116107    kNonFocusTabColor(settings.UIColor(B_WINDOW_INACTIVE_TAB_COLOR)),
    117108    kNonFocusTabColorLight(tint_color(kNonFocusTabColor,
    118109        (B_LIGHTEN_MAX_TINT + B_LIGHTEN_2_TINT) / 2)),
    DefaultDecorator::TabLocation(int32 tab) const  
    143134{
    144135    DefaultDecorator::Tab* decoratorTab = _TabAt(tab);
    145136    if (decoratorTab == NULL)
    146         return 0.;
     137        return 0.0f;
    147138    return (float)decoratorTab->tabOffset;
    148139}
    149140
    DefaultDecorator::_DrawFrame(BRect invalid)  
    666657            // top
    667658            if (invalid.Intersects(fTopBorder)) {
    668659                ComponentColors colors;
    669                 _GetComponentColors(COMPONENT_TOP_BORDER, colors);
     660                _GetComponentColors(COMPONENT_TOP_BORDER, colors, fTopTab);
    670661
    671662                for (int8 i = 0; i < 5; i++) {
    672663                    fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
    DefaultDecorator::_DrawFrame(BRect invalid)  
    686677            // left
    687678            if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
    688679                ComponentColors colors;
    689                 _GetComponentColors(COMPONENT_LEFT_BORDER, colors);
     680                _GetComponentColors(COMPONENT_LEFT_BORDER, colors, fTopTab);
    690681
    691682                for (int8 i = 0; i < 5; i++) {
    692683                    fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
    DefaultDecorator::_DrawFrame(BRect invalid)  
    696687            // bottom
    697688            if (invalid.Intersects(fBottomBorder)) {
    698689                ComponentColors colors;
    699                 _GetComponentColors(COMPONENT_BOTTOM_BORDER, colors);
     690                _GetComponentColors(COMPONENT_BOTTOM_BORDER, colors, fTopTab);
    700691
    701692                for (int8 i = 0; i < 5; i++) {
    702693                    fDrawingEngine->StrokeLine(BPoint(r.left + i, r.bottom - i),
    DefaultDecorator::_DrawFrame(BRect invalid)  
    707698            // right
    708699            if (invalid.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) {
    709700                ComponentColors colors;
    710                 _GetComponentColors(COMPONENT_RIGHT_BORDER, colors);
     701                _GetComponentColors(COMPONENT_RIGHT_BORDER, colors, fTopTab);
    711702
    712703                for (int8 i = 0; i < 5; i++) {
    713704                    fDrawingEngine->StrokeLine(BPoint(r.right - i, r.top + i),
    DefaultDecorator::_DrawFrame(BRect invalid)  
    724715            // top
    725716            if (invalid.Intersects(fTopBorder)) {
    726717                ComponentColors colors;
    727                 _GetComponentColors(COMPONENT_TOP_BORDER, colors);
     718                _GetComponentColors(COMPONENT_TOP_BORDER, colors, fTopTab);
    728719
    729720                for (int8 i = 0; i < 3; i++) {
    730721                    fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
    DefaultDecorator::_DrawFrame(BRect invalid)  
    744735            // left
    745736            if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
    746737                ComponentColors colors;
    747                 _GetComponentColors(COMPONENT_LEFT_BORDER, colors);
     738                _GetComponentColors(COMPONENT_LEFT_BORDER, colors, fTopTab);
    748739
    749740                for (int8 i = 0; i < 3; i++) {
    750741                    fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
    DefaultDecorator::_DrawFrame(BRect invalid)  
    764755            // bottom
    765756            if (invalid.Intersects(fBottomBorder)) {
    766757                ComponentColors colors;
    767                 _GetComponentColors(COMPONENT_BOTTOM_BORDER, colors);
     758                _GetComponentColors(COMPONENT_BOTTOM_BORDER, colors, fTopTab);
    768759
    769760                for (int8 i = 0; i < 3; i++) {
    770761                    fDrawingEngine->StrokeLine(BPoint(r.left + i, r.bottom - i),
    DefaultDecorator::_DrawFrame(BRect invalid)  
    775766            // right
    776767            if (invalid.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) {
    777768                ComponentColors colors;
    778                 _GetComponentColors(COMPONENT_RIGHT_BORDER, colors);
     769                _GetComponentColors(COMPONENT_RIGHT_BORDER, colors, fTopTab);
    779770
    780771                for (int8 i = 0; i < 3; i++) {
    781772                    fDrawingEngine->StrokeLine(BPoint(r.right - i, r.top + i),
    DefaultDecorator::_DrawFrame(BRect invalid)  
    790781        {
    791782            // TODO: Draw the borders individually!
    792783            ComponentColors colors;
    793             _GetComponentColors(COMPONENT_LEFT_BORDER, colors);
     784            _GetComponentColors(COMPONENT_LEFT_BORDER, colors, fTopTab);
    794785
    795786            fDrawingEngine->StrokeRect(r, colors[5]);
    796787            break;
    DefaultDecorator::_DrawFrame(BRect invalid)  
    806797        r = fResizeRect;
    807798
    808799        ComponentColors colors;
    809         _GetComponentColors(COMPONENT_RESIZE_CORNER, colors);
     800        _GetComponentColors(COMPONENT_RESIZE_CORNER, colors, fTopTab);
    810801
    811802        switch ((int)fTopTab->look) {
    812803            case B_DOCUMENT_WINDOW_LOOK:
    DefaultDecorator::GetComponentColors(Component component, uint8 highlight,  
    14991490    DefaultDecorator::Tab* tab = static_cast<DefaultDecorator::Tab*>(_tab);
    15001491    switch (component) {
    15011492        case COMPONENT_TAB:
    1502             _colors[COLOR_TAB_FRAME_LIGHT] = kFrameColors[0];
    1503             _colors[COLOR_TAB_FRAME_DARK] = kFrameColors[3];
     1493            _colors[COLOR_TAB_FRAME_LIGHT]
     1494                = tint_color(kFocusFrameColor, B_DARKEN_2_TINT);
     1495            _colors[COLOR_TAB_FRAME_DARK]
     1496                = tint_color(kFocusFrameColor, B_DARKEN_3_TINT);
    15041497            if (tab && tab->buttonFocus) {
    15051498                _colors[COLOR_TAB] = kFocusTabColor;
    15061499                _colors[COLOR_TAB_LIGHT] = kFocusTabColorLight;
    DefaultDecorator::GetComponentColors(Component component, uint8 highlight,  
    15331526        case COMPONENT_BOTTOM_BORDER:
    15341527        case COMPONENT_RESIZE_CORNER:
    15351528        default:
    1536             _colors[0] = kFrameColors[0];
    1537             _colors[1] = kFrameColors[1];
    15381529            if (tab && tab->buttonFocus) {
    1539                 _colors[2] = kFocusFrameColors[0];
    1540                 _colors[3] = kFocusFrameColors[1];
     1530                _colors[0] = tint_color(kFocusFrameColor, B_DARKEN_2_TINT);
     1531                _colors[1] = tint_color(kFocusFrameColor, B_LIGHTEN_2_TINT);
     1532                _colors[2] = kFocusFrameColor;
     1533                _colors[3] = tint_color(kFocusFrameColor,
     1534                    (B_DARKEN_1_TINT + B_NO_TINT) / 2);
     1535                _colors[4] = tint_color(kFocusFrameColor, B_DARKEN_2_TINT);
     1536                _colors[5] = tint_color(kFocusFrameColor, B_DARKEN_3_TINT);
    15411537            } else {
    1542                 _colors[2] = kNonFocusFrameColors[0];
    1543                 _colors[3] = kNonFocusFrameColors[1];
     1538                _colors[0] = tint_color(kNonFocusFrameColor, B_DARKEN_2_TINT);
     1539                _colors[1] = tint_color(kNonFocusFrameColor, B_LIGHTEN_2_TINT);
     1540                _colors[2] = kNonFocusFrameColor;
     1541                _colors[3] = tint_color(kNonFocusFrameColor,
     1542                    (B_DARKEN_1_TINT + B_NO_TINT) / 2);
     1543                _colors[4] = tint_color(kNonFocusFrameColor, B_DARKEN_2_TINT);
     1544                _colors[5] = tint_color(kNonFocusFrameColor, B_DARKEN_3_TINT);
    15441545            }
    1545             _colors[4] = kFrameColors[2];
    1546             _colors[5] = kFrameColors[3];
    15471546
    15481547            // for the resize-border highlight dye everything bluish.
    15491548            if (highlight == HIGHLIGHT_RESIZE_BORDER) {
  • src/servers/app/decorator/DefaultDecorator.h

    diff --git src/servers/app/decorator/DefaultDecorator.h src/servers/app/decorator/DefaultDecorator.h
    index 89fd663..7f46309 100644
    private:  
    186186            void                _CalculateTabsRegion();
    187187protected:
    188188    static  const rgb_color     kFrameColors[4];
    189     static  const rgb_color     kFocusFrameColors[2];
    190     static  const rgb_color     kNonFocusFrameColors[2];
     189
     190            const rgb_color     kFocusFrameColor;
    191191
    192192            const rgb_color     kFocusTabColor;
    193193            const rgb_color     kFocusTabColorLight;
    protected:  
    195195            const rgb_color     kFocusTabColorShadow;
    196196            const rgb_color     kFocusTextColor;
    197197
     198            const rgb_color     kNonFocusFrameColor;
     199
    198200            const rgb_color     kNonFocusTabColor;
    199201            const rgb_color     kNonFocusTabColorLight;
    200202            const rgb_color     kNonFocusTabColorBevel;