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

Side by Side Diff: ui/views/controls/menu/menu_host.cc

Issue 290553002: Refactor menu dependency on aura/wm SetShadowType (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename enum Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/views/touchui/touch_selection_controller_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "ui/events/gestures/gesture_recognizer.h" 9 #include "ui/events/gestures/gesture_recognizer.h"
10 #include "ui/gfx/path.h" 10 #include "ui/gfx/path.h"
11 #include "ui/native_theme/native_theme.h" 11 #include "ui/native_theme/native_theme.h"
12 #include "ui/views/controls/menu/menu_controller.h" 12 #include "ui/views/controls/menu/menu_controller.h"
13 #include "ui/views/controls/menu/menu_host_root_view.h" 13 #include "ui/views/controls/menu/menu_host_root_view.h"
14 #include "ui/views/controls/menu/menu_item_view.h" 14 #include "ui/views/controls/menu/menu_item_view.h"
15 #include "ui/views/controls/menu/menu_scroll_view_container.h" 15 #include "ui/views/controls/menu/menu_scroll_view_container.h"
16 #include "ui/views/controls/menu/submenu_view.h" 16 #include "ui/views/controls/menu/submenu_view.h"
17 #include "ui/views/round_rect_painter.h" 17 #include "ui/views/round_rect_painter.h"
18 #include "ui/views/widget/native_widget_private.h" 18 #include "ui/views/widget/native_widget_private.h"
19 #include "ui/views/widget/widget.h" 19 #include "ui/views/widget/widget.h"
20 #include "ui/wm/core/shadow_types.h"
21 20
22 namespace views { 21 namespace views {
23 22
24 //////////////////////////////////////////////////////////////////////////////// 23 ////////////////////////////////////////////////////////////////////////////////
25 // MenuHost, public: 24 // MenuHost, public:
26 25
27 MenuHost::MenuHost(SubmenuView* submenu) 26 MenuHost::MenuHost(SubmenuView* submenu)
28 : submenu_(submenu), 27 : submenu_(submenu),
29 destroying_(false), 28 destroying_(false),
30 ignore_capture_lost_(false) { 29 ignore_capture_lost_(false) {
31 set_auto_release_capture(false); 30 set_auto_release_capture(false);
32 } 31 }
33 32
34 MenuHost::~MenuHost() { 33 MenuHost::~MenuHost() {
35 } 34 }
36 35
37 void MenuHost::InitMenuHost(Widget* parent, 36 void MenuHost::InitMenuHost(Widget* parent,
38 const gfx::Rect& bounds, 37 const gfx::Rect& bounds,
39 View* contents_view, 38 View* contents_view,
40 bool do_capture) { 39 bool do_capture) {
41 TRACE_EVENT0("views", "MenuHost::InitMenuHost"); 40 TRACE_EVENT0("views", "MenuHost::InitMenuHost");
42 Widget::InitParams params(Widget::InitParams::TYPE_MENU); 41 Widget::InitParams params(Widget::InitParams::TYPE_MENU);
43 const MenuController* menu_controller = 42 const MenuController* menu_controller =
44 submenu_->GetMenuItem()->GetMenuController(); 43 submenu_->GetMenuItem()->GetMenuController();
45 const MenuConfig& menu_config = submenu_->GetMenuItem()->GetMenuConfig(); 44 const MenuConfig& menu_config = submenu_->GetMenuItem()->GetMenuConfig();
46 bool rounded_border = menu_controller && menu_config.corner_radius > 0; 45 bool rounded_border = menu_controller && menu_config.corner_radius > 0;
47 bool bubble_border = submenu_->GetScrollViewContainer() && 46 bool bubble_border = submenu_->GetScrollViewContainer() &&
48 submenu_->GetScrollViewContainer()->HasBubbleBorder(); 47 submenu_->GetScrollViewContainer()->HasBubbleBorder();
49 params.has_dropshadow = !bubble_border; 48 params.shadow_type = bubble_border ? Widget::InitParams::SHADOW_TYPE_NONE
49 : Widget::InitParams::SHADOW_TYPE_DROP;
50 params.opacity = (bubble_border || rounded_border) ? 50 params.opacity = (bubble_border || rounded_border) ?
51 Widget::InitParams::TRANSLUCENT_WINDOW : 51 Widget::InitParams::TRANSLUCENT_WINDOW :
52 Widget::InitParams::OPAQUE_WINDOW; 52 Widget::InitParams::OPAQUE_WINDOW;
53 params.parent = parent ? parent->GetNativeView() : NULL; 53 params.parent = parent ? parent->GetNativeView() : NULL;
54 params.bounds = bounds; 54 params.bounds = bounds;
55 Init(params); 55 Init(params);
56 56
57 if (bubble_border)
58 SetShadowType(GetNativeView(), wm::SHADOW_TYPE_NONE);
59
60 SetContentsView(contents_view); 57 SetContentsView(contents_view);
61 if (bubble_border || rounded_border) 58 if (bubble_border || rounded_border)
62 SetOpacity(0); 59 SetOpacity(0);
63 ShowMenuHost(do_capture); 60 ShowMenuHost(do_capture);
64 } 61 }
65 62
66 bool MenuHost::IsMenuHostVisible() { 63 bool MenuHost::IsMenuHostVisible() {
67 return IsVisible(); 64 return IsVisible();
68 } 65 }
69 66
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 if (destroying_) 131 if (destroying_)
135 return; 132 return;
136 133
137 MenuController* menu_controller = 134 MenuController* menu_controller =
138 submenu_->GetMenuItem()->GetMenuController(); 135 submenu_->GetMenuItem()->GetMenuController();
139 if (menu_controller && !menu_controller->drag_in_progress()) 136 if (menu_controller && !menu_controller->drag_in_progress())
140 menu_controller->CancelAll(); 137 menu_controller->CancelAll();
141 } 138 }
142 139
143 } // namespace views 140 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/touchui/touch_selection_controller_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698