Changeset 963


Ignore:
Timestamp:
Dec 9, 2009, 3:58:28 AM (12 years ago)
Author:
Peter Johansson
Message:

fixes #420 - use same color in blame output as in plots.

Location:
trunk/lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Colors.cc

    r943 r963  
    3737  {
    3838    color_map_[ 0].label="green";
    39     color_map_[ 0].r=  0; color_map_[ 0].g=146; color_map_[ 0].b= 72;
     39    color_map_[ 0].str="009248";
    4040    color_map_[ 1].label="blue";
    41     color_map_[ 1].r= 27; color_map_[ 1].g=117; color_map_[ 1].b=186;
     41    color_map_[ 1].str="1b75ba";
    4242    color_map_[ 2].label="red";
    43     color_map_[ 2].r=189; color_map_[ 2].g= 32; color_map_[ 2].b= 46;
     43    color_map_[ 2].str="bd202e";
    4444    color_map_[ 3].label="grey";
    45     color_map_[ 3].r=131; color_map_[ 3].g=131; color_map_[ 3].b=131;
     45    color_map_[ 3].str="838383";
    4646    color_map_[ 4].label="orange";
    47     color_map_[ 4].r=245; color_map_[ 4].g=145; color_map_[ 4].b= 32;
     47    color_map_[ 4].str="f59120";
    4848    color_map_[ 5].label="brown";
    49     color_map_[ 5].r=117; color_map_[ 5].g= 77; color_map_[ 5].b= 41;
     49    color_map_[ 5].str="754d29";
    5050    color_map_[ 6].label="cyan";
    51     color_map_[ 6].r= 40; color_map_[ 6].g=170; color_map_[ 6].b=225;
     51    color_map_[ 6].str="28aae1";
    5252    color_map_[ 7].label="lime";
    53     color_map_[ 7].r=213; color_map_[ 7].g=221; color_map_[ 7].b= 38;
     53    color_map_[ 7].str="d5dd26";
    5454    color_map_[ 8].label="purple";
    55     color_map_[ 8].r=143; color_map_[ 8].g= 40; color_map_[ 8].b=140;
     55    color_map_[ 8].str="8f288c";
    5656    color_map_[ 9].label="lgrey";
    57     color_map_[ 9].r=220; color_map_[ 9].g=220; color_map_[ 9].b=220;
     57    color_map_[ 9].str="dcdcdc";
    5858    color_map_[10].label="lbrown";
    59     color_map_[10].r=194; color_map_[10].g=151; color_map_[10].b=106;
     59    color_map_[10].str="c2976a";
    6060    color_map_[11].label="pink";
    61     color_map_[11].r=230; color_map_[11].g=125; color_map_[11].b=230;
     61    color_map_[11].str="e67de6";
    6262    color_map_[12].label="black";
    63     color_map_[12].r=  0; color_map_[12].g=  0; color_map_[12].b=  0;
     63    color_map_[12].str="000000";
     64    // calculate corresponding rgb values
     65    for (std::vector<color>::iterator col = color_map_.begin();
     66         col!=color_map_.end(); ++col) {
     67      str2rgb(col->str, col->r, col->g, col->b);
     68    }
    6469
    6570    typedef std::map<std::string, std::string> ACmap;
     
    7378      c.label=i->first;
    7479      str2rgb(i->second, c.r, c.g, c.b);
     80      c.str = i->second;
    7581      next_color_=color_map_.insert(next_color_,c);
    7682      author_map_.insert(std::make_pair(c.label, next_color_++));
     
    7985
    8086
    81   void Colors::get_color(const std::string& label, unsigned char& r,
    82                            unsigned char& g, unsigned char& b)
     87  const std::string& Colors::color_str(const std::string& label)
     88  {
     89    return get_color(label).str;
     90  }
     91
     92
     93  const Colors::color& Colors::get_color(const std::string& label)
    8394  {
    8495    std::map<std::string,std::vector<color>::iterator>::iterator i;
     
    91102        next_color_=color_map_.begin();
    92103    }
    93     r = i->second->r;
    94     g = i->second->g;
    95     b = i->second->b;
     104    return *(i->second);
     105  }
     106
     107
     108  void Colors::get_color(const std::string& label, unsigned char& r,
     109                           unsigned char& g, unsigned char& b)
     110  {
     111    const color& col(get_color(label));
     112    r = col.r;
     113    g = col.g;
     114    b = col.b;
    96115  }
    97116
  • trunk/lib/Colors.h

    r944 r963  
    4343
    4444    /**
     45       Same as get_color(4) but color is returned as a hexadecimal
     46       string rather than in rgb.
     47
     48       \return color string associated with label
     49     */
     50    const std::string& color_str(const std::string& label);
     51
     52    /**
    4553       \brief Get RGB color for \a label
    4654
     
    7482      std::string label;
    7583      unsigned char r,g,b;
     84      std::string str;
    7685    };
     86
     87    const color& get_color(const std::string& label);
    7788
    7889    std::map<std::string, std::vector<color>::iterator> author_map_;
  • trunk/lib/File.cc

    r938 r963  
    2323
    2424#include "Alias.h"
     25#include "Colors.h"
    2526#include "Configuration.h"
    2627#include "Date.h"
     
    290291      hs << Date(blame.date())("%d %b %y");
    291292      os << "</font></td>\n<td class=\"author\">";
    292       std::string author_color =
    293         Configuration::instance().author_str_color(blame.author());
    294       if (!author_color.empty())
    295         os << "<font color=\"#" << author_color << "\">";
     293      const std::string& author_color =
     294        Colors::instance().color_str(blame.author());
     295      assert(!author_color.empty());
     296      os << "<font color=\"#" << author_color << "\">";
    296297      hs << blame.author();
    297298      os << "</td>\n<td class=\"";
Note: See TracChangeset for help on using the changeset viewer.