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

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

Issue 2453243002: Gtk3 UI: Rename files in libgtkui containing gtk2 in their name (Closed)
Patch Set: Fix git cl format mistake Created 4 years, 1 month 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
« no previous file with comments | « chrome/browser/ui/libgtkui/gtk2_status_icon.cc ('k') | chrome/browser/ui/libgtkui/gtk2_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_LIBGTKUI_GTK2_UI_H_
6 #define CHROME_BROWSER_UI_LIBGTKUI_GTK2_UI_H_
7
8 #include <map>
9 #include <memory>
10 #include <vector>
11
12 #include "base/compiler_specific.h"
13 #include "base/macros.h"
14 #include "base/observer_list.h"
15 #include "chrome/browser/ui/libgtkui/gtk2_signal.h"
16 #include "chrome/browser/ui/libgtkui/libgtkui_export.h"
17 #include "ui/gfx/color_utils.h"
18 #include "ui/views/linux_ui/linux_ui.h"
19 #include "ui/views/window/frame_buttons.h"
20
21 typedef struct _GtkStyle GtkStyle;
22 typedef struct _GtkWidget GtkWidget;
23
24 class SkBitmap;
25
26 namespace libgtkui {
27 class Gtk2KeyBindingsHandler;
28 class GConfListener;
29
30 // Interface to GTK2 desktop features.
31 //
32 class Gtk2UI : public views::LinuxUI {
33 public:
34 Gtk2UI();
35 ~Gtk2UI() override;
36
37 typedef base::Callback<ui::NativeTheme*(aura::Window* window)>
38 NativeThemeGetter;
39
40 // Setters used by GConfListener:
41 void SetWindowButtonOrdering(
42 const std::vector<views::FrameButton>& leading_buttons,
43 const std::vector<views::FrameButton>& trailing_buttons);
44 void SetNonClientMiddleClickAction(NonClientMiddleClickAction action);
45
46 // Called when gtk style changes
47 void ResetStyle();
48
49 // ui::LinuxInputMethodContextFactory:
50 std::unique_ptr<ui::LinuxInputMethodContext> CreateInputMethodContext(
51 ui::LinuxInputMethodContextDelegate* delegate,
52 bool is_simple) const override;
53
54 // gfx::LinuxFontDelegate:
55 gfx::FontRenderParams GetDefaultFontRenderParams() const override;
56 void GetDefaultFontDescription(
57 std::string* family_out,
58 int* size_pixels_out,
59 int* style_out,
60 gfx::Font::Weight* weight_out,
61 gfx::FontRenderParams* params_out) const override;
62
63 // ui::ShellDialogLinux:
64 ui::SelectFileDialog* CreateSelectFileDialog(
65 ui::SelectFileDialog::Listener* listener,
66 ui::SelectFilePolicy* policy) const override;
67
68 // ui::LinuxUI:
69 void Initialize() override;
70 bool GetTint(int id, color_utils::HSL* tint) const override;
71 bool GetColor(int id, SkColor* color) const override;
72 SkColor GetFocusRingColor() const override;
73 SkColor GetThumbActiveColor() const override;
74 SkColor GetThumbInactiveColor() const override;
75 SkColor GetTrackColor() const override;
76 SkColor GetActiveSelectionBgColor() const override;
77 SkColor GetActiveSelectionFgColor() const override;
78 SkColor GetInactiveSelectionBgColor() const override;
79 SkColor GetInactiveSelectionFgColor() const override;
80 double GetCursorBlinkInterval() const override;
81 ui::NativeTheme* GetNativeTheme(aura::Window* window) const override;
82 void SetNativeThemeOverride(const NativeThemeGetter& callback) override;
83 bool GetDefaultUsesSystemTheme() const override;
84 void SetDownloadCount(int count) const override;
85 void SetProgressFraction(float percentage) const override;
86 bool IsStatusIconSupported() const override;
87 std::unique_ptr<views::StatusIconLinux> CreateLinuxStatusIcon(
88 const gfx::ImageSkia& image,
89 const base::string16& tool_tip) const override;
90 gfx::Image GetIconForContentType(const std::string& content_type,
91 int size) const override;
92 std::unique_ptr<views::Border> CreateNativeBorder(
93 views::LabelButton* owning_button,
94 std::unique_ptr<views::LabelButtonBorder> border) override;
95 void AddWindowButtonOrderObserver(
96 views::WindowButtonOrderObserver* observer) override;
97 void RemoveWindowButtonOrderObserver(
98 views::WindowButtonOrderObserver* observer) override;
99 bool UnityIsRunning() override;
100 NonClientMiddleClickAction GetNonClientMiddleClickAction() override;
101 void NotifyWindowManagerStartupComplete() override;
102
103 // ui::TextEditKeybindingDelegate:
104 bool MatchEvent(const ui::Event& event,
105 std::vector<ui::TextEditCommandAuraLinux>* commands) override;
106
107 // ui::Views::LinuxUI:
108 void UpdateDeviceScaleFactor(float device_scale_factor) override;
109 float GetDeviceScaleFactor() const override;
110
111 private:
112 typedef std::map<int, SkColor> ColorMap;
113 typedef std::map<int, color_utils::HSL> TintMap;
114
115 // This method returns the colors webkit will use for the scrollbars. When no
116 // colors are specified by the GTK+ theme, this function averages of the
117 // thumb part and of the track colors.
118 void SetScrollbarColors();
119
120 // Extracts colors and tints from the GTK theme, both for the
121 // ThemeService interface and the colors we send to webkit.
122 void LoadGtkValues();
123
124 // Initialize the Xcursor theme and size with the GTK theme and size.
125 void LoadCursorTheme();
126
127 // Reads in explicit theme frame colors from the ChromeGtkFrame style class
128 // or generates them per our fallback algorithm.
129 void BuildFrameColors();
130
131 // Gets a tint which depends on the default for |id| as well as |color|.
132 color_utils::HSL ColorToTint(int id, SkColor color);
133
134 // Returns the tint for buttons that contrasts with the normal window
135 // background color.
136 void GetNormalButtonTintHSL(color_utils::HSL* tint) const;
137
138 // Returns a tint that's the color of the current normal text in an entry.
139 void GetNormalEntryForegroundHSL(color_utils::HSL* tint) const;
140
141 // Returns a tint that's the color of the current highlighted text in an
142 // entry.
143 void GetSelectedEntryForegroundHSL(color_utils::HSL* tint) const;
144
145 // Gets a color for the background of the prominent button.
146 SkColor GetProminentButtonBgColor(int gtk_state) const;
147
148 // Updates |default_font_*|.
149 void UpdateDefaultFont();
150
151 // Colors calculated by LoadGtkValues() that are given to the
152 // caller while |use_gtk_| is true.
153 ColorMap colors_;
154
155 // Colors used to tint certain icons.
156 color_utils::HSL button_tint_;
157 color_utils::HSL entry_tint_;
158 color_utils::HSL selected_entry_tint_;
159
160 // Colors that we pass to WebKit. These are generated each time the theme
161 // changes.
162 SkColor focus_ring_color_;
163 SkColor thumb_active_color_;
164 SkColor thumb_inactive_color_;
165 SkColor track_color_;
166 SkColor active_selection_bg_color_;
167 SkColor active_selection_fg_color_;
168 SkColor inactive_selection_bg_color_;
169 SkColor inactive_selection_fg_color_;
170
171 // Details about the default UI font.
172 std::string default_font_family_;
173 int default_font_size_pixels_;
174 int default_font_style_; // Bitfield of gfx::Font::Style values.
175 gfx::Font::Weight default_font_weight_;
176 gfx::FontRenderParams default_font_render_params_;
177
178 #if defined(USE_GCONF)
179 // Currently, the only source of window button configuration. This will
180 // change if we ever have to support XFCE's configuration system or KDE's.
181 std::unique_ptr<GConfListener> gconf_listener_;
182 #endif // defined(USE_GCONF)
183
184 // If either of these vectors are non-empty, they represent the current
185 // window button configuration.
186 std::vector<views::FrameButton> leading_buttons_;
187 std::vector<views::FrameButton> trailing_buttons_;
188
189 std::unique_ptr<Gtk2KeyBindingsHandler> key_bindings_handler_;
190
191 // Objects to notify when the window frame button order changes.
192 base::ObserverList<views::WindowButtonOrderObserver> observer_list_;
193
194 // Whether we should lower the window on a middle click to the non client
195 // area.
196 NonClientMiddleClickAction middle_click_action_;
197
198 // Used to override the native theme for a window. If no override is provided
199 // or the callback returns NULL, Gtk2UI will default to a NativeThemeGtk2
200 // instance.
201 NativeThemeGetter native_theme_overrider_;
202
203 float device_scale_factor_;
204
205 DISALLOW_COPY_AND_ASSIGN(Gtk2UI);
206 };
207
208 } // namespace libgtkui
209
210 // Access point to the GTK2 desktop system. This should be the only symbol that
211 // is exported in the library; everything else should be used through the
212 // interface, because eventually this .so will be loaded through dlopen at
213 // runtime so our main binary can conditionally load GTK2 or GTK3 or EFL or
214 // QT or whatever.
215 LIBGTKUI_EXPORT views::LinuxUI* BuildGtk2UI();
216
217 #endif // CHROME_BROWSER_UI_LIBGTKUI_GTK2_UI_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/libgtkui/gtk2_status_icon.cc ('k') | chrome/browser/ui/libgtkui/gtk2_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698