Ticket #8054: Control_mark_color_1.diff

File Control_mark_color_1.diff, 7.8 KB (added by jscipione, 13 years ago)

This patch allows the user to set the mark color in the Appearance preferences fixing a TODO. It also normalizes the default colors as defined in InterfaceDefs.cpp and in the Appearance Preferences.

  • headers/os/interface/ControlLook.h

    diff --git headers/os/interface/ControlLook.h headers/os/interface/ControlLook.h
    index b832a1d..f766e08 100644
    protected:  
    330330                                        = B_HORIZONTAL) const;
    331331
    332332            bool                _RadioButtonAndCheckBoxMarkColor(
    333                                     const rgb_color& base, rgb_color& color,
    334                                     uint32 flags) const;
     333                                    const rgb_color& base,
     334                                    rgb_color& markColor, uint32 flags) const;
    335335
    336336            void                _DrawRoundBarCorner(BView* view, BRect& rect,
    337337                                    const BRect& updateRect,
  • headers/os/interface/InterfaceDefs.h

    diff --git headers/os/interface/InterfaceDefs.h headers/os/interface/InterfaceDefs.h
    index 40f2d89..f1082b6 100644
    enum color_which {  
    294294    B_CONTROL_TEXT_COLOR = 14,
    295295    B_CONTROL_BORDER_COLOR = 15,
    296296    B_CONTROL_HIGHLIGHT_COLOR = 16,
     297    B_CONTROL_MARK_COLOR = 25,
    297298    B_NAVIGATION_BASE_COLOR = 4,
    298299    B_NAVIGATION_PULSE_COLOR = 17,
    299300    B_SHINE_COLOR = 18,
  • headers/private/app/ServerReadOnlyMemory.h

    diff --git headers/private/app/ServerReadOnlyMemory.h headers/private/app/ServerReadOnlyMemory.h
    index e0bb817..523056b 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_CONTROL_MARK_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_CONTROL_MARK_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_CONTROL_MARK_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_CONTROL_MARK_COLOR);
    4545    }
    4646
    4747    return (color_which)-1;
  • src/bin/WindowShade.cpp

    diff --git src/bin/WindowShade.cpp src/bin/WindowShade.cpp
    index 9b5bc31..a0c4578 100644
    static struct option const kLongOptions[] = {  
    4343    I(control_text_color, B_CONTROL_TEXT_COLOR),
    4444    I(control_border_color, B_CONTROL_BORDER_COLOR),
    4545    I(control_highlight_color, B_CONTROL_HIGHLIGHT_COLOR),
     46    I(control_mark_color, B_CONTROL_MARK_COLOR),
    4647    I(navigation_base_color, B_NAVIGATION_BASE_COLOR),
    4748    I(navigation_pulse_color, B_NAVIGATION_PULSE_COLOR),
    4849    I(shine_color, B_SHINE_COLOR),
  • src/kits/interface/ControlLook.cpp

    diff --git src/kits/interface/ControlLook.cpp src/kits/interface/ControlLook.cpp
    index 3f01f5c..23ee729 100644
     
    88
    99#include <Control.h>
    1010#include <GradientLinear.h>
     11#include <InterfaceDefs.h>
    1112#include <Region.h>
    1213#include <Shape.h>
    1314#include <String.h>
    BControlLook::_MakeGlossyGradient(BGradientLinear& gradient, const BRect& rect,  
    21812182
    21822183bool
    21832184BControlLook::_RadioButtonAndCheckBoxMarkColor(const rgb_color& base,
    2184     rgb_color& color, uint32 flags) const
     2185    rgb_color& markColor, uint32 flags) const
    21852186{
    21862187    if ((flags & (B_ACTIVATED | B_CLICKED)) == 0) {
    21872188        // no mark to be drawn at all
    21882189        return false;
    21892190    }
    21902191
    2191     // TODO: Get from UI settings
    2192     color.red = 27;
    2193     color.green = 82;
    2194     color.blue = 140;
     2192    markColor = ui_color(B_CONTROL_MARK_COLOR);
    21952193
    21962194    float mix = 1.0;
    21972195
    BControlLook::_RadioButtonAndCheckBoxMarkColor(const rgb_color& base,  
    22102208        // simply activated
    22112209    }
    22122210
    2213     color.red = uint8(color.red * mix + base.red * (1.0 - mix));
    2214     color.green = uint8(color.green * mix + base.green * (1.0 - mix));
    2215     color.blue = uint8(color.blue * mix + base.blue * (1.0 - mix));
     2211    markColor.red = uint8(markColor.red * mix + base.red * (1.0 - mix));
     2212    markColor.green = uint8(markColor.green * mix + base.green * (1.0 - mix));
     2213    markColor.blue = uint8(markColor.blue * mix + base.blue * (1.0 - mix));
    22162214
    22172215    return true;
    22182216}
  • src/kits/interface/InterfaceDefs.cpp

    diff --git src/kits/interface/InterfaceDefs.cpp src/kits/interface/InterfaceDefs.cpp
    index ed61c2f..82ca87d 100644
    static const rgb_color _kDefaultColors[kNumColors] = {  
    7373    {216, 216, 216, 255},   // B_PANEL_BACKGROUND_COLOR
    7474    {216, 216, 216, 255},   // B_MENU_BACKGROUND_COLOR
    7575    {255, 203, 0, 255},     // B_WINDOW_TAB_COLOR
    76     {0, 0, 229, 255},       // B_KEYBOARD_NAVIGATION_COLOR
     76    {0, 0, 229, 255},       // B_NAVIGATION_BASE_COLOR
     77                            // (B_KEYBOARD_NAVIGATION_COLOR)
    7778    {51, 102, 152, 255},    // B_DESKTOP_COLOR
    7879    {153, 153, 153, 255},   // B_MENU_SELECTED_BACKGROUND_COLOR
    7980    {0, 0, 0, 255},         // B_MENU_ITEM_TEXT_COLOR
    static const rgb_color _kDefaultColors[kNumColors] = {  
    8990    {0, 0, 0, 255},         // B_NAVIGATION_PULSE_COLOR
    9091    {255, 255, 255, 255},   // B_SHINE_COLOR
    9192    {0, 0, 0, 255},         // B_SHADOW_COLOR
    92     {255, 255, 216, 255},   // B_TOOLTIP_BACKGROUND_COLOR
    93     {0, 0, 0, 255},         // B_TOOLTIP_TEXT_COLOR
     93    {255, 255, 216, 255},   // B_TOOL_TIP_BACKGROUND_COLOR
     94    {0, 0, 0, 255},         // B_TOOL_TIP_TEXT_COLOR
    9495    {0, 0, 0, 255},         // B_WINDOW_TEXT_COLOR
    9596    {232, 232, 232, 255},   // B_WINDOW_INACTIVE_TAB_COLOR
    9697    {80, 80, 80, 255},      // B_WINDOW_INACTIVE_TEXT_COLOR
     98    {27, 82, 140, 255},     // B_CONTROL_MARK_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..53d696b 100644
     
    1313#include <Directory.h>
    1414#include <Entry.h>
    1515#include <File.h>
     16#include <GraphicsDefs.h>
    1617#include <InterfaceDefs.h>
    1718#include <Locale.h>
    1819#include <Message.h>
    static ColorDescription sColorDescriptionTable[] =  
    3233    { B_CONTROL_TEXT_COLOR, B_TRANSLATE_MARK("Control text") },
    3334    { B_CONTROL_BORDER_COLOR, B_TRANSLATE_MARK("Control border") },
    3435    { B_CONTROL_HIGHLIGHT_COLOR, B_TRANSLATE_MARK("Control highlight") },
     36    { B_CONTROL_MARK_COLOR, B_TRANSLATE_MARK("Control mark") },
    3537    { B_NAVIGATION_BASE_COLOR, B_TRANSLATE_MARK("Navigation base") },
    3638    { B_NAVIGATION_PULSE_COLOR, B_TRANSLATE_MARK("Navigation pulse") },
    3739    { B_SHINE_COLOR, B_TRANSLATE_MARK("Shine") },
    ColorSet::DefaultColorSet(void)  
    111113    ColorSet set;
    112114    set.fColors[B_PANEL_BACKGROUND_COLOR] = make_color(216, 216, 216);
    113115    set.fColors[B_PANEL_TEXT_COLOR] = make_color(0, 0, 0);
    114     set.fColors[B_DOCUMENT_BACKGROUND_COLOR] = make_color(255,255, 255);
     116    set.fColors[B_DOCUMENT_BACKGROUND_COLOR] = make_color(255, 255, 255);
    115117    set.fColors[B_DOCUMENT_TEXT_COLOR] = make_color(0, 0, 0);
    116118    set.fColors[B_CONTROL_BACKGROUND_COLOR] = make_color(245, 245, 245);
    117119    set.fColors[B_CONTROL_TEXT_COLOR] = make_color(0, 0, 0);
    118120    set.fColors[B_CONTROL_BORDER_COLOR] = make_color(0, 0, 0);
    119     set.fColors[B_CONTROL_HIGHLIGHT_COLOR] = make_color(102, 152, 203);
     121    set.fColors[B_CONTROL_HIGHLIGHT_COLOR] = make_color(153, 153, 153);
     122    set.fColors[B_CONTROL_MARK_COLOR] = make_color(27, 82, 140);
    120123    set.fColors[B_NAVIGATION_BASE_COLOR] = make_color(0, 0, 229);
    121124    set.fColors[B_NAVIGATION_PULSE_COLOR] = make_color(0, 0, 0);
    122125    set.fColors[B_SHINE_COLOR] = make_color(255, 255, 255);
    ColorSet::DefaultColorSet(void)  
    124127    set.fColors[B_MENU_BACKGROUND_COLOR] = make_color(216, 216, 216);
    125128    set.fColors[B_MENU_SELECTED_BACKGROUND_COLOR] = make_color(115, 120, 184);
    126129    set.fColors[B_MENU_ITEM_TEXT_COLOR] = make_color(0, 0, 0);
    127     set.fColors[B_MENU_SELECTED_ITEM_TEXT_COLOR] = make_color(255, 255, 255);
     130    set.fColors[B_MENU_SELECTED_ITEM_TEXT_COLOR] = make_color(0, 0, 0);
    128131    set.fColors[B_MENU_SELECTED_BORDER_COLOR] = make_color(0, 0, 0);
    129132    set.fColors[B_TOOL_TIP_BACKGROUND_COLOR] = make_color(255, 255, 0);
    130133    set.fColors[B_TOOL_TIP_TEXT_COLOR] = make_color(0, 0, 0);