Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Unified Diff: ui/native_theme/common_theme.cc

Issue 12334077: Added inverted color scheme support to new menu style. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/native_theme/common_theme.cc
diff --git a/ui/native_theme/common_theme.cc b/ui/native_theme/common_theme.cc
index eb457d7d8c7b31a343482f23f317298b055904f6..90e4db5ab9be6984be894752ec6cb8d82a22db49 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;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698