| OLD | NEW |
| 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 <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 15 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h" | 15 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h" |
| 16 #include "chrome/browser/ui/libgtk2ui/libgtk2ui_export.h" | 16 #include "chrome/browser/ui/libgtk2ui/libgtk2ui_export.h" |
| 17 #include "ui/base/ime/linux/text_edit_key_bindings_delegate_auralinux.h" | 17 #include "ui/base/ime/linux/text_edit_key_bindings_delegate_auralinux.h" |
| 18 #include "ui/gfx/color_utils.h" | 18 #include "ui/gfx/color_utils.h" |
| 19 #include "ui/views/linux_ui/linux_ui.h" | 19 #include "ui/views/linux_ui/linux_ui.h" |
| 20 #include "ui/views/window/frame_buttons.h" | 20 #include "ui/views/window/frame_buttons.h" |
| 21 | 21 |
| 22 typedef struct _GtkBorder GtkBorder; | |
| 23 typedef struct _GtkStyle GtkStyle; | 22 typedef struct _GtkStyle GtkStyle; |
| 24 typedef struct _GtkWidget GtkWidget; | 23 typedef struct _GtkWidget GtkWidget; |
| 25 | 24 |
| 26 class SkBitmap; | 25 class SkBitmap; |
| 27 | 26 |
| 28 namespace gfx { | |
| 29 class Image; | |
| 30 } | |
| 31 | |
| 32 namespace libgtk2ui { | 27 namespace libgtk2ui { |
| 33 class Gtk2Border; | |
| 34 class Gtk2KeyBindingsHandler; | 28 class Gtk2KeyBindingsHandler; |
| 35 class GConfListener; | 29 class GConfListener; |
| 36 | 30 |
| 37 // Interface to GTK2 desktop features. | 31 // Interface to GTK2 desktop features. |
| 38 // | 32 // |
| 39 class Gtk2UI : public views::LinuxUI { | 33 class Gtk2UI : public views::LinuxUI { |
| 40 public: | 34 public: |
| 41 Gtk2UI(); | 35 Gtk2UI(); |
| 42 ~Gtk2UI() override; | 36 ~Gtk2UI() override; |
| 43 | 37 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 70 // ui::ShellDialogLinux: | 64 // ui::ShellDialogLinux: |
| 71 ui::SelectFileDialog* CreateSelectFileDialog( | 65 ui::SelectFileDialog* CreateSelectFileDialog( |
| 72 ui::SelectFileDialog::Listener* listener, | 66 ui::SelectFileDialog::Listener* listener, |
| 73 ui::SelectFilePolicy* policy) const override; | 67 ui::SelectFilePolicy* policy) const override; |
| 74 | 68 |
| 75 // ui::LinuxUI: | 69 // ui::LinuxUI: |
| 76 void Initialize() override; | 70 void Initialize() override; |
| 77 // TODO(varkha): This should not be necessary once Material Design is on | 71 // TODO(varkha): This should not be necessary once Material Design is on |
| 78 // unconditionally. | 72 // unconditionally. |
| 79 void MaterialDesignControllerReady() override; | 73 void MaterialDesignControllerReady() override; |
| 80 gfx::Image GetThemeImageNamed(int id) const override; | |
| 81 bool GetTint(int id, color_utils::HSL* tint) const override; | 74 bool GetTint(int id, color_utils::HSL* tint) const override; |
| 82 bool GetColor(int id, SkColor* color) const override; | 75 bool GetColor(int id, SkColor* color) const override; |
| 83 bool HasCustomImage(int id) const override; | |
| 84 SkColor GetFocusRingColor() const override; | 76 SkColor GetFocusRingColor() const override; |
| 85 SkColor GetThumbActiveColor() const override; | 77 SkColor GetThumbActiveColor() const override; |
| 86 SkColor GetThumbInactiveColor() const override; | 78 SkColor GetThumbInactiveColor() const override; |
| 87 SkColor GetTrackColor() const override; | 79 SkColor GetTrackColor() const override; |
| 88 SkColor GetActiveSelectionBgColor() const override; | 80 SkColor GetActiveSelectionBgColor() const override; |
| 89 SkColor GetActiveSelectionFgColor() const override; | 81 SkColor GetActiveSelectionFgColor() const override; |
| 90 SkColor GetInactiveSelectionBgColor() const override; | 82 SkColor GetInactiveSelectionBgColor() const override; |
| 91 SkColor GetInactiveSelectionFgColor() const override; | 83 SkColor GetInactiveSelectionFgColor() const override; |
| 92 double GetCursorBlinkInterval() const override; | 84 double GetCursorBlinkInterval() const override; |
| 93 ui::NativeTheme* GetNativeTheme(aura::Window* window) const override; | 85 ui::NativeTheme* GetNativeTheme(aura::Window* window) const override; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 116 bool MatchEvent(const ui::Event& event, | 108 bool MatchEvent(const ui::Event& event, |
| 117 std::vector<ui::TextEditCommandAuraLinux>* commands) override; | 109 std::vector<ui::TextEditCommandAuraLinux>* commands) override; |
| 118 | 110 |
| 119 // ui::Views::LinuxUI: | 111 // ui::Views::LinuxUI: |
| 120 void UpdateDeviceScaleFactor(float device_scale_factor) override; | 112 void UpdateDeviceScaleFactor(float device_scale_factor) override; |
| 121 float GetDeviceScaleFactor() const override; | 113 float GetDeviceScaleFactor() const override; |
| 122 | 114 |
| 123 private: | 115 private: |
| 124 typedef std::map<int, SkColor> ColorMap; | 116 typedef std::map<int, SkColor> ColorMap; |
| 125 typedef std::map<int, color_utils::HSL> TintMap; | 117 typedef std::map<int, color_utils::HSL> TintMap; |
| 126 typedef std::map<int, gfx::Image> ImageCache; | |
| 127 | 118 |
| 128 // This method returns the colors webkit will use for the scrollbars. When no | 119 // This method returns the colors webkit will use for the scrollbars. When no |
| 129 // colors are specified by the GTK+ theme, this function averages of the | 120 // colors are specified by the GTK+ theme, this function averages of the |
| 130 // thumb part and of the track colors. | 121 // thumb part and of the track colors. |
| 131 void SetScrollbarColors(); | 122 void SetScrollbarColors(); |
| 132 | 123 |
| 133 // Extracts colors and tints from the GTK theme, both for the | 124 // Extracts colors and tints from the GTK theme, both for the |
| 134 // ThemeService interface and the colors we send to webkit. | 125 // ThemeService interface and the colors we send to webkit. |
| 135 void LoadGtkValues(); | 126 void LoadGtkValues(); |
| 136 | 127 |
| 137 // Initialize the Xcursor theme and size with the GTK theme and size. | 128 // Initialize the Xcursor theme and size with the GTK theme and size. |
| 138 void LoadCursorTheme(); | 129 void LoadCursorTheme(); |
| 139 | 130 |
| 140 // Updates colors if necessary after possible modification of command line. | 131 // Updates colors if necessary after possible modification of command line. |
| 141 // TODO(varkha): This should not be necessary once Material Design is on | 132 // TODO(varkha): This should not be necessary once Material Design is on |
| 142 // unconditionally. | 133 // unconditionally. |
| 143 void UpdateMaterialDesignColors(); | 134 void UpdateMaterialDesignColors(); |
| 144 | 135 |
| 145 // Reads in explicit theme frame colors from the ChromeGtkFrame style class | 136 // Reads in explicit theme frame colors from the ChromeGtkFrame style class |
| 146 // or generates them per our fallback algorithm. | 137 // or generates them per our fallback algorithm. |
| 147 SkColor BuildFrameColors(); | 138 void BuildFrameColors(); |
| 148 | 139 |
| 149 // Gets a tint which depends on the default for |id| as well as |color|. | 140 // Gets a tint which depends on the default for |id| as well as |color|. |
| 150 color_utils::HSL ColorToTint(int id, SkColor color); | 141 color_utils::HSL ColorToTint(int id, SkColor color); |
| 151 | 142 |
| 152 // Lazily generates each image used in the gtk theme. | |
| 153 gfx::Image GenerateGtkThemeImage(int id) const; | |
| 154 SkBitmap GenerateGtkThemeBitmap(int id) const; | |
| 155 | |
| 156 // Creates a GTK+ version of IDR_THEME_FRAME. Instead of tinting, this | |
| 157 // creates a theme configurable gradient ending with |color_id| at the | |
| 158 // bottom, and |gradient_name| at the top if that color is specified in the | |
| 159 // theme. | |
| 160 SkBitmap GenerateFrameImage(int color_id, | |
| 161 const char* gradient_name) const; | |
| 162 | |
| 163 // Takes the base frame image |base_id| and tints it with |tint_id|. | |
| 164 SkBitmap GenerateTabImage(int base_id) const; | |
| 165 | |
| 166 // Tints an icon based on tint. | |
| 167 SkBitmap GenerateTintedIcon(int base_id, | |
| 168 const color_utils::HSL& tint) const; | |
| 169 | |
| 170 // Returns the tint for buttons that contrasts with the normal window | 143 // Returns the tint for buttons that contrasts with the normal window |
| 171 // background color. | 144 // background color. |
| 172 void GetNormalButtonTintHSL(color_utils::HSL* tint) const; | 145 void GetNormalButtonTintHSL(color_utils::HSL* tint) const; |
| 173 | 146 |
| 174 // Returns a tint that's the color of the current normal text in an entry. | 147 // Returns a tint that's the color of the current normal text in an entry. |
| 175 void GetNormalEntryForegroundHSL(color_utils::HSL* tint) const; | 148 void GetNormalEntryForegroundHSL(color_utils::HSL* tint) const; |
| 176 | 149 |
| 177 // Returns a tint that's the color of the current highlighted text in an | 150 // Returns a tint that's the color of the current highlighted text in an |
| 178 // entry. | 151 // entry. |
| 179 void GetSelectedEntryForegroundHSL(color_utils::HSL* tint) const; | 152 void GetSelectedEntryForegroundHSL(color_utils::HSL* tint) const; |
| 180 | 153 |
| 181 // Gets a color for the background of the call to action button. | 154 // Gets a color for the background of the call to action button. |
| 182 SkColor CallToActionBgColor(int gtk_state) const; | 155 SkColor CallToActionBgColor(int gtk_state) const; |
| 183 | 156 |
| 184 // Frees all calculated images and color data. | |
| 185 void ClearAllThemeData(); | |
| 186 | |
| 187 // Updates |default_font_*|. | 157 // Updates |default_font_*|. |
| 188 void UpdateDefaultFont(); | 158 void UpdateDefaultFont(); |
| 189 | 159 |
| 190 // Colors calculated by LoadGtkValues() that are given to the | 160 // Colors calculated by LoadGtkValues() that are given to the |
| 191 // caller while |use_gtk_| is true. | 161 // caller while |use_gtk_| is true. |
| 192 ColorMap colors_; | 162 ColorMap colors_; |
| 193 | 163 |
| 194 // Colors used to tint certain icons. | 164 // Colors used to tint certain icons. |
| 195 color_utils::HSL button_tint_; | 165 color_utils::HSL button_tint_; |
| 196 color_utils::HSL entry_tint_; | 166 color_utils::HSL entry_tint_; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 227 | 197 |
| 228 std::unique_ptr<Gtk2KeyBindingsHandler> key_bindings_handler_; | 198 std::unique_ptr<Gtk2KeyBindingsHandler> key_bindings_handler_; |
| 229 | 199 |
| 230 // Objects to notify when the window frame button order changes. | 200 // Objects to notify when the window frame button order changes. |
| 231 base::ObserverList<views::WindowButtonOrderObserver> observer_list_; | 201 base::ObserverList<views::WindowButtonOrderObserver> observer_list_; |
| 232 | 202 |
| 233 // Whether we should lower the window on a middle click to the non client | 203 // Whether we should lower the window on a middle click to the non client |
| 234 // area. | 204 // area. |
| 235 NonClientMiddleClickAction middle_click_action_; | 205 NonClientMiddleClickAction middle_click_action_; |
| 236 | 206 |
| 237 // Image cache of lazily created images. | |
| 238 mutable ImageCache gtk_images_; | |
| 239 | |
| 240 // Used to override the native theme for a window. If no override is provided | 207 // Used to override the native theme for a window. If no override is provided |
| 241 // or the callback returns NULL, Gtk2UI will default to a NativeThemeGtk2 | 208 // or the callback returns NULL, Gtk2UI will default to a NativeThemeGtk2 |
| 242 // instance. | 209 // instance. |
| 243 NativeThemeGetter native_theme_overrider_; | 210 NativeThemeGetter native_theme_overrider_; |
| 244 | 211 |
| 245 float device_scale_factor_; | 212 float device_scale_factor_; |
| 246 | 213 |
| 247 DISALLOW_COPY_AND_ASSIGN(Gtk2UI); | 214 DISALLOW_COPY_AND_ASSIGN(Gtk2UI); |
| 248 }; | 215 }; |
| 249 | 216 |
| 250 } // namespace libgtk2ui | 217 } // namespace libgtk2ui |
| 251 | 218 |
| 252 // Access point to the GTK2 desktop system. This should be the only symbol that | 219 // Access point to the GTK2 desktop system. This should be the only symbol that |
| 253 // is exported in the library; everything else should be used through the | 220 // is exported in the library; everything else should be used through the |
| 254 // interface, because eventually this .so will be loaded through dlopen at | 221 // interface, because eventually this .so will be loaded through dlopen at |
| 255 // runtime so our main binary can conditionally load GTK2 or GTK3 or EFL or | 222 // runtime so our main binary can conditionally load GTK2 or GTK3 or EFL or |
| 256 // QT or whatever. | 223 // QT or whatever. |
| 257 LIBGTK2UI_EXPORT views::LinuxUI* BuildGtk2UI(); | 224 LIBGTK2UI_EXPORT views::LinuxUI* BuildGtk2UI(); |
| 258 | 225 |
| 259 #endif // CHROME_BROWSER_UI_LIBGTK2UI_GTK2_UI_H_ | 226 #endif // CHROME_BROWSER_UI_LIBGTK2UI_GTK2_UI_H_ |
| OLD | NEW |