OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_GTK_GTK_THEME_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_GTK_GTK_THEME_PROVIDER_H_ |
6 #define CHROME_BROWSER_GTK_GTK_THEME_PROVIDER_H_ | 6 #define CHROME_BROWSER_GTK_GTK_THEME_PROVIDER_H_ |
7 | 7 |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 bool UseGtkTheme() const; | 63 bool UseGtkTheme() const; |
64 | 64 |
65 // A wrapper around ThemeProvider::GetColor, transforming the result to a | 65 // A wrapper around ThemeProvider::GetColor, transforming the result to a |
66 // GdkColor. | 66 // GdkColor. |
67 GdkColor GetGdkColor(int id) const; | 67 GdkColor GetGdkColor(int id) const; |
68 | 68 |
69 // A weighted average between the text color and the background color of a | 69 // A weighted average between the text color and the background color of a |
70 // label. Used for borders between GTK stuff and the webcontent. | 70 // label. Used for borders between GTK stuff and the webcontent. |
71 GdkColor GetBorderColor() const; | 71 GdkColor GetBorderColor() const; |
72 | 72 |
| 73 // Returns a set of icons tinted for different GtkStateTypes based on the |
| 74 // label colors for the IDR resource |id|. |
| 75 GtkIconSet* GetIconSetForId(int id) const; |
| 76 |
73 // This method returns averages of the thumb part and of the track colors. | 77 // This method returns averages of the thumb part and of the track colors. |
74 // Used when rendering scrollbars. | 78 // Used when rendering scrollbars. |
75 static void GetScrollbarColors(GdkColor* thumb_active_color, | 79 static void GetScrollbarColors(GdkColor* thumb_active_color, |
76 GdkColor* thumb_inactive_color, | 80 GdkColor* thumb_inactive_color, |
77 GdkColor* track_color); | 81 GdkColor* track_color); |
78 | 82 |
79 // Expose the inner label. Only used for testing. | 83 // Expose the inner label. Only used for testing. |
80 GtkWidget* fake_label() { return fake_label_.get(); } | 84 GtkWidget* fake_label() { return fake_label_.get(); } |
81 | 85 |
82 // Returns a CairoCachedSurface for a particular Display. CairoCachedSurfaces | 86 // Returns a CairoCachedSurface for a particular Display. CairoCachedSurfaces |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 // Additionally frees the CairoCachedSurfaces. | 141 // Additionally frees the CairoCachedSurfaces. |
138 virtual void FreePlatformCaches(); | 142 virtual void FreePlatformCaches(); |
139 | 143 |
140 // Extracts colors and tints from the GTK theme, both for the | 144 // Extracts colors and tints from the GTK theme, both for the |
141 // BrowserThemeProvider interface and the colors we send to webkit. | 145 // BrowserThemeProvider interface and the colors we send to webkit. |
142 void LoadGtkValues(); | 146 void LoadGtkValues(); |
143 | 147 |
144 // Sets the values that we send to webkit to safe defaults. | 148 // Sets the values that we send to webkit to safe defaults. |
145 void LoadDefaultValues(); | 149 void LoadDefaultValues(); |
146 | 150 |
| 151 // Builds all of the tinted menus images needed for custom buttons. This is |
| 152 // always called on style-set even if we aren't using the gtk-theme because |
| 153 // the menus are always rendered with gtk colors. |
| 154 void RebuildMenuIconSets(); |
| 155 |
| 156 // Builds and tints the image with |id| to the GtkStateType |state| and |
| 157 // places the result in |icon_set|. |
| 158 void BuildIconFromIDRWithColor(int id, |
| 159 GtkStyle* style, |
| 160 GtkStateType state, |
| 161 GtkIconSet* icon_set); |
| 162 |
147 // Sets the underlying theme colors/tints from a GTK color. | 163 // Sets the underlying theme colors/tints from a GTK color. |
148 void SetThemeColorFromGtk(int id, const GdkColor* color); | 164 void SetThemeColorFromGtk(int id, const GdkColor* color); |
149 void SetThemeTintFromGtk(int id, const GdkColor* color); | 165 void SetThemeTintFromGtk(int id, const GdkColor* color); |
150 void BuildTintedFrameColor(int color_id, int tint_id); | 166 void BuildTintedFrameColor(int color_id, int tint_id); |
151 void SetTintToExactColor(int id, const GdkColor* color); | 167 void SetTintToExactColor(int id, const GdkColor* color); |
152 | 168 |
153 // Split out from FreePlatformCaches so it can be called in our destructor; | 169 // Split out from FreePlatformCaches so it can be called in our destructor; |
154 // FreePlatformCaches() is called from the BrowserThemeProvider's destructor, | 170 // FreePlatformCaches() is called from the BrowserThemeProvider's destructor, |
155 // but by the time ~BrowserThemeProvider() is run, the vtable no longer | 171 // but by the time ~BrowserThemeProvider() is run, the vtable no longer |
156 // points to GtkThemeProvider's version. | 172 // points to GtkThemeProvider's version. |
157 void FreePerDisplaySurfaces(PerDisplaySurfaceMap* per_display_map); | 173 void FreePerDisplaySurfaces(PerDisplaySurfaceMap* per_display_map); |
158 | 174 |
| 175 // Frees all the created GtkIconSets we use for the chrome menu. |
| 176 void FreeIconSets(); |
| 177 |
159 // Lazily generates each bitmap used in the gtk theme. | 178 // Lazily generates each bitmap used in the gtk theme. |
160 SkBitmap* GenerateGtkThemeBitmap(int id) const; | 179 SkBitmap* GenerateGtkThemeBitmap(int id) const; |
161 | 180 |
162 // Tints IDR_THEME_FRAME based based on |tint_id|. Used during lazy | 181 // Tints IDR_THEME_FRAME based based on |tint_id|. Used during lazy |
163 // generation of the gtk theme bitmaps. | 182 // generation of the gtk theme bitmaps. |
164 SkBitmap* GenerateFrameImage(int tint_id) const; | 183 SkBitmap* GenerateFrameImage(int tint_id) const; |
165 | 184 |
166 // Takes the base frame image |base_id| and tints it with |tint_id|. | 185 // Takes the base frame image |base_id| and tints it with |tint_id|. |
167 SkBitmap* GenerateTabImage(int base_id) const; | 186 SkBitmap* GenerateTabImage(int base_id) const; |
168 | 187 |
(...skipping 23 matching lines...) Expand all Loading... |
192 | 211 |
193 // Whether we should be using gtk rendering. | 212 // Whether we should be using gtk rendering. |
194 bool use_gtk_; | 213 bool use_gtk_; |
195 | 214 |
196 // GtkWidgets that exist only so we can look at their properties (and take | 215 // GtkWidgets that exist only so we can look at their properties (and take |
197 // their colors). | 216 // their colors). |
198 GtkWidget* fake_window_; | 217 GtkWidget* fake_window_; |
199 GtkWidget* fake_frame_; | 218 GtkWidget* fake_frame_; |
200 OwnedWidgetGtk fake_label_; | 219 OwnedWidgetGtk fake_label_; |
201 OwnedWidgetGtk fake_entry_; | 220 OwnedWidgetGtk fake_entry_; |
| 221 OwnedWidgetGtk fake_menu_item_; |
202 | 222 |
203 // A list of all GtkChromeButton instances. We hold on to these to notify | 223 // A list of all GtkChromeButton instances. We hold on to these to notify |
204 // them of theme changes. | 224 // them of theme changes. |
205 std::vector<GtkWidget*> chrome_buttons_; | 225 std::vector<GtkWidget*> chrome_buttons_; |
206 | 226 |
207 // Tracks all the signals we have connected to on various widgets. | 227 // Tracks all the signals we have connected to on various widgets. |
208 GtkSignalRegistrar signals_; | 228 GtkSignalRegistrar signals_; |
209 | 229 |
210 // Tints and colors calculated by LoadGtkValues() that are given to the | 230 // Tints and colors calculated by LoadGtkValues() that are given to the |
211 // caller while |use_gtk_| is true. | 231 // caller while |use_gtk_| is true. |
212 ColorMap colors_; | 232 ColorMap colors_; |
213 TintMap tints_; | 233 TintMap tints_; |
214 | 234 |
215 // Colors used to tint certain icons. | 235 // Colors used to tint certain icons. |
216 color_utils::HSL button_tint_; | 236 color_utils::HSL button_tint_; |
217 color_utils::HSL entry_tint_; | 237 color_utils::HSL entry_tint_; |
218 color_utils::HSL selected_entry_tint_; | 238 color_utils::HSL selected_entry_tint_; |
219 | 239 |
220 // Colors that we pass to WebKit. These are generated each time the theme | 240 // Colors that we pass to WebKit. These are generated each time the theme |
221 // changes. | 241 // changes. |
222 SkColor focus_ring_color_; | 242 SkColor focus_ring_color_; |
223 SkColor thumb_active_color_; | 243 SkColor thumb_active_color_; |
224 SkColor thumb_inactive_color_; | 244 SkColor thumb_inactive_color_; |
225 SkColor track_color_; | 245 SkColor track_color_; |
226 SkColor active_selection_bg_color_; | 246 SkColor active_selection_bg_color_; |
227 SkColor active_selection_fg_color_; | 247 SkColor active_selection_fg_color_; |
228 SkColor inactive_selection_bg_color_; | 248 SkColor inactive_selection_bg_color_; |
229 SkColor inactive_selection_fg_color_; | 249 SkColor inactive_selection_fg_color_; |
230 | 250 |
| 251 // A GtkIconSet that has the tinted icons for the NORMAL and PRELIGHT states |
| 252 // of the IDR_FULLSCREEN_MENU_BUTTON tinted to the respective menu item label |
| 253 // colors. |
| 254 GtkIconSet* fullscreen_icon_set_; |
| 255 |
231 // Image cache of lazily created images, created when requested by | 256 // Image cache of lazily created images, created when requested by |
232 // GetBitmapNamed(). | 257 // GetBitmapNamed(). |
233 mutable ImageCache gtk_images_; | 258 mutable ImageCache gtk_images_; |
234 | 259 |
235 // Cairo surfaces for each GdkDisplay. | 260 // Cairo surfaces for each GdkDisplay. |
236 PerDisplaySurfaceMap per_display_surfaces_; | 261 PerDisplaySurfaceMap per_display_surfaces_; |
237 PerDisplaySurfaceMap per_display_unthemed_surfaces_; | 262 PerDisplaySurfaceMap per_display_unthemed_surfaces_; |
238 | 263 |
239 // This is a dummy widget that only exists so we have something to pass to | 264 // This is a dummy widget that only exists so we have something to pass to |
240 // gtk_widget_render_icon(). | 265 // gtk_widget_render_icon(). |
241 static GtkWidget* icon_widget_; | 266 static GtkWidget* icon_widget_; |
242 | 267 |
243 // The default folder icon and default bookmark icon for the GTK theme. | 268 // The default folder icon and default bookmark icon for the GTK theme. |
244 // These are static because the system can only have one theme at a time. | 269 // These are static because the system can only have one theme at a time. |
245 // They are cached when they are requested the first time, and cleared when | 270 // They are cached when they are requested the first time, and cleared when |
246 // the system theme changes. | 271 // the system theme changes. |
247 static GdkPixbuf* default_folder_icon_; | 272 static GdkPixbuf* default_folder_icon_; |
248 static GdkPixbuf* default_bookmark_icon_; | 273 static GdkPixbuf* default_bookmark_icon_; |
249 }; | 274 }; |
250 | 275 |
251 #endif // CHROME_BROWSER_GTK_GTK_THEME_PROVIDER_H_ | 276 #endif // CHROME_BROWSER_GTK_GTK_THEME_PROVIDER_H_ |
OLD | NEW |