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

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

Issue 187483005: Extending the Views-on-Mac experiment: whole app list grid. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: still compiles r263560 + crrev/195793005 Created 6 years, 8 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 | « ui/views/controls/menu/menu_runner.h ('k') | ui/views/controls/native/native_view_host_mac.mm » ('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_runner.h" 5 #include "ui/views/controls/menu/menu_runner.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "ui/base/models/menu_model.h" 10 #include "ui/base/models/menu_model.h"
11 #include "ui/views/controls/button/menu_button.h" 11 #include "ui/views/controls/button/menu_button.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_controller_delegate.h" 13 #include "ui/views/controls/menu/menu_controller_delegate.h"
14 #include "ui/views/controls/menu/menu_delegate.h" 14 #include "ui/views/controls/menu/menu_delegate.h"
15 #include "ui/views/controls/menu/menu_item_view.h"
15 #include "ui/views/controls/menu/menu_model_adapter.h" 16 #include "ui/views/controls/menu/menu_model_adapter.h"
16 #include "ui/views/controls/menu/menu_runner_handler.h" 17 #include "ui/views/controls/menu/menu_runner_handler.h"
17 #include "ui/views/widget/widget.h" 18 #include "ui/views/widget/widget.h"
18 19
19 #if defined(OS_WIN) 20 #if defined(OS_WIN)
20 #include "base/win/win_util.h" 21 #include "base/win/win_util.h"
21 #endif 22 #endif
22 23
23 namespace views { 24 namespace views {
24 25
(...skipping 11 matching lines...) Expand all
36 37
37 bool running() const { return running_; } 38 bool running() const { return running_; }
38 39
39 // See description above class for details. 40 // See description above class for details.
40 void Release(); 41 void Release();
41 42
42 // Runs the menu. 43 // Runs the menu.
43 MenuRunner::RunResult RunMenuAt(Widget* parent, 44 MenuRunner::RunResult RunMenuAt(Widget* parent,
44 MenuButton* button, 45 MenuButton* button,
45 const gfx::Rect& bounds, 46 const gfx::Rect& bounds,
46 MenuItemView::AnchorPosition anchor, 47 ui::MenuAnchorPosition anchor,
47 int32 types) WARN_UNUSED_RESULT; 48 int32 types) WARN_UNUSED_RESULT;
48 49
49 void Cancel(); 50 void Cancel();
50 51
51 // Returns the time from the event which closed the menu - or 0. 52 // Returns the time from the event which closed the menu - or 0.
52 base::TimeDelta closing_event_time() const; 53 base::TimeDelta closing_event_time() const;
53 54
54 // MenuControllerDelegate: 55 // MenuControllerDelegate:
55 virtual void DropMenuClosed(NotifyType type, MenuItemView* menu) OVERRIDE; 56 virtual void DropMenuClosed(NotifyType type, MenuItemView* menu) OVERRIDE;
56 virtual void SiblingMenuCreated(MenuItemView* menu) OVERRIDE; 57 virtual void SiblingMenuCreated(MenuItemView* menu) OVERRIDE;
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 } 291 }
291 292
292 MenuRunner::~MenuRunner() { 293 MenuRunner::~MenuRunner() {
293 holder_->Release(); 294 holder_->Release();
294 } 295 }
295 296
296 MenuItemView* MenuRunner::GetMenu() { 297 MenuItemView* MenuRunner::GetMenu() {
297 return holder_->menu(); 298 return holder_->menu();
298 } 299 }
299 300
301 template<>
300 MenuRunner::RunResult MenuRunner::RunMenuAt(Widget* parent, 302 MenuRunner::RunResult MenuRunner::RunMenuAt(Widget* parent,
301 MenuButton* button, 303 MenuButton* button,
302 const gfx::Rect& bounds, 304 const gfx::Rect& bounds,
303 MenuItemView::AnchorPosition anchor, 305 ui::MenuAnchorPosition menu_anchor,
304 ui::MenuSourceType source_type, 306 ui::MenuSourceType source_type,
305 int32 types) { 307 int32 types) {
308 MenuItemView::AnchorPosition anchor =
309 static_cast<MenuItemView::AnchorPosition>(menu_anchor);
306 if (runner_handler_.get()) { 310 if (runner_handler_.get()) {
307 return runner_handler_->RunMenuAt(parent, button, bounds, anchor, 311 return runner_handler_->RunMenuAt(parent, button, bounds, anchor,
308 source_type, types); 312 source_type, types);
309 } 313 }
310 314
311 // The parent of the nested menu will have created a DisplayChangeListener, so 315 // The parent of the nested menu will have created a DisplayChangeListener, so
312 // we avoid creating a DisplayChangeListener if nested. Drop menus are 316 // we avoid creating a DisplayChangeListener if nested. Drop menus are
313 // transient, so we don't cancel in that case. 317 // transient, so we don't cancel in that case.
314 if ((types & (IS_NESTED | FOR_DROP)) == 0 && parent) { 318 if ((types & (IS_NESTED | FOR_DROP)) == 0 && parent) {
315 display_change_listener_.reset( 319 display_change_listener_.reset(
(...skipping 30 matching lines...) Expand all
346 base::TimeDelta MenuRunner::closing_event_time() const { 350 base::TimeDelta MenuRunner::closing_event_time() const {
347 return holder_->closing_event_time(); 351 return holder_->closing_event_time();
348 } 352 }
349 353
350 void MenuRunner::SetRunnerHandler( 354 void MenuRunner::SetRunnerHandler(
351 scoped_ptr<MenuRunnerHandler> runner_handler) { 355 scoped_ptr<MenuRunnerHandler> runner_handler) {
352 runner_handler_ = runner_handler.Pass(); 356 runner_handler_ = runner_handler.Pass();
353 } 357 }
354 358
355 } // namespace views 359 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_runner.h ('k') | ui/views/controls/native/native_view_host_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698