diff options
author | yefim@chromium.org <yefim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-21 22:47:54 +0000 |
---|---|---|
committer | yefim@chromium.org <yefim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-21 22:47:54 +0000 |
commit | 2e5cd126464cbe8c382d375697a9dee15fae38c2 (patch) | |
tree | 103a0ccb2f726fc0c2702181c5662dc9c236e833 /ui | |
parent | 3a0158f0eaa5fbea107f5c3361cacf2a310188bb (diff) | |
download | chromium_src-2e5cd126464cbe8c382d375697a9dee15fae38c2.zip chromium_src-2e5cd126464cbe8c382d375697a9dee15fae38c2.tar.gz chromium_src-2e5cd126464cbe8c382d375697a9dee15fae38c2.tar.bz2 |
Made rounded menu corners transparent (views).
BUG=157692
Review URL: https://chromiumcodereview.appspot.com/11417107
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169149 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/views/controls/menu/menu_host.cc | 11 | ||||
-rw-r--r-- | ui/views/round_rect_painter.cc | 12 | ||||
-rw-r--r-- | ui/views/round_rect_painter.h | 4 |
3 files changed, 27 insertions, 0 deletions
diff --git a/ui/views/controls/menu/menu_host.cc b/ui/views/controls/menu/menu_host.cc index 76a6e4a..dccd64e 100644 --- a/ui/views/controls/menu/menu_host.cc +++ b/ui/views/controls/menu/menu_host.cc @@ -4,10 +4,13 @@ #include "ui/views/controls/menu/menu_host.h" +#include "ui/gfx/path.h" +#include "ui/native_theme/native_theme.h" #include "ui/views/controls/menu/menu_controller.h" #include "ui/views/controls/menu/menu_host_root_view.h" #include "ui/views/controls/menu/menu_item_view.h" #include "ui/views/controls/menu/submenu_view.h" +#include "ui/views/round_rect_painter.h" #include "ui/views/widget/native_widget_private.h" #include "ui/views/widget/widget.h" @@ -34,6 +37,14 @@ void MenuHost::InitMenuHost(Widget* parent, params.parent_widget = parent; params.bounds = bounds; Init(params); + + if (ui::NativeTheme::IsNewMenuStyleEnabled()) { + // TODO(yefim): Investigate it more on aura. + gfx::Path path; + RoundRectPainter::CreateRoundRectPath(bounds, &path); + SetShape(path.CreateNativeRegion()); + } + SetContentsView(contents_view); ShowMenuHost(do_capture); } diff --git a/ui/views/round_rect_painter.cc b/ui/views/round_rect_painter.cc index ec8c179..2492e92 100644 --- a/ui/views/round_rect_painter.cc +++ b/ui/views/round_rect_painter.cc @@ -5,6 +5,7 @@ #include "ui/views/round_rect_painter.h" #include "ui/gfx/canvas.h" +#include "ui/gfx/path.h" #include "ui/gfx/skia_util.h" namespace views { @@ -32,4 +33,15 @@ void RoundRectPainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) { SkIntToScalar(kRadius), paint); } +// static +void RoundRectPainter::CreateRoundRectPath(const gfx::Rect& bounds, + gfx::Path* path) { + SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), + SkIntToScalar(bounds.height())); + SkScalar radius = SkIntToScalar(kRadius); + SkScalar radii[8] = {radius, radius, radius, radius, + radius, radius, radius, radius}; + path->addRoundRect(rect, radii); +} + } // namespace views diff --git a/ui/views/round_rect_painter.h b/ui/views/round_rect_painter.h index 3e4b5ca..7eac9c5 100644 --- a/ui/views/round_rect_painter.h +++ b/ui/views/round_rect_painter.h @@ -11,6 +11,7 @@ namespace gfx { class Canvas; +class Path; class Size; } @@ -25,6 +26,9 @@ class VIEWS_EXPORT RoundRectPainter : public Painter { // Painter overrides: virtual void Paint(gfx::Canvas* canvas, const gfx::Size& size) OVERRIDE; + // Creates |path| for the same rectangle Paint() will draw. + static void CreateRoundRectPath(const gfx::Rect& bounds, gfx::Path* path); + private: const SkColor border_color_; |