summaryrefslogtreecommitdiffstats
path: root/ui/native_theme
diff options
context:
space:
mode:
authoryefim@chromium.org <yefim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-26 19:07:05 +0000
committeryefim@chromium.org <yefim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-26 19:07:05 +0000
commit5301f56fe5649cc9e0d7d03559c74bdcd1ce04dc (patch)
tree947a64ea21d2aa0a754987d4b01867561bdbf1b1 /ui/native_theme
parentf9bdad57c58d438019732ae0b490a20ba40bbddd (diff)
downloadchromium_src-5301f56fe5649cc9e0d7d03559c74bdcd1ce04dc.zip
chromium_src-5301f56fe5649cc9e0d7d03559c74bdcd1ce04dc.tar.gz
chromium_src-5301f56fe5649cc9e0d7d03559c74bdcd1ce04dc.tar.bz2
Added inverted color scheme support to new menu style.
BUG=177233 Review URL: https://codereview.chromium.org/12334077 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@184683 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/native_theme')
-rw-r--r--ui/native_theme/common_theme.cc30
1 files changed, 27 insertions, 3 deletions
diff --git a/ui/native_theme/common_theme.cc b/ui/native_theme/common_theme.cc
index eb457d7..90e4db5 100644
--- a/ui/native_theme/common_theme.cc
+++ b/ui/native_theme/common_theme.cc
@@ -8,9 +8,11 @@
#include "grit/ui_resources.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "ui/base/resource/resource_bundle.h"
+#include "ui/gfx/color_utils.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/skia_util.h"
+#include "ui/gfx/sys_color_change_listener.h"
#include "ui/views/controls/menu/menu_config.h"
namespace {
@@ -20,6 +22,8 @@ namespace {
// MenuItem:
const SkColor kMenuBackgroundColor = SK_ColorWHITE;
const SkColor kMenuHighlightBackgroundColor = SkColorSetA(SK_ColorBLACK, 15);
+const SkColor kMenuInvertedSchemeHighlightBackgroundColor =
+ SkColorSetRGB(48, 48, 48);
const SkColor kMenuBorderColor = SkColorSetRGB(0xBA, 0xBA, 0xBA);
const SkColor kMenuSeparatorColor = SkColorSetRGB(0xE9, 0xE9, 0xE9);
const SkColor kEnabledMenuItemForegroundColor = SK_ColorBLACK;
@@ -56,6 +60,15 @@ bool CommonThemeGetSystemColor(NativeTheme::ColorId color_id, SkColor* color) {
default:
return false;
}
+ if (gfx::IsInvertedColorScheme()) {
+ switch (color_id) {
+ case NativeTheme::kColorId_FocusedMenuItemBackgroundColor:
+ *color = kMenuInvertedSchemeHighlightBackgroundColor;
+ break;
+ default:
+ *color = color_utils::InvertColor(*color);
+ }
+ }
return true;
}
@@ -82,6 +95,8 @@ void CommonThemePaintMenuSeparator(
SkCanvas* canvas,
const gfx::Rect& rect,
const NativeTheme::MenuSeparatorExtraParams& extra) {
+ SkColor color;
+ CommonThemeGetSystemColor(NativeTheme::kColorId_MenuSeparatorColor, &color);
SkPaint paint;
paint.setColor(kMenuSeparatorColor);
int position_y = rect.y() + rect.height() / 2;
@@ -89,6 +104,8 @@ void CommonThemePaintMenuSeparator(
}
void CommonThemePaintMenuGutter(SkCanvas* canvas, const gfx::Rect& rect) {
+ SkColor color;
+ CommonThemeGetSystemColor(NativeTheme::kColorId_MenuSeparatorColor, &color);
SkPaint paint;
paint.setColor(kMenuSeparatorColor);
int position_x = rect.x() + rect.width() / 2;
@@ -96,22 +113,29 @@ void CommonThemePaintMenuGutter(SkCanvas* canvas, const gfx::Rect& rect) {
}
void CommonThemePaintMenuBackground(SkCanvas* canvas, const gfx::Rect& rect) {
+ SkColor color;
+ CommonThemeGetSystemColor(NativeTheme::kColorId_MenuBackgroundColor, &color);
SkPaint paint;
- paint.setColor(kMenuBackgroundColor);
+ paint.setColor(color);
canvas->drawRect(gfx::RectToSkRect(rect), paint);
}
void CommonThemePaintMenuItemBackground(SkCanvas* canvas,
NativeTheme::State state,
const gfx::Rect& rect) {
+ SkColor color;
SkPaint paint;
switch (state) {
case NativeTheme::kNormal:
case NativeTheme::kDisabled:
- paint.setColor(kMenuBackgroundColor);
+ CommonThemeGetSystemColor(NativeTheme::kColorId_MenuBackgroundColor,
+ &color);
+ paint.setColor(color);
break;
case NativeTheme::kHovered:
- paint.setColor(kMenuHighlightBackgroundColor);
+ CommonThemeGetSystemColor(
+ NativeTheme::kColorId_FocusedMenuItemBackgroundColor, &color);
+ paint.setColor(color);
break;
default:
NOTREACHED() << "Invalid state " << state;