Changeset d451ded122128ae7642f03735ebc062afc1b7e9d
- Timestamp:
- 10/24/09 16:58:54 (4 years ago)
- Parents:
- 100e34cbc1b89eb7b0aa267f90358ed8f0b7d84d
- Children:
- 44f4113f1630461cc00e8ad6aae3d5720fa585e5
- git-committer:
- Armin Burgmeier <armin@arbur.net> / 2009-10-24T16:58:54Z+0200
- Files:
-
- 2 added
- 10 modified
-
ChangeLog (modified) (1 diff)
-
code/core/iconmanager.cpp (modified) (2 diffs)
-
code/core/iconmanager.hpp (modified) (2 diffs)
-
code/core/userlist.cpp (modified) (5 diffs)
-
code/util/color.cpp (modified) (3 diffs)
-
code/util/color.hpp (modified) (1 diff)
-
configure.ac (modified) (1 diff)
-
icons/hicolor/48x48/Makefile.am (modified) (1 diff)
-
icons/hicolor/48x48/status/Makefile.am (added)
-
icons/hicolor/scalable/Makefile.am (modified) (1 diff)
-
icons/hicolor/scalable/status/Makefile.am (added)
-
icons/hicolor/scalable/status/user-color-indicator.svg (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r100e34c rd451ded 1 2009-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 1 23 2009-10-24 Benjamin Herr <ben@0x539.de> 2 24 -
code/core/iconmanager.cpp
rca24222 rd451ded 26 26 Gtk::StockID Gobby::IconManager::STOCK_DOCLIST("gobby-document-list"); 27 27 Gtk::StockID Gobby::IconManager::STOCK_SAVE_ALL("gobby-save-all"); 28 Gtk::StockID Gobby::IconManager::STOCK_USER_COLOR_INDICATOR( 29 "gobby-user-color-indicator"); 28 30 29 31 // TODO: The save-all icon does not match the save icon for toolbar … … 48 50 Gtk::StockItem save_all_item(STOCK_SAVE_ALL, _("Save All")); 49 51 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 50 60 m_icon_factory->add_default(); 51 61 } -
code/core/iconmanager.hpp
rca24222 rd451ded 33 33 static Gtk::StockID STOCK_DOCLIST; 34 34 static Gtk::StockID STOCK_SAVE_ALL; 35 static Gtk::StockID STOCK_USER_COLOR_INDICATOR; 35 36 36 37 IconManager(); … … 40 41 Gtk::IconSet m_is_doclist; 41 42 Gtk::IconSet m_is_save_all; 43 Gtk::IconSet m_is_user_color_indicator; 42 44 43 45 Glib::RefPtr<Gtk::IconFactory> m_icon_factory; -
code/core/userlist.cpp
r6b79c69 rd451ded 18 18 19 19 #include "core/userlist.hpp" 20 #include "core/iconmanager.hpp" 20 21 21 22 #include "util/i18n.hpp" … … 37 38 } 38 39 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 } 92 75 93 76 return pixbuf; … … 266 249 g_assert(find_user_iter(user) == m_store->children().end()); 267 250 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)); 270 253 271 254 Gtk::TreeIter iter = m_store->append(); … … 285 268 g_assert(iter != m_store->children().end()); 286 269 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)); 289 272 } 290 273 … … 313 296 return children.end(); 314 297 } 315 -
code/util/color.cpp
r6b79c69 rd451ded 162 162 namespace Gobby 163 163 { 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 164 174 double hue_from_gdk_color(const Gdk::Color& color) 165 175 { … … 168 178 double b = color.get_blue() / 65535.0; 169 179 170 rgb_to_hsv(&r, &g, &b);180 ::rgb_to_hsv(&r, &g, &b); 171 181 return r; 172 182 } … … 175 185 double value) 176 186 { 177 hsv_to_rgb(&hue, &saturation, &value);187 ::hsv_to_rgb(&hue, &saturation, &value); 178 188 Gdk::Color color; 179 189 color.set_red(static_cast<gushort>(hue * 65535.0)); -
code/util/color.hpp
r6b79c69 rd451ded 24 24 namespace Gobby 25 25 { 26 double hsv_to_rgb(double& rh, double &gs, double &gv); 27 double rgb_to_hsv(double &rh, double &gs, double &gv); 28 26 29 double hue_from_gdk_color(const Gdk::Color& color); 27 30 -
configure.ac
rb483a11 rd451ded 108 108 icons/hicolor/48x48/apps/Makefile 109 109 icons/hicolor/48x48/actions/Makefile 110 icons/hicolor/48x48/status/Makefile 110 111 icons/hicolor/scalable/Makefile 111 112 icons/hicolor/scalable/apps/Makefile 112 113 icons/hicolor/scalable/actions/Makefile 114 icons/hicolor/scalable/status/Makefile 113 115 icons/HighContrastLargePrint/Makefile 114 116 icons/HighContrastLargePrint/48x48/Makefile -
icons/hicolor/48x48/Makefile.am
rca24222 rd451ded 1 SUBDIRS = apps actions 1 SUBDIRS = apps actions status -
icons/hicolor/scalable/Makefile.am
rca24222 rd451ded 1 SUBDIRS = apps actions 1 SUBDIRS = apps actions status -
icons/hicolor/scalable/status/user-color-indicator.svg
r100e34c rd451ded 136 136 fy="23.794725" 137 137 r="6.65625" /> 138 <filter139 inkscape:collect="always"140 id="filter3737">141 <feGaussianBlur142 inkscape:collect="always"143 stdDeviation="0.064470153"144 id="feGaussianBlur3739" />145 </filter>146 138 </defs> 147 139 <sodipodi:namedview … … 156 148 inkscape:pageshadow="2" 157 149 inkscape:zoom="8" 158 inkscape:cx=" 17.162175"150 inkscape:cx="-4.400325" 159 151 inkscape:cy="18.546187" 160 152 inkscape:document-units="px" 161 153 inkscape:current-layer="layer1" 162 154 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" /> 167 159 <metadata 168 160 id="metadata7"> … … 206 198 <path 207 199 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;" 209 201 id="path6538" 210 202 sodipodi:cx="10.1875"
