| OLD | NEW |
| (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 #include "ui/base/native_theme/native_theme_gtk.h" | |
| 6 | |
| 7 #include <gtk/gtk.h> | |
| 8 | |
| 9 #include "base/basictypes.h" | |
| 10 #include "base/logging.h" | |
| 11 #include "ui/gfx/skia_utils_gtk.h" | |
| 12 | |
| 13 namespace { | |
| 14 | |
| 15 const SkColor kInvalidColorIdColor = SkColorSetRGB(255, 0, 128); | |
| 16 | |
| 17 // Theme colors returned by GetSystemColor(). | |
| 18 | |
| 19 // FocusableBorder: | |
| 20 const SkColor kFocusedBorderColor = SkColorSetRGB(0x4D, 0x90, 0xFE); | |
| 21 const SkColor kUnfocusedBorderColor = SkColorSetRGB(0xD9, 0xD9, 0xD9); | |
| 22 | |
| 23 // TextButton: | |
| 24 const SkColor kTextButtonBackgroundColor = SkColorSetRGB(0xde, 0xde, 0xde); | |
| 25 const SkColor kTextButtonEnabledColor = SkColorSetRGB(6, 45, 117); | |
| 26 const SkColor kTextButtonDisabledColor = SkColorSetRGB(161, 161, 146); | |
| 27 const SkColor kTextButtonHighlightColor = SkColorSetARGB(200, 255, 255, 255); | |
| 28 const SkColor kTextButtonHoverColor = kTextButtonEnabledColor; | |
| 29 | |
| 30 } // namespace | |
| 31 | |
| 32 namespace ui { | |
| 33 | |
| 34 // static | |
| 35 const NativeTheme* NativeTheme::instance() { | |
| 36 return NativeThemeGtk::instance(); | |
| 37 } | |
| 38 | |
| 39 // static | |
| 40 const NativeThemeGtk* NativeThemeGtk::instance() { | |
| 41 CR_DEFINE_STATIC_LOCAL(NativeThemeGtk, s_native_theme, ()); | |
| 42 return &s_native_theme; | |
| 43 } | |
| 44 | |
| 45 SkColor NativeThemeGtk::GetSystemColor(ColorId color_id) const { | |
| 46 switch (color_id) { | |
| 47 case kColorId_DialogBackground: | |
| 48 // TODO(benrg): This code used to call gtk_widget_get_style() on the | |
| 49 // widget being styled. After refactoring, that widget is not available | |
| 50 // and we have to call gtk_widget_get_default_style(). Unfortunately, | |
| 51 // it turns out that this breaks everything (chromium bug 105609, | |
| 52 // chromium-os bug 23461). Need to figure out the right thing and do it. | |
| 53 return gfx::GdkColorToSkColor( | |
| 54 gtk_widget_get_default_style()->bg[GTK_STATE_NORMAL]); | |
| 55 | |
| 56 // FocusableBorder: | |
| 57 case kColorId_FocusedBorderColor: | |
| 58 return kFocusedBorderColor; | |
| 59 case kColorId_UnfocusedBorderColor: | |
| 60 return kUnfocusedBorderColor; | |
| 61 | |
| 62 // TextButton: | |
| 63 case kColorId_TextButtonBackgroundColor: | |
| 64 return kTextButtonBackgroundColor; | |
| 65 case kColorId_TextButtonEnabledColor: | |
| 66 return kTextButtonEnabledColor; | |
| 67 case kColorId_TextButtonDisabledColor: | |
| 68 return kTextButtonDisabledColor; | |
| 69 case kColorId_TextButtonHighlightColor: | |
| 70 return kTextButtonHighlightColor; | |
| 71 case kColorId_TextButtonHoverColor: | |
| 72 return kTextButtonHoverColor; | |
| 73 | |
| 74 default: | |
| 75 NOTREACHED() << "Invalid color_id: " << color_id; | |
| 76 break; | |
| 77 } | |
| 78 return kInvalidColorIdColor; | |
| 79 } | |
| 80 | |
| 81 NativeThemeGtk::NativeThemeGtk() { | |
| 82 } | |
| 83 | |
| 84 NativeThemeGtk::~NativeThemeGtk() { | |
| 85 } | |
| 86 | |
| 87 } // namespace ui | |
| OLD | NEW |