Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(436)

Side by Side Diff: chrome/browser/ui/libgtk2ui/gtk2_ui.h

Issue 10545037: Aura/GTK integration: Create a small stub library that can talk to GTK. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sky nits Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_LIBGTK2UI_GTK2_UI_H_
6 #define CHROME_BROWSER_UI_LIBGTK2UI_GTK2_UI_H_
7 #pragma once
8
9 #include <map>
10
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "chrome/browser/ui/libgtk2ui/libgtk2ui_export.h"
14 #include "chrome/browser/ui/libgtk2ui/owned_widget_gtk2.h"
15 #include "ui/base/linux_ui.h"
16 #include "ui/gfx/color_utils.h"
17
18 typedef struct _GdkColor GdkColor;
19 typedef struct _GtkStyle GtkStyle;
20 typedef struct _GtkWidget GtkWidget;
21
22 class SkBitmap;
23
24 namespace gfx {
25 class Image;
26 }
27
28 namespace libgtk2ui {
29
30 // Interface to GTK2 desktop features.
31 //
32 class Gtk2UI : public ui::LinuxUI {
33 public:
34 Gtk2UI();
35 virtual ~Gtk2UI();
36
37 // LinuxShell:
tfarina 2012/06/07 17:02:05 nit: s/LinuxShell/ui::LinuxUI
38 virtual bool UseNativeTheme() const OVERRIDE;
39 virtual gfx::Image* GetThemeImageNamed(int id) const OVERRIDE;
40 virtual SkColor GetColor(int id) const OVERRIDE;
41
42 private:
43 typedef std::map<int, SkColor> ColorMap;
44 typedef std::map<int, color_utils::HSL> TintMap;
45 typedef std::map<int, gfx::Image*> ImageCache;
46
47 // This method returns the colors webkit will use for the scrollbars. When no
48 // colors are specified by the GTK+ theme, this function averages of the
49 // thumb part and of the track colors.
50 void GetScrollbarColors(GdkColor* thumb_active_color,
51 GdkColor* thumb_inactive_color,
52 GdkColor* track_color);
53
54 // Extracts colors and tints from the GTK theme, both for the
55 // ThemeService interface and the colors we send to webkit.
56 void LoadGtkValues();
57
58 // Reads in explicit theme frame colors from the ChromeGtkFrame style class
59 // or generates them per our fallback algorithm.
60 GdkColor BuildFrameColors(GtkStyle* frame_style);
61
62 // Sets the underlying theme colors/tints from a GTK color.
63 void SetThemeColorFromGtk(int id, const GdkColor* color);
64 void SetThemeTintFromGtk(int id, const GdkColor* color);
65
66 // Creates and returns a frame color, either using |gtk_base| verbatim if
67 // non-NULL, or tinting |base| with |tint|. Also sets |color_id| and
68 // |tint_id| to the returned color.
69 GdkColor BuildAndSetFrameColor(const GdkColor* base,
70 const GdkColor* gtk_base,
71 const color_utils::HSL& tint,
72 int color_id,
73 int tint_id);
74
75 // Lazily generates each bitmap used in the gtk theme.
76 SkBitmap GenerateGtkThemeBitmap(int id) const;
77
78 // Creates a GTK+ version of IDR_THEME_FRAME. Instead of tinting, this
79 // creates a theme configurable gradient ending with |color_id| at the
80 // bottom, and |gradient_name| at the top if that color is specified in the
81 // theme.
82 SkBitmap GenerateFrameImage(int color_id,
83 const char* gradient_name) const;
84
85 // Takes the base frame image |base_id| and tints it with |tint_id|.
86 SkBitmap GenerateTabImage(int base_id) const;
87
88 // Tints an icon based on tint.
89 SkBitmap GenerateTintedIcon(int base_id,
90 const color_utils::HSL& tint) const;
91
92 // Returns the tint for buttons that contrasts with the normal window
93 // background color.
94 void GetNormalButtonTintHSL(color_utils::HSL* tint) const;
95
96 // Returns a tint that's the color of the current normal text in an entry.
97 void GetNormalEntryForegroundHSL(color_utils::HSL* tint) const;
98
99 // Returns a tint that's the color of the current highlighted text in an
100 // entry.
101 void GetSelectedEntryForegroundHSL(color_utils::HSL* tint) const;
102
103 // Frees all calculated images and color data.
104 void ClearAllThemeData();
105
106 GtkWidget* fake_window_;
107 GtkWidget* fake_frame_;
108 OwnedWidgetGtk fake_label_;
109 OwnedWidgetGtk fake_entry_;
110 OwnedWidgetGtk fake_menu_item_;
111
112 // Tints and colors calculated by LoadGtkValues() that are given to the
113 // caller while |use_gtk_| is true.
114 ColorMap colors_;
115 TintMap tints_;
116
117 // Colors used to tint certain icons.
118 color_utils::HSL button_tint_;
119 color_utils::HSL entry_tint_;
120 color_utils::HSL selected_entry_tint_;
121
122 // Colors that we pass to WebKit. These are generated each time the theme
123 // changes.
124 SkColor focus_ring_color_;
125 SkColor thumb_active_color_;
126 SkColor thumb_inactive_color_;
127 SkColor track_color_;
128 SkColor active_selection_bg_color_;
129 SkColor active_selection_fg_color_;
130 SkColor inactive_selection_bg_color_;
131 SkColor inactive_selection_fg_color_;
132
133 // Image cache of lazily created images.
134 mutable ImageCache gtk_images_;
135
136 DISALLOW_COPY_AND_ASSIGN(Gtk2UI);
137 };
138
139 } // namespace libgtk2ui
140
141 // Access point to the GTK2 desktop system. This should be the only symbol that
142 // is exported in the library; everything else should be used through the
143 // interface, because eventually this .so will be loaded through dlopen at
144 // runtime so our main binary can conditionally load GTK2 or GTK3 or EFL or
145 // QT or whatever.
146 LIBGTK2UI_EXPORT ui::LinuxUI* BuildGtk2UI();
147
148 #endif // CHROME_BROWSER_UI_LIBGTK2UI_GTK2_UI_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698