Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/controls/menu/menu_host.h" | 5 #include "ui/views/controls/menu/menu_host.h" |
| 6 | 6 |
| 7 #include "ui/gfx/path.h" | 7 #include "ui/gfx/path.h" |
| 8 #include "ui/native_theme/native_theme.h" | 8 #include "ui/native_theme/native_theme.h" |
| 9 #include "ui/views/controls/menu/menu_controller.h" | 9 #include "ui/views/controls/menu/menu_controller.h" |
| 10 #include "ui/views/controls/menu/menu_host_root_view.h" | 10 #include "ui/views/controls/menu/menu_host_root_view.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 } | 29 } |
| 30 | 30 |
| 31 void MenuHost::InitMenuHost(Widget* parent, | 31 void MenuHost::InitMenuHost(Widget* parent, |
| 32 const gfx::Rect& bounds, | 32 const gfx::Rect& bounds, |
| 33 View* contents_view, | 33 View* contents_view, |
| 34 bool do_capture) { | 34 bool do_capture) { |
| 35 Widget::InitParams params(Widget::InitParams::TYPE_MENU); | 35 Widget::InitParams params(Widget::InitParams::TYPE_MENU); |
| 36 params.has_dropshadow = true; | 36 params.has_dropshadow = true; |
| 37 params.parent = parent ? parent->GetNativeView() : NULL; | 37 params.parent = parent ? parent->GetNativeView() : NULL; |
| 38 params.bounds = bounds; | 38 params.bounds = bounds; |
| 39 if (MenuConfig::instance(ui::NativeTheme::instance()).has_rounded_corners) | |
|
sky
2013/01/25 16:10:52
Don't use ui::NativeTheme::instance() here, it mig
varunjain
2013/01/25 18:50:40
Done.
| |
| 40 params.transparent = true; | |
| 39 Init(params); | 41 Init(params); |
| 40 | 42 |
| 41 if (ui::NativeTheme::IsNewMenuStyleEnabled()) { | 43 if (ui::NativeTheme::IsNewMenuStyleEnabled()) { |
|
sky
2013/01/25 16:10:52
Only do this if there are rounded corners.
varunjain
2013/01/25 18:50:40
Done.
| |
| 42 // TODO(yefim): Investigate it more on aura. | 44 // TODO(yefim): Investigate it more on aura. |
| 43 gfx::Path path; | 45 gfx::Path path; |
| 44 RoundRectPainter::CreateRoundRectPath(bounds, &path); | 46 RoundRectPainter::CreateRoundRectPath(bounds, &path); |
| 45 SetShape(path.CreateNativeRegion()); | 47 SetShape(path.CreateNativeRegion()); |
| 46 } | 48 } |
| 47 | 49 |
| 48 SetContentsView(contents_view); | 50 SetContentsView(contents_view); |
| 51 if (MenuConfig::instance(ui::NativeTheme::instance()).has_rounded_corners) | |
| 52 SetOpacity(0); | |
| 49 ShowMenuHost(do_capture); | 53 ShowMenuHost(do_capture); |
| 50 } | 54 } |
| 51 | 55 |
| 52 bool MenuHost::IsMenuHostVisible() { | 56 bool MenuHost::IsMenuHostVisible() { |
| 53 return IsVisible(); | 57 return IsVisible(); |
| 54 } | 58 } |
| 55 | 59 |
| 56 void MenuHost::ShowMenuHost(bool do_capture) { | 60 void MenuHost::ShowMenuHost(bool do_capture) { |
| 57 // Doing a capture may make us get capture lost. Ignore it while we're in the | 61 // Doing a capture may make us get capture lost. Ignore it while we're in the |
| 58 // process of showing. | 62 // process of showing. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 if (destroying_) | 125 if (destroying_) |
| 122 return; | 126 return; |
| 123 | 127 |
| 124 MenuController* menu_controller = | 128 MenuController* menu_controller = |
| 125 submenu_->GetMenuItem()->GetMenuController(); | 129 submenu_->GetMenuItem()->GetMenuController(); |
| 126 if (menu_controller && !menu_controller->drag_in_progress()) | 130 if (menu_controller && !menu_controller->drag_in_progress()) |
| 127 menu_controller->CancelAll(); | 131 menu_controller->CancelAll(); |
| 128 } | 132 } |
| 129 | 133 |
| 130 } // namespace views | 134 } // namespace views |
| OLD | NEW |