OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/ui/libgtkui/gtk_ui.h" | 5 #include "chrome/browser/ui/libgtkui/gtk_ui.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <pango/pango.h> | 8 #include <pango/pango.h> |
9 #include <X11/Xcursor/Xcursor.h> | 9 #include <X11/Xcursor/Xcursor.h> |
10 | 10 |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 | 229 |
230 // Prefix for app indicator ids | 230 // Prefix for app indicator ids |
231 const char kAppIndicatorIdPrefix[] = "chrome_app_indicator_"; | 231 const char kAppIndicatorIdPrefix[] = "chrome_app_indicator_"; |
232 | 232 |
233 // Number of app indicators used (used as part of app-indicator id). | 233 // Number of app indicators used (used as part of app-indicator id). |
234 int indicators_count; | 234 int indicators_count; |
235 | 235 |
236 // The unknown content type. | 236 // The unknown content type. |
237 const char* kUnknownContentType = "application/octet-stream"; | 237 const char* kUnknownContentType = "application/octet-stream"; |
238 | 238 |
239 // TODO(erg): ThemeService has a whole interface just for reading default | |
240 // constants. Figure out what to do with that more long term; for now, just | |
241 // copy the constants themselves here. | |
242 // | |
243 // Default tints. | |
244 const color_utils::HSL kDefaultTintFrameIncognito = {-1, 0.2f, 0.35f}; | |
245 #if GTK_MAJOR_VERSION == 2 | |
246 const color_utils::HSL kDefaultTintFrameIncognitoInactive = {-1, 0.3f, 0.6f}; | |
247 #endif | |
248 | |
249 // Picks a button tint from a set of background colors. While | 239 // Picks a button tint from a set of background colors. While |
250 // |accent_color| will usually be the same color through a theme, this | 240 // |accent_color| will usually be the same color through a theme, this |
251 // function will get called with the normal GtkLabel |text_color|/GtkWindow | 241 // function will get called with the normal GtkLabel |text_color|/GtkWindow |
252 // |background_color| pair and the GtkEntry |text_color|/|background_color| | 242 // |background_color| pair and the GtkEntry |text_color|/|background_color| |
253 // pair. While 3/4 of the time the resulting tint will be the same, themes that | 243 // pair. While 3/4 of the time the resulting tint will be the same, themes that |
254 // have a dark window background (with light text) and a light text entry (with | 244 // have a dark window background (with light text) and a light text entry (with |
255 // dark text) will get better icons with this separated out. | 245 // dark text) will get better icons with this separated out. |
256 void PickButtonTintFromColors(SkColor accent_color, | 246 void PickButtonTintFromColors(SkColor accent_color, |
257 SkColor text_color, | 247 SkColor text_color, |
258 SkColor background_color, | 248 SkColor background_color, |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 if (theme) | 892 if (theme) |
903 XcursorSetTheme(gfx::GetXDisplay(), theme); | 893 XcursorSetTheme(gfx::GetXDisplay(), theme); |
904 if (size) | 894 if (size) |
905 XcursorSetDefaultSize(gfx::GetXDisplay(), size); | 895 XcursorSetDefaultSize(gfx::GetXDisplay(), size); |
906 | 896 |
907 g_free(theme); | 897 g_free(theme); |
908 } | 898 } |
909 | 899 |
910 void GtkUi::BuildFrameColors() { | 900 void GtkUi::BuildFrameColors() { |
911 #if GTK_MAJOR_VERSION == 2 | 901 #if GTK_MAJOR_VERSION == 2 |
912 color_utils::HSL kDefaultFrameShift = {-1, -1, 0.4}; | 902 const color_utils::HSL kDefaultFrameShift = {-1, -1, 0.4}; |
913 SkColor frame_color = | 903 SkColor frame_color = |
914 native_theme_->GetSystemColor(ui::NativeTheme::kColorId_WindowBackground); | 904 native_theme_->GetSystemColor(ui::NativeTheme::kColorId_WindowBackground); |
915 frame_color = color_utils::HSLShift(frame_color, kDefaultFrameShift); | 905 frame_color = color_utils::HSLShift(frame_color, kDefaultFrameShift); |
916 GetChromeStyleColor("frame-color", &frame_color); | 906 GetChromeStyleColor("frame-color", &frame_color); |
917 colors_[ThemeProperties::COLOR_FRAME] = frame_color; | 907 colors_[ThemeProperties::COLOR_FRAME] = frame_color; |
918 | 908 |
919 GtkStyle* style = gtk_rc_get_style(fake_window_); | 909 GtkStyle* style = gtk_rc_get_style(fake_window_); |
920 SkColor temp_color = color_utils::HSLShift( | 910 SkColor temp_color = color_utils::HSLShift( |
921 GdkColorToSkColor(style->bg[GTK_STATE_INSENSITIVE]), kDefaultFrameShift); | 911 GdkColorToSkColor(style->bg[GTK_STATE_INSENSITIVE]), kDefaultFrameShift); |
922 GetChromeStyleColor("inactive-frame-color", &temp_color); | 912 GetChromeStyleColor("inactive-frame-color", &temp_color); |
923 colors_[ThemeProperties::COLOR_FRAME_INACTIVE] = temp_color; | 913 colors_[ThemeProperties::COLOR_FRAME_INACTIVE] = temp_color; |
924 | 914 |
925 temp_color = color_utils::HSLShift(frame_color, kDefaultTintFrameIncognito); | 915 temp_color = color_utils::HSLShift(frame_color, kDefaultTintFrameIncognito); |
926 GetChromeStyleColor("incognito-frame-color", &temp_color); | 916 GetChromeStyleColor("incognito-frame-color", &temp_color); |
927 colors_[ThemeProperties::COLOR_FRAME_INCOGNITO] = temp_color; | 917 colors_[ThemeProperties::COLOR_FRAME_INCOGNITO] = temp_color; |
928 | 918 |
929 temp_color = | 919 temp_color = |
930 color_utils::HSLShift(frame_color, kDefaultTintFrameIncognitoInactive); | 920 color_utils::HSLShift(frame_color, kDefaultTintFrameIncognitoInactive); |
931 GetChromeStyleColor("incognito-inactive-frame-color", &temp_color); | 921 GetChromeStyleColor("incognito-inactive-frame-color", &temp_color); |
932 colors_[ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE] = temp_color; | 922 colors_[ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE] = temp_color; |
933 #else | 923 #else |
934 // TODO(thomasanderson): Render a GtkHeaderBar directly. | |
935 SkColor color_frame = GetBgColor("#headerbar.header-bar.titlebar"); | 924 SkColor color_frame = GetBgColor("#headerbar.header-bar.titlebar"); |
936 SkColor color_frame_inactive = | 925 SkColor color_frame_inactive = |
937 GetBgColor("#headerbar.header-bar.titlebar:backdrop"); | 926 GetBgColor("#headerbar.header-bar.titlebar:backdrop"); |
938 colors_[ThemeProperties::COLOR_FRAME] = color_frame; | 927 colors_[ThemeProperties::COLOR_FRAME] = color_frame; |
939 colors_[ThemeProperties::COLOR_FRAME_INACTIVE] = color_frame_inactive; | 928 colors_[ThemeProperties::COLOR_FRAME_INACTIVE] = color_frame_inactive; |
940 colors_[ThemeProperties::COLOR_FRAME_INCOGNITO] = | 929 colors_[ThemeProperties::COLOR_FRAME_INCOGNITO] = |
941 color_utils::HSLShift(color_frame, kDefaultTintFrameIncognito); | 930 color_utils::HSLShift(color_frame, kDefaultTintFrameIncognito); |
942 colors_[ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE] = | 931 colors_[ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE] = |
943 color_utils::HSLShift(color_frame_inactive, kDefaultTintFrameIncognito); | 932 color_utils::HSLShift(color_frame_inactive, kDefaultTintFrameIncognito); |
944 #endif | 933 #endif |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 | 1042 |
1054 float GtkUi::GetDeviceScaleFactor() const { | 1043 float GtkUi::GetDeviceScaleFactor() const { |
1055 return device_scale_factor_; | 1044 return device_scale_factor_; |
1056 } | 1045 } |
1057 | 1046 |
1058 } // namespace libgtkui | 1047 } // namespace libgtkui |
1059 | 1048 |
1060 views::LinuxUI* BuildGtkUi() { | 1049 views::LinuxUI* BuildGtkUi() { |
1061 return new libgtkui::GtkUi; | 1050 return new libgtkui::GtkUi; |
1062 } | 1051 } |
OLD | NEW |