Changeset d451ded122128ae7642f03735ebc062afc1b7e9d

Show
Ignore:
Timestamp:
10/24/09 16:58:54 (4 years ago)
Author:
Armin Burgmeier <armin@…>
Parents:
100e34cbc1b89eb7b0aa267f90358ed8f0b7d84d
Children:
44f4113f1630461cc00e8ad6aae3d5720fa585e5
git-committer:
Armin Burgmeier <armin@arbur.net> / 2009-10-24T16:58:54Z+0200
Message:

Show user color indicator in user list

2009-10-24 Armin Burgmeier <armin@…>

  • icons/hicolor/scalable/status/user-color-indicator.svg: Removed blur, so that rsvg renders it correctly.
  • icons/hicolor/scalable/Makefile.am:
  • icons/hicolor/48x48/Makefile.am:
  • icons/hicolor/48x48/status/Makefile.am:
  • icons/hicolor/scalable/status/Makefile.am:
  • configure.ac: Added the new item to the build system.
  • code/util/color.hpp:
  • code/util/color.cpp: Added public rgb_to_hsv() and hsv_to_rgb() functions.
  • code/core/iconmanager.hpp:
  • code/core/iconmanager.cpp: Added a stock item for the user color indicator.
  • code/core/userlist.cpp: Show the user color indicator for the user color instead of a boring monochromatic square.
Files:
2 added
10 modified

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r100e34c rd451ded  
     12009-10-24  Armin Burgmeier  <armin@arbur.net> 
     2 
     3        * icons/hicolor/scalable/status/user-color-indicator.svg: Removed 
     4        blur, so that rsvg renders it correctly. 
     5 
     6        * icons/hicolor/scalable/Makefile.am: 
     7        * icons/hicolor/48x48/Makefile.am: 
     8        * icons/hicolor/48x48/status/Makefile.am: 
     9        * icons/hicolor/scalable/status/Makefile.am: 
     10        * configure.ac: Added the new item to the build system. 
     11 
     12        * code/util/color.hpp: 
     13        * code/util/color.cpp: Added public rgb_to_hsv() and hsv_to_rgb() 
     14        functions. 
     15 
     16        * code/core/iconmanager.hpp: 
     17        * code/core/iconmanager.cpp: Added a stock item for the user color 
     18        indicator. 
     19 
     20        * code/core/userlist.cpp: Show the user color indicator for the user 
     21        color instead of a boring monochromatic square. 
     22 
    1232009-10-24  Benjamin Herr  <ben@0x539.de> 
    224 
  • code/core/iconmanager.cpp

    rca24222 rd451ded  
    2626Gtk::StockID Gobby::IconManager::STOCK_DOCLIST("gobby-document-list"); 
    2727Gtk::StockID Gobby::IconManager::STOCK_SAVE_ALL("gobby-save-all"); 
     28Gtk::StockID Gobby::IconManager::STOCK_USER_COLOR_INDICATOR( 
     29        "gobby-user-color-indicator"); 
    2830 
    2931// TODO: The save-all icon does not match the save icon for toolbar 
     
    4850        Gtk::StockItem save_all_item(STOCK_SAVE_ALL, _("Save All")); 
    4951 
     52        Gtk::IconSource user_color_indicator_source; 
     53        user_color_indicator_source.set_icon_name("user-color-indicator"); 
     54        m_is_user_color_indicator.add_source(user_color_indicator_source); 
     55        Gtk::StockItem user_color_indicator_item(STOCK_USER_COLOR_INDICATOR, 
     56                                                 _("User Color Indicator")); 
     57        m_icon_factory->add(STOCK_USER_COLOR_INDICATOR, 
     58                            m_is_user_color_indicator); 
     59 
    5060        m_icon_factory->add_default(); 
    5161} 
  • code/core/iconmanager.hpp

    rca24222 rd451ded  
    3333                static Gtk::StockID STOCK_DOCLIST; 
    3434                static Gtk::StockID STOCK_SAVE_ALL; 
     35                static Gtk::StockID STOCK_USER_COLOR_INDICATOR; 
    3536 
    3637                IconManager(); 
     
    4041                Gtk::IconSet m_is_doclist; 
    4142                Gtk::IconSet m_is_save_all; 
     43                Gtk::IconSet m_is_user_color_indicator; 
    4244 
    4345                Glib::RefPtr<Gtk::IconFactory> m_icon_factory; 
  • code/core/userlist.cpp

    r6b79c69 rd451ded  
    1818 
    1919#include "core/userlist.hpp" 
     20#include "core/iconmanager.hpp" 
    2021 
    2122#include "util/i18n.hpp" 
     
    3738        } 
    3839 
    39         void draw_pixel(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf, int x, int y, 
    40                         const Gdk::Color& color) 
    41         { 
    42                 guint8* pixels = pixbuf->get_pixels(); 
    43                 guint8* pixel = pixels + y * pixbuf->get_rowstride() + 
    44                                          x * pixbuf->get_n_channels(); 
    45                 *pixel++ = (color.get_red() >> 8); 
    46                 *pixel++ = (color.get_green() >> 8); 
    47                 *pixel++ = (color.get_blue() >> 8); 
    48         } 
    49  
    50         void draw_vline(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf, int x, 
    51                         int y1, int y2, const Gdk::Color& color) 
    52         { 
    53                 for(int y = y1; y < y2; ++ y) 
    54                         draw_pixel(pixbuf, x, y, color); 
    55         } 
    56  
    57         void draw_hline(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf, int x1, 
    58                         int x2, int y, const Gdk::Color& color) 
    59         { 
    60                 for(int x = x1; x < x2; ++ x) 
    61                         draw_pixel(pixbuf, x, y, color); 
    62         } 
    63  
    64         void draw_rectangle(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf, int x1, 
    65                             int y1, int x2, int y2, const Gdk::Color& color) 
    66         { 
    67                 for(int y = y1; y < y2; ++ y) 
    68                         for(int x = x1; x < x2; ++ x) 
    69                                 draw_pixel(pixbuf, x, y, color); 
    70         } 
    71  
    72         Glib::RefPtr<Gdk::Pixbuf> generate_user_color_pixbuf(gdouble hue) 
    73         { 
    74                 // TODO: Play around with hue, saturation and value to get 
    75                 // a cool effect instead of a monochromatic icon. 
    76                 Gdk::Color color = Gobby::hue_to_gdk_color(hue, 0.35, 1.0); 
    77                 Gdk::Color black("#000000"); 
    78  
    79                 int width, height; 
    80                 Gtk::IconSize::lookup(Gtk::ICON_SIZE_MENU, width, height); 
    81  
    82                 Glib::RefPtr<Gdk::Pixbuf> pixbuf( 
    83                         Gdk::Pixbuf::create( 
    84                                 Gdk::COLORSPACE_RGB, false, 8, 
    85                                 width, height)); 
    86  
    87                 draw_hline(pixbuf, 0, width, 0, black); 
    88                 draw_hline(pixbuf, 0, width, height - 1, black); 
    89                 draw_vline(pixbuf, 0, 1, height - 1, black); 
    90                 draw_vline(pixbuf, width-1, 1, height - 1, black); 
    91                 draw_rectangle(pixbuf, 1, 1, width - 1, height - 1, color); 
     40        Glib::RefPtr<Gdk::Pixbuf> generate_user_color_pixbuf(Gtk::Widget& w, 
     41                                                             gdouble hue) 
     42        { 
     43                Glib::RefPtr<Gdk::Pixbuf> pixbuf = w.render_icon( 
     44                        Gobby::IconManager::STOCK_USER_COLOR_INDICATOR, 
     45                        Gtk::ICON_SIZE_MENU); 
     46 
     47                // pixbuf is shared, though we want to mess with it here 
     48                pixbuf = pixbuf->copy(); 
     49 
     50                for(unsigned int y = 0; y < pixbuf->get_height(); ++y) 
     51                { 
     52                        for(unsigned int x = 0; x < pixbuf->get_width(); ++x) 
     53                        { 
     54                                guint8* pixels = pixbuf->get_pixels(); 
     55                                guint8* pixel = 
     56                                        pixels + y * pixbuf->get_rowstride() + 
     57                                                 x * pixbuf->get_n_channels(); 
     58 
     59                                double r = pixel[0]/255.0; 
     60                                double g = pixel[1]/255.0; 
     61                                double b = pixel[2]/255.0; 
     62 
     63                                Gobby::rgb_to_hsv(r,g,b); 
     64                                r = hue; 
     65                                Gobby::hsv_to_rgb(r,g,b); 
     66 
     67                                pixel[0] = 
     68                                        static_cast<guint8>(r * 255.0 + 0.5); 
     69                                pixel[1] = 
     70                                        static_cast<guint8>(g * 255.0 + 0.5); 
     71                                pixel[2] = 
     72                                        static_cast<guint8>(b * 255.0 + 0.5); 
     73                        } 
     74                } 
    9275 
    9376                return pixbuf; 
     
    266249        g_assert(find_user_iter(user) == m_store->children().end()); 
    267250 
    268         Glib::RefPtr<Gdk::Pixbuf> color_pixbuf = 
    269                 generate_user_color_pixbuf(inf_text_user_get_hue(user)); 
     251        Glib::RefPtr<Gdk::Pixbuf> color_pixbuf = generate_user_color_pixbuf( 
     252                *this, inf_text_user_get_hue(user)); 
    270253 
    271254        Gtk::TreeIter iter = m_store->append(); 
     
    285268        g_assert(iter != m_store->children().end()); 
    286269 
    287         (*iter)[m_columns.color] = 
    288                 generate_user_color_pixbuf(inf_text_user_get_hue(user)); 
     270        (*iter)[m_columns.color] = generate_user_color_pixbuf( 
     271                *this, inf_text_user_get_hue(user)); 
    289272} 
    290273 
     
    313296        return children.end(); 
    314297} 
    315  
  • code/util/color.cpp

    r6b79c69 rd451ded  
    162162namespace Gobby 
    163163{ 
     164        double hsv_to_rgb(double& rh, double &gs, double &gv) 
     165        { 
     166                ::hsv_to_rgb(&rh, &gs, &gv); 
     167        } 
     168 
     169        double rgb_to_hsv(double &rh, double &gs, double &gv) 
     170        { 
     171                ::rgb_to_hsv(&rh, &gs, &gv); 
     172        } 
     173 
    164174        double hue_from_gdk_color(const Gdk::Color& color) 
    165175        { 
     
    168178                double b = color.get_blue() / 65535.0; 
    169179 
    170                 rgb_to_hsv(&r, &g, &b); 
     180                ::rgb_to_hsv(&r, &g, &b); 
    171181                return r; 
    172182        } 
     
    175185                                    double value) 
    176186        { 
    177                 hsv_to_rgb(&hue, &saturation, &value); 
     187                ::hsv_to_rgb(&hue, &saturation, &value); 
    178188                Gdk::Color color; 
    179189                color.set_red(static_cast<gushort>(hue * 65535.0)); 
  • code/util/color.hpp

    r6b79c69 rd451ded  
    2424namespace Gobby 
    2525{ 
     26        double hsv_to_rgb(double& rh, double &gs, double &gv); 
     27        double rgb_to_hsv(double &rh, double &gs, double &gv); 
     28 
    2629        double hue_from_gdk_color(const Gdk::Color& color); 
    2730 
  • configure.ac

    rb483a11 rd451ded  
    108108          icons/hicolor/48x48/apps/Makefile 
    109109          icons/hicolor/48x48/actions/Makefile 
     110          icons/hicolor/48x48/status/Makefile 
    110111        icons/hicolor/scalable/Makefile 
    111112          icons/hicolor/scalable/apps/Makefile 
    112113          icons/hicolor/scalable/actions/Makefile 
     114          icons/hicolor/scalable/status/Makefile 
    113115      icons/HighContrastLargePrint/Makefile 
    114116        icons/HighContrastLargePrint/48x48/Makefile 
  • icons/hicolor/48x48/Makefile.am

    rca24222 rd451ded  
    1 SUBDIRS = apps actions 
     1SUBDIRS = apps actions status 
  • icons/hicolor/scalable/Makefile.am

    rca24222 rd451ded  
    1 SUBDIRS = apps actions 
     1SUBDIRS = apps actions status 
  • icons/hicolor/scalable/status/user-color-indicator.svg

    r100e34c rd451ded  
    136136       fy="23.794725" 
    137137       r="6.65625" /> 
    138     <filter 
    139        inkscape:collect="always" 
    140        id="filter3737"> 
    141       <feGaussianBlur 
    142          inkscape:collect="always" 
    143          stdDeviation="0.064470153" 
    144          id="feGaussianBlur3739" /> 
    145     </filter> 
    146138  </defs> 
    147139  <sodipodi:namedview 
     
    156148     inkscape:pageshadow="2" 
    157149     inkscape:zoom="8" 
    158      inkscape:cx="17.162175" 
     150     inkscape:cx="-4.400325" 
    159151     inkscape:cy="18.546187" 
    160152     inkscape:document-units="px" 
    161153     inkscape:current-layer="layer1" 
    162154     showgrid="false" 
    163      inkscape:window-width="821" 
    164      inkscape:window-height="809" 
    165      inkscape:window-x="792" 
    166      inkscape:window-y="155" /> 
     155     inkscape:window-width="1280" 
     156     inkscape:window-height="725" 
     157     inkscape:window-x="0" 
     158     inkscape:window-y="25" /> 
    167159  <metadata 
    168160     id="metadata7"> 
     
    206198      <path 
    207199         sodipodi:type="arc" 
    208          style="fill:url(#linearGradient3707);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;filter:url(#filter3737)" 
     200         style="fill:url(#linearGradient3707);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;" 
    209201         id="path6538" 
    210202         sodipodi:cx="10.1875"