| 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 "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" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 bool bubble_border = submenu_->GetScrollViewContainer() && | 47 bool bubble_border = submenu_->GetScrollViewContainer() && |
| 48 submenu_->GetScrollViewContainer()->HasBubbleBorder(); | 48 submenu_->GetScrollViewContainer()->HasBubbleBorder(); |
| 49 params.has_dropshadow = !bubble_border; | 49 params.has_dropshadow = !bubble_border; |
| 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 defined(USE_AURA) |
| 57 if (bubble_border) | 58 if (bubble_border) |
| 58 SetShadowType(GetNativeView(), wm::SHADOW_TYPE_NONE); | 59 SetShadowType(GetNativeView(), wm::SHADOW_TYPE_NONE); |
| 60 #endif |
| 59 | 61 |
| 60 SetContentsView(contents_view); | 62 SetContentsView(contents_view); |
| 61 if (bubble_border || rounded_border) | 63 if (bubble_border || rounded_border) |
| 62 SetOpacity(0); | 64 SetOpacity(0); |
| 63 ShowMenuHost(do_capture); | 65 ShowMenuHost(do_capture); |
| 64 } | 66 } |
| 65 | 67 |
| 66 bool MenuHost::IsMenuHostVisible() { | 68 bool MenuHost::IsMenuHostVisible() { |
| 67 return IsVisible(); | 69 return IsVisible(); |
| 68 } | 70 } |
| 69 | 71 |
| 70 void MenuHost::ShowMenuHost(bool do_capture) { | 72 void MenuHost::ShowMenuHost(bool do_capture) { |
| 71 // Doing a capture may make us get capture lost. Ignore it while we're in the | 73 // Doing a capture may make us get capture lost. Ignore it while we're in the |
| 72 // process of showing. | 74 // process of showing. |
| 73 base::AutoReset<bool> reseter(&ignore_capture_lost_, true); | 75 base::AutoReset<bool> reseter(&ignore_capture_lost_, true); |
| 74 ShowInactive(); | 76 ShowInactive(); |
| 75 if (do_capture) { | 77 if (do_capture) { |
| 78 #if defined(USE_AURA) |
| 76 // Cancel existing touches, so we don't miss some touch release/cancel | 79 // Cancel existing touches, so we don't miss some touch release/cancel |
| 77 // events due to the menu taking capture. | 80 // events due to the menu taking capture. |
| 78 ui::GestureRecognizer::Get()->TransferEventsTo(GetNativeWindow(), NULL); | 81 ui::GestureRecognizer::Get()->TransferEventsTo(GetNativeWindow(), NULL); |
| 82 #endif |
| 79 native_widget_private()->SetCapture(); | 83 native_widget_private()->SetCapture(); |
| 80 } | 84 } |
| 81 } | 85 } |
| 82 | 86 |
| 83 void MenuHost::HideMenuHost() { | 87 void MenuHost::HideMenuHost() { |
| 84 ignore_capture_lost_ = true; | 88 ignore_capture_lost_ = true; |
| 85 ReleaseMenuHostCapture(); | 89 ReleaseMenuHostCapture(); |
| 86 Hide(); | 90 Hide(); |
| 87 ignore_capture_lost_ = false; | 91 ignore_capture_lost_ = false; |
| 88 } | 92 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 if (destroying_) | 138 if (destroying_) |
| 135 return; | 139 return; |
| 136 | 140 |
| 137 MenuController* menu_controller = | 141 MenuController* menu_controller = |
| 138 submenu_->GetMenuItem()->GetMenuController(); | 142 submenu_->GetMenuItem()->GetMenuController(); |
| 139 if (menu_controller && !menu_controller->drag_in_progress()) | 143 if (menu_controller && !menu_controller->drag_in_progress()) |
| 140 menu_controller->CancelAll(); | 144 menu_controller->CancelAll(); |
| 141 } | 145 } |
| 142 | 146 |
| 143 } // namespace views | 147 } // namespace views |
| OLD | NEW |