| 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_runner.h" | 5 #include "ui/views/controls/menu/menu_runner.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "ui/views/controls/button/menu_button.h" | 9 #include "ui/views/controls/button/menu_button.h" |
| 10 #include "ui/views/controls/menu/menu_controller.h" | 10 #include "ui/views/controls/menu/menu_controller.h" |
| 11 #include "ui/views/controls/menu/menu_controller_delegate.h" | 11 #include "ui/views/controls/menu/menu_controller_delegate.h" |
| 12 #include "ui/views/controls/menu/menu_delegate.h" | 12 #include "ui/views/controls/menu/menu_delegate.h" |
| 13 #include "ui/views/widget/widget.h" |
| 13 | 14 |
| 14 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
| 15 #include "base/win/win_util.h" | 16 #include "base/win/win_util.h" |
| 16 #endif | 17 #endif |
| 17 | 18 |
| 18 namespace views { | 19 namespace views { |
| 19 | 20 |
| 20 namespace internal { | 21 namespace internal { |
| 21 | 22 |
| 22 // Manages the menu. To destroy a MenuRunnerImpl invoke Release(). Release() | 23 // Manages the menu. To destroy a MenuRunnerImpl invoke Release(). Release() |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 const gfx::Rect& bounds, | 278 const gfx::Rect& bounds, |
| 278 MenuItemView::AnchorPosition anchor, | 279 MenuItemView::AnchorPosition anchor, |
| 279 int32 types) { | 280 int32 types) { |
| 280 // The parent of the nested menu will have created a DisplayChangeListener, so | 281 // The parent of the nested menu will have created a DisplayChangeListener, so |
| 281 // we avoid creating a DisplayChangeListener if nested. Drop menus are | 282 // we avoid creating a DisplayChangeListener if nested. Drop menus are |
| 282 // transient, so we don't cancel in that case. | 283 // transient, so we don't cancel in that case. |
| 283 if ((types & (IS_NESTED | FOR_DROP)) == 0) { | 284 if ((types & (IS_NESTED | FOR_DROP)) == 0) { |
| 284 display_change_listener_.reset( | 285 display_change_listener_.reset( |
| 285 internal::DisplayChangeListener::Create(parent, this)); | 286 internal::DisplayChangeListener::Create(parent, this)); |
| 286 } | 287 } |
| 288 if ((types & MenuRunner::CONTEXT_MENU) && parent->GetCurrentEvent()) |
| 289 anchor = parent->GetCurrentEvent()->IsGestureEvent() ? |
| 290 MenuItemView::BOTTOMCENTER : MenuItemView::TOPLEFT; |
| 291 |
| 287 return holder_->RunMenuAt(parent, button, bounds, anchor, types); | 292 return holder_->RunMenuAt(parent, button, bounds, anchor, types); |
| 288 } | 293 } |
| 289 | 294 |
| 290 bool MenuRunner::IsRunning() const { | 295 bool MenuRunner::IsRunning() const { |
| 291 return holder_->running(); | 296 return holder_->running(); |
| 292 } | 297 } |
| 293 | 298 |
| 294 void MenuRunner::Cancel() { | 299 void MenuRunner::Cancel() { |
| 295 holder_->Cancel(); | 300 holder_->Cancel(); |
| 296 } | 301 } |
| 297 | 302 |
| 298 } // namespace views | 303 } // namespace views |
| OLD | NEW |