summaryrefslogtreecommitdiffstats
path: root/ui/native_theme
diff options
context:
space:
mode:
authorvarunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-29 02:31:12 +0000
committervarunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-29 02:31:12 +0000
commite95cacb738f1b29fb9b7c13e889ebff81e3dc03d (patch)
treed5708e86247f7b0d1c95b3bf08073de1252a3a97 /ui/native_theme
parente80d4b35472e692f05e986116a5910e1a9612f74 (diff)
downloadchromium_src-e95cacb738f1b29fb9b7c13e889ebff81e3dc03d.zip
chromium_src-e95cacb738f1b29fb9b7c13e889ebff81e3dc03d.tar.gz
chromium_src-e95cacb738f1b29fb9b7c13e889ebff81e3dc03d.tar.bz2
Fix menu corners: the menu background was being painted as a rect when in fact,
the border is a rounded rect. In this CL, I change the menu background painting code to paint a rounded rect instead. I also had to make the hosting widget transparent to avoid showing black background around the rounded corners. One more fix was needed: a selected item in a menu is indicated by painting a highlight colored rectangle background for that item. Due to this, selecting the topmost or the bottom-most item messes up the roundedness of the menu background. I fix this by simply adding a padding inside the menu so that the highlighted background of the item does not overlap the rounded corners of the menu. BUG=171703 Review URL: https://chromiumcodereview.appspot.com/12041085 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179267 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/native_theme')
-rw-r--r--ui/native_theme/native_theme.h5
-rw-r--r--ui/native_theme/native_theme_aura.cc26
-rw-r--r--ui/native_theme/native_theme_aura.h6
-rw-r--r--ui/native_theme/native_theme_base.cc8
-rw-r--r--ui/native_theme/native_theme_base.h6
5 files changed, 41 insertions, 10 deletions
diff --git a/ui/native_theme/native_theme.h b/ui/native_theme/native_theme.h
index 0c5499e..2958609 100644
--- a/ui/native_theme/native_theme.h
+++ b/ui/native_theme/native_theme.h
@@ -135,6 +135,10 @@ class NATIVE_THEME_EXPORT NativeTheme {
bool has_gutter;
};
+ struct MenuBackgroundExtraParams {
+ int corner_radius;
+ };
+
struct ProgressBarExtraParams {
double animated_seconds;
bool determinate;
@@ -190,6 +194,7 @@ class NATIVE_THEME_EXPORT NativeTheme {
MenuItemExtraParams menu_item;
MenuListExtraParams menu_list;
MenuSeparatorExtraParams menu_separator;
+ MenuBackgroundExtraParams menu_background;
ProgressBarExtraParams progress_bar;
ScrollbarArrowExtraParams scrollbar_arrow;
ScrollbarTrackExtraParams scrollbar_track;
diff --git a/ui/native_theme/native_theme_aura.cc b/ui/native_theme/native_theme_aura.cc
index 6382593..b1f41e4 100644
--- a/ui/native_theme/native_theme_aura.cc
+++ b/ui/native_theme/native_theme_aura.cc
@@ -9,6 +9,7 @@
#include "ui/base/layout.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image_skia.h"
+#include "ui/gfx/path.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
#include "ui/gfx/skbitmap_operations.h"
@@ -193,9 +194,28 @@ SkColor NativeThemeAura::GetSystemColor(ColorId color_id) const {
return kInvalidColorIdColor;
}
-void NativeThemeAura::PaintMenuPopupBackground(SkCanvas* canvas,
- const gfx::Size& size) const {
- canvas->drawColor(kMenuBackgroundColor, SkXfermode::kSrc_Mode);
+void NativeThemeAura::PaintMenuPopupBackground(
+ SkCanvas* canvas,
+ const gfx::Size& size,
+ const MenuBackgroundExtraParams& menu_background) const {
+ if (menu_background.corner_radius > 0) {
+ SkPaint paint;
+ paint.setStyle(SkPaint::kFill_Style);
+ paint.setFlags(SkPaint::kAntiAlias_Flag);
+ paint.setColor(kMenuBackgroundColor);
+
+ gfx::Path path;
+ SkRect rect = SkRect::MakeWH(SkIntToScalar(size.width()),
+ SkIntToScalar(size.height()));
+ SkScalar radius = SkIntToScalar(menu_background.corner_radius);
+ SkScalar radii[8] = {radius, radius, radius, radius,
+ radius, radius, radius, radius};
+ path.addRoundRect(rect, radii);
+
+ canvas->drawPath(path, paint);
+ } else {
+ canvas->drawColor(kMenuBackgroundColor, SkXfermode::kSrc_Mode);
+ }
}
void NativeThemeAura::PaintScrollbarTrack(
diff --git a/ui/native_theme/native_theme_aura.h b/ui/native_theme/native_theme_aura.h
index d1d3d0d..1780e9c 100644
--- a/ui/native_theme/native_theme_aura.h
+++ b/ui/native_theme/native_theme_aura.h
@@ -22,8 +22,10 @@ class NATIVE_THEME_EXPORT NativeThemeAura : public NativeThemeBase {
// Overridden from NativeThemeBase:
virtual SkColor GetSystemColor(ColorId color_id) const OVERRIDE;
- virtual void PaintMenuPopupBackground(SkCanvas* canvas,
- const gfx::Size& size) const OVERRIDE;
+ virtual void PaintMenuPopupBackground(
+ SkCanvas* canvas,
+ const gfx::Size& size,
+ const MenuBackgroundExtraParams& menu_background) const OVERRIDE;
virtual void PaintScrollbarTrack(
SkCanvas* canvas,
Part part,
diff --git a/ui/native_theme/native_theme_base.cc b/ui/native_theme/native_theme_base.cc
index 7a833f6..70dbcc4 100644
--- a/ui/native_theme/native_theme_base.cc
+++ b/ui/native_theme/native_theme_base.cc
@@ -176,7 +176,7 @@ void NativeThemeBase::Paint(SkCanvas* canvas,
NOTIMPLEMENTED();
break;
case kMenuPopupBackground:
- PaintMenuPopupBackground(canvas, rect.size());
+ PaintMenuPopupBackground(canvas, rect.size(), extra.menu_background);
break;
case kMenuPopupGutter:
case kMenuPopupSeparator:
@@ -867,8 +867,10 @@ void NativeThemeBase::PaintMenuList(
canvas->drawPath(path, paint);
}
-void NativeThemeBase::PaintMenuPopupBackground(SkCanvas* canvas,
- const gfx::Size& size) const {
+void NativeThemeBase::PaintMenuPopupBackground(
+ SkCanvas* canvas,
+ const gfx::Size& size,
+ const MenuBackgroundExtraParams& menu_background) const {
canvas->drawColor(kMenuPopupBackgroundColor, SkXfermode::kSrc_Mode);
}
diff --git a/ui/native_theme/native_theme_base.h b/ui/native_theme/native_theme_base.h
index 0705665..633cb46 100644
--- a/ui/native_theme/native_theme_base.h
+++ b/ui/native_theme/native_theme_base.h
@@ -86,8 +86,10 @@ class NATIVE_THEME_EXPORT NativeThemeBase : public NativeTheme {
const gfx::Rect& rect,
const MenuListExtraParams& menu_list) const;
- virtual void PaintMenuPopupBackground(SkCanvas* canvas,
- const gfx::Size& size) const;
+ virtual void PaintMenuPopupBackground(
+ SkCanvas* canvas,
+ const gfx::Size& size,
+ const MenuBackgroundExtraParams& menu_background) const;
virtual void PaintMenuItemBackground(
SkCanvas* canvas,