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

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

Issue 131513005: linux_aura: Use GTK button borders in GTK theme mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_UI_LIBGTK2UI_GTK2_UI_H_ 5 #ifndef CHROME_BROWSER_UI_LIBGTK2UI_GTK2_UI_H_
6 #define CHROME_BROWSER_UI_LIBGTK2UI_GTK2_UI_H_ 6 #define CHROME_BROWSER_UI_LIBGTK2UI_GTK2_UI_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "chrome/browser/ui/libgtk2ui/libgtk2ui_export.h" 14 #include "chrome/browser/ui/libgtk2ui/libgtk2ui_export.h"
15 #include "chrome/browser/ui/libgtk2ui/owned_widget_gtk2.h" 15 #include "chrome/browser/ui/libgtk2ui/owned_widget_gtk2.h"
16 #include "ui/gfx/color_utils.h" 16 #include "ui/gfx/color_utils.h"
17 #include "ui/gfx/geometry/insets.h"
17 #include "ui/views/linux_ui/linux_ui.h" 18 #include "ui/views/linux_ui/linux_ui.h"
18 #include "ui/views/window/frame_buttons.h" 19 #include "ui/views/window/frame_buttons.h"
19 20
20 typedef struct _GdkColor GdkColor; 21 typedef struct _GdkColor GdkColor;
22 typedef struct _GtkBorder GtkBorder;
21 typedef struct _GtkStyle GtkStyle; 23 typedef struct _GtkStyle GtkStyle;
22 typedef struct _GtkWidget GtkWidget; 24 typedef struct _GtkWidget GtkWidget;
23 25
24 class SkBitmap; 26 class SkBitmap;
25 27
26 namespace gfx { 28 namespace gfx {
27 class Image; 29 class Image;
28 } 30 }
29 31
30 namespace libgtk2ui { 32 namespace libgtk2ui {
33 class Gtk2Border;
31 class GConfTitlebarListener; 34 class GConfTitlebarListener;
32 35
33 // Interface to GTK2 desktop features. 36 // Interface to GTK2 desktop features.
34 // 37 //
35 class Gtk2UI : public views::LinuxUI { 38 class Gtk2UI : public views::LinuxUI {
36 public: 39 public:
37 Gtk2UI(); 40 Gtk2UI();
38 virtual ~Gtk2UI(); 41 virtual ~Gtk2UI();
39 42
40 void SetWindowButtonOrdering( 43 void SetWindowButtonOrdering(
41 const std::vector<views::FrameButton>& leading_buttons, 44 const std::vector<views::FrameButton>& leading_buttons,
42 const std::vector<views::FrameButton>& trailing_buttons); 45 const std::vector<views::FrameButton>& trailing_buttons);
43 46
47 // Draws the GTK button border for state |gtk_state| onto a bitmap.
48 SkBitmap DrawGtkButtonBorder(int gtk_state, int width, int height) const;
49
50 // Returns the current insets for a button.
51 gfx::Insets GetButtonInsets() const;
52
53 // We keep track of live Gtk2Border objects since we must alert them to theme
54 // changes.
55 void AddGtkBorder(Gtk2Border* border);
56 void RemoveGtkBorder(Gtk2Border* border);
57
44 // ui::LinuxInputMethodContextFactory: 58 // ui::LinuxInputMethodContextFactory:
45 virtual scoped_ptr<ui::LinuxInputMethodContext> CreateInputMethodContext( 59 virtual scoped_ptr<ui::LinuxInputMethodContext> CreateInputMethodContext(
46 ui::LinuxInputMethodContextDelegate* delegate) const OVERRIDE; 60 ui::LinuxInputMethodContextDelegate* delegate) const OVERRIDE;
47 61
48 // gfx::LinuxFontDelegate: 62 // gfx::LinuxFontDelegate:
49 virtual bool UseAntialiasing() const OVERRIDE; 63 virtual bool UseAntialiasing() const OVERRIDE;
50 virtual gfx::FontRenderParams::Hinting GetHintingStyle() const OVERRIDE; 64 virtual gfx::FontRenderParams::Hinting GetHintingStyle() const OVERRIDE;
51 virtual gfx::FontRenderParams::SubpixelRendering 65 virtual gfx::FontRenderParams::SubpixelRendering
52 GetSubpixelRenderingStyle() const OVERRIDE; 66 GetSubpixelRenderingStyle() const OVERRIDE;
53 virtual std::string GetDefaultFontName() const OVERRIDE; 67 virtual std::string GetDefaultFontName() const OVERRIDE;
(...skipping 12 matching lines...) Expand all
66 virtual SkColor GetThumbActiveColor() const OVERRIDE; 80 virtual SkColor GetThumbActiveColor() const OVERRIDE;
67 virtual SkColor GetThumbInactiveColor() const OVERRIDE; 81 virtual SkColor GetThumbInactiveColor() const OVERRIDE;
68 virtual SkColor GetTrackColor() const OVERRIDE; 82 virtual SkColor GetTrackColor() const OVERRIDE;
69 virtual SkColor GetActiveSelectionBgColor() const OVERRIDE; 83 virtual SkColor GetActiveSelectionBgColor() const OVERRIDE;
70 virtual SkColor GetActiveSelectionFgColor() const OVERRIDE; 84 virtual SkColor GetActiveSelectionFgColor() const OVERRIDE;
71 virtual SkColor GetInactiveSelectionBgColor() const OVERRIDE; 85 virtual SkColor GetInactiveSelectionBgColor() const OVERRIDE;
72 virtual SkColor GetInactiveSelectionFgColor() const OVERRIDE; 86 virtual SkColor GetInactiveSelectionFgColor() const OVERRIDE;
73 virtual double GetCursorBlinkInterval() const OVERRIDE; 87 virtual double GetCursorBlinkInterval() const OVERRIDE;
74 virtual ui::NativeTheme* GetNativeTheme() const OVERRIDE; 88 virtual ui::NativeTheme* GetNativeTheme() const OVERRIDE;
75 virtual void SetUseSystemTheme(bool use_system_theme) OVERRIDE; 89 virtual void SetUseSystemTheme(bool use_system_theme) OVERRIDE;
90 virtual bool GetUseSystemTheme() const OVERRIDE;
76 virtual bool GetDefaultUsesSystemTheme() const OVERRIDE; 91 virtual bool GetDefaultUsesSystemTheme() const OVERRIDE;
77 virtual void SetDownloadCount(int count) const OVERRIDE; 92 virtual void SetDownloadCount(int count) const OVERRIDE;
78 virtual void SetProgressFraction(float percentage) const OVERRIDE; 93 virtual void SetProgressFraction(float percentage) const OVERRIDE;
79 virtual bool IsStatusIconSupported() const OVERRIDE; 94 virtual bool IsStatusIconSupported() const OVERRIDE;
80 virtual scoped_ptr<views::StatusIconLinux> CreateLinuxStatusIcon( 95 virtual scoped_ptr<views::StatusIconLinux> CreateLinuxStatusIcon(
81 const gfx::ImageSkia& image, 96 const gfx::ImageSkia& image,
82 const base::string16& tool_tip) const OVERRIDE; 97 const base::string16& tool_tip) const OVERRIDE;
83 virtual gfx::Image GetIconForContentType( 98 virtual gfx::Image GetIconForContentType(
84 const std::string& content_type, int size) const OVERRIDE; 99 const std::string& content_type, int size) const OVERRIDE;
100 virtual views::Border* CreateNativeBorder(
101 views::View* owning_view,
102 views::LabelButtonBorder* label_button_border) OVERRIDE;
msw 2014/01/21 19:18:19 Just use a views::Border here.
85 virtual void AddWindowButtonOrderObserver( 103 virtual void AddWindowButtonOrderObserver(
86 views::WindowButtonOrderObserver* observer) OVERRIDE; 104 views::WindowButtonOrderObserver* observer) OVERRIDE;
87 virtual void RemoveWindowButtonOrderObserver( 105 virtual void RemoveWindowButtonOrderObserver(
88 views::WindowButtonOrderObserver* observer) OVERRIDE; 106 views::WindowButtonOrderObserver* observer) OVERRIDE;
89 virtual bool UnityIsRunning() OVERRIDE; 107 virtual bool UnityIsRunning() OVERRIDE;
90 108
91 private: 109 private:
92 typedef std::map<int, SkColor> ColorMap; 110 typedef std::map<int, SkColor> ColorMap;
93 typedef std::map<int, color_utils::HSL> TintMap; 111 typedef std::map<int, color_utils::HSL> TintMap;
94 typedef std::map<int, gfx::Image> ImageCache; 112 typedef std::map<int, gfx::Image> ImageCache;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // background color. 172 // background color.
155 void GetNormalButtonTintHSL(color_utils::HSL* tint) const; 173 void GetNormalButtonTintHSL(color_utils::HSL* tint) const;
156 174
157 // Returns a tint that's the color of the current normal text in an entry. 175 // Returns a tint that's the color of the current normal text in an entry.
158 void GetNormalEntryForegroundHSL(color_utils::HSL* tint) const; 176 void GetNormalEntryForegroundHSL(color_utils::HSL* tint) const;
159 177
160 // Returns a tint that's the color of the current highlighted text in an 178 // Returns a tint that's the color of the current highlighted text in an
161 // entry. 179 // entry.
162 void GetSelectedEntryForegroundHSL(color_utils::HSL* tint) const; 180 void GetSelectedEntryForegroundHSL(color_utils::HSL* tint) const;
163 181
164 // Draws the GTK button border for state |gtk_state| onto a bitmap. 182 // Create a GTK window and button and queries what "default-border" is, which
165 SkBitmap DrawGtkButtonBorder(int gtk_state, int width, int height) const; 183 // corresponds with our insets.
184 void UpdateButtonInsets();
166 185
167 // Frees all calculated images and color data. 186 // Frees all calculated images and color data.
168 void ClearAllThemeData(); 187 void ClearAllThemeData();
169 188
170 GtkWidget* fake_window_; 189 GtkWidget* fake_window_;
171 GtkWidget* fake_frame_; 190 GtkWidget* fake_frame_;
172 OwnedWidgetGtk fake_label_; 191 OwnedWidgetGtk fake_label_;
173 OwnedWidgetGtk fake_entry_; 192 OwnedWidgetGtk fake_entry_;
174 193
175 // Tints and colors calculated by LoadGtkValues() that are given to the 194 // Tints and colors calculated by LoadGtkValues() that are given to the
(...skipping 10 matching lines...) Expand all
186 // changes. 205 // changes.
187 SkColor focus_ring_color_; 206 SkColor focus_ring_color_;
188 SkColor thumb_active_color_; 207 SkColor thumb_active_color_;
189 SkColor thumb_inactive_color_; 208 SkColor thumb_inactive_color_;
190 SkColor track_color_; 209 SkColor track_color_;
191 SkColor active_selection_bg_color_; 210 SkColor active_selection_bg_color_;
192 SkColor active_selection_fg_color_; 211 SkColor active_selection_fg_color_;
193 SkColor inactive_selection_bg_color_; 212 SkColor inactive_selection_bg_color_;
194 SkColor inactive_selection_fg_color_; 213 SkColor inactive_selection_fg_color_;
195 214
215 gfx::Insets button_insets_;
216
196 #if defined(USE_GCONF) 217 #if defined(USE_GCONF)
197 // Currently, the only source of window button configuration. This will 218 // Currently, the only source of window button configuration. This will
198 // change if we ever have to support XFCE's configuration system or KDE's. 219 // change if we ever have to support XFCE's configuration system or KDE's.
199 scoped_ptr<GConfTitlebarListener> titlebar_listener_; 220 scoped_ptr<GConfTitlebarListener> titlebar_listener_;
200 #endif // defined(USE_GCONF) 221 #endif // defined(USE_GCONF)
201 222
202 // If either of these vectors are non-empty, they represent the current 223 // If either of these vectors are non-empty, they represent the current
203 // window button configuration. 224 // window button configuration.
204 std::vector<views::FrameButton> leading_buttons_; 225 std::vector<views::FrameButton> leading_buttons_;
205 std::vector<views::FrameButton> trailing_buttons_; 226 std::vector<views::FrameButton> trailing_buttons_;
206 227
207 // Objects to notify when the window frame button order changes. 228 // Objects to notify when the window frame button order changes.
208 ObserverList<views::WindowButtonOrderObserver> observer_list_; 229 ObserverList<views::WindowButtonOrderObserver> observer_list_;
209 230
231 // Borders to notify when the theme state changes.
232 ObserverList<Gtk2Border> border_list_;
233
210 // Image cache of lazily created images. 234 // Image cache of lazily created images.
211 mutable ImageCache gtk_images_; 235 mutable ImageCache gtk_images_;
212 236
213 // Whether to use the Gtk2 version of the native theme. 237 // Whether to use the Gtk2 version of the native theme.
214 bool use_gtk_; 238 bool use_gtk_;
215 239
216 DISALLOW_COPY_AND_ASSIGN(Gtk2UI); 240 DISALLOW_COPY_AND_ASSIGN(Gtk2UI);
217 }; 241 };
218 242
219 } // namespace libgtk2ui 243 } // namespace libgtk2ui
220 244
221 // Access point to the GTK2 desktop system. This should be the only symbol that 245 // Access point to the GTK2 desktop system. This should be the only symbol that
222 // is exported in the library; everything else should be used through the 246 // is exported in the library; everything else should be used through the
223 // interface, because eventually this .so will be loaded through dlopen at 247 // interface, because eventually this .so will be loaded through dlopen at
224 // runtime so our main binary can conditionally load GTK2 or GTK3 or EFL or 248 // runtime so our main binary can conditionally load GTK2 or GTK3 or EFL or
225 // QT or whatever. 249 // QT or whatever.
226 LIBGTK2UI_EXPORT views::LinuxUI* BuildGtk2UI(); 250 LIBGTK2UI_EXPORT views::LinuxUI* BuildGtk2UI();
227 251
228 #endif // CHROME_BROWSER_UI_LIBGTK2UI_GTK2_UI_H_ 252 #endif // CHROME_BROWSER_UI_LIBGTK2UI_GTK2_UI_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698