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

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

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 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
« no previous file with comments | « ui/views/controls/menu/menu_runner.h ('k') | ui/views/controls/menu/menu_runner_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/views/controls/menu/menu_runner.h"
6
7 #include "ui/views/controls/menu/menu_runner_handler.h"
8 #include "ui/views/controls/menu/menu_runner_impl.h"
9
10 namespace views {
11
12 MenuRunner::MenuRunner(ui::MenuModel* menu_model, int32 run_types)
13 : run_types_(run_types),
14 impl_(internal::MenuRunnerImplInterface::Create(menu_model, run_types)) {
15 }
16
17 MenuRunner::MenuRunner(MenuItemView* menu_view, int32 run_types)
18 : run_types_(run_types), impl_(new internal::MenuRunnerImpl(menu_view)) {
19 }
20
21 MenuRunner::~MenuRunner() {
22 impl_->Release();
23 }
24
25 MenuRunner::RunResult MenuRunner::RunMenuAt(Widget* parent,
26 MenuButton* button,
27 const gfx::Rect& bounds,
28 MenuAnchorPosition anchor,
29 ui::MenuSourceType source_type) {
30 if (runner_handler_.get()) {
31 return runner_handler_->RunMenuAt(
32 parent, button, bounds, anchor, source_type, run_types_);
33 }
34
35 // The parent of the nested menu will have created a DisplayChangeListener, so
36 // we avoid creating a DisplayChangeListener if nested. Drop menus are
37 // transient, so we don't cancel in that case.
38 if ((run_types_ & (IS_NESTED | FOR_DROP)) == 0 && parent) {
39 display_change_listener_.reset(
40 internal::DisplayChangeListener::Create(parent, this));
41 }
42
43 if (run_types_ & CONTEXT_MENU) {
44 switch (source_type) {
45 case ui::MENU_SOURCE_NONE:
46 case ui::MENU_SOURCE_KEYBOARD:
47 case ui::MENU_SOURCE_MOUSE:
48 anchor = MENU_ANCHOR_TOPLEFT;
49 break;
50 case ui::MENU_SOURCE_TOUCH:
51 case ui::MENU_SOURCE_TOUCH_EDIT_MENU:
52 anchor = MENU_ANCHOR_BOTTOMCENTER;
53 break;
54 default:
55 break;
56 }
57 }
58
59 return impl_->RunMenuAt(parent, button, bounds, anchor, run_types_);
60 }
61
62 bool MenuRunner::IsRunning() const {
63 return impl_->IsRunning();
64 }
65
66 void MenuRunner::Cancel() {
67 impl_->Cancel();
68 }
69
70 base::TimeDelta MenuRunner::closing_event_time() const {
71 return impl_->GetClosingEventTime();
72 }
73
74 void MenuRunner::SetRunnerHandler(
75 scoped_ptr<MenuRunnerHandler> runner_handler) {
76 runner_handler_ = runner_handler.Pass();
77 }
78
79 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_runner.h ('k') | ui/views/controls/menu/menu_runner_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698