summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;