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

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

Issue 59383003: Add the button style for combobox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: warnings Created 7 years 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/combobox/combobox_unittest.cc ('k') | ui/views/controls/menu/menu_runner.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 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_H_ 5 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_H_
6 #define UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_H_ 6 #define UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "ui/views/controls/menu/menu_item_view.h" 11 #include "ui/views/controls/menu/menu_item_view.h"
12 12
13 namespace ui { 13 namespace ui {
14 class MenuModel; 14 class MenuModel;
15 } 15 }
16 16
17 namespace views { 17 namespace views {
18 18
19 class MenuButton; 19 class MenuButton;
20 class MenuModelAdapter; 20 class MenuModelAdapter;
21 class MenuRunnerHandler;
21 class Widget; 22 class Widget;
22 23
23 namespace internal { 24 namespace internal {
24 class DisplayChangeListener; 25 class DisplayChangeListener;
25 class MenuRunnerImpl; 26 class MenuRunnerImpl;
26 } 27 }
27 28
29 namespace test {
30 class MenuRunnerTestAPI;
31 }
32
28 // MenuRunner is responsible for showing (running) the menu and additionally 33 // MenuRunner is responsible for showing (running) the menu and additionally
29 // owning the MenuItemView. RunMenuAt() runs a nested message loop. It is safe 34 // owning the MenuItemView. RunMenuAt() runs a nested message loop. It is safe
30 // to delete MenuRunner at any point, but MenuRunner internally only deletes the 35 // to delete MenuRunner at any point, but MenuRunner internally only deletes the
31 // MenuItemView *after* the nested message loop completes. If MenuRunner is 36 // MenuItemView *after* the nested message loop completes. If MenuRunner is
32 // deleted while the menu is showing the delegate of the menu is reset. This is 37 // deleted while the menu is showing the delegate of the menu is reset. This is
33 // done to ensure delegates aren't notified after they may have been deleted. 38 // done to ensure delegates aren't notified after they may have been deleted.
34 // 39 //
35 // NOTE: while you can delete a MenuRunner at any point, the nested message loop 40 // NOTE: while you can delete a MenuRunner at any point, the nested message loop
36 // won't return immediately. This means if you delete the object that owns 41 // won't return immediately. This means if you delete the object that owns
37 // the MenuRunner while the menu is running, your object is effectively still 42 // the MenuRunner while the menu is running, your object is effectively still
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // Returns true if we're in a nested message loop running the menu. 110 // Returns true if we're in a nested message loop running the menu.
106 bool IsRunning() const; 111 bool IsRunning() const;
107 112
108 // Hides and cancels the menu. This does nothing if the menu is not open. 113 // Hides and cancels the menu. This does nothing if the menu is not open.
109 void Cancel(); 114 void Cancel();
110 115
111 // Returns the time from the event which closed the menu - or 0. 116 // Returns the time from the event which closed the menu - or 0.
112 base::TimeDelta closing_event_time() const; 117 base::TimeDelta closing_event_time() const;
113 118
114 private: 119 private:
120 friend class test::MenuRunnerTestAPI;
121
122 // Sets an implementation of RunMenuAt. This is intended to be used at test.
123 void SetRunnerHandler(scoped_ptr<MenuRunnerHandler> runner_handler);
124
115 scoped_ptr<MenuModelAdapter> menu_model_adapter_; 125 scoped_ptr<MenuModelAdapter> menu_model_adapter_;
116 126
117 internal::MenuRunnerImpl* holder_; 127 internal::MenuRunnerImpl* holder_;
118 128
129 // An implementation of RunMenuAt. This is usually NULL and ignored. If this
130 // is not NULL, this implementation will be used.
131 scoped_ptr<MenuRunnerHandler> runner_handler_;
132
119 scoped_ptr<internal::DisplayChangeListener> display_change_listener_; 133 scoped_ptr<internal::DisplayChangeListener> display_change_listener_;
120 134
121 DISALLOW_COPY_AND_ASSIGN(MenuRunner); 135 DISALLOW_COPY_AND_ASSIGN(MenuRunner);
122 }; 136 };
123 137
124 namespace internal { 138 namespace internal {
125 139
126 // DisplayChangeListener is intended to listen for changes in the display size 140 // DisplayChangeListener is intended to listen for changes in the display size
127 // and cancel the menu. DisplayChangeListener is created when the menu is 141 // and cancel the menu. DisplayChangeListener is created when the menu is
128 // shown. 142 // shown.
129 class DisplayChangeListener { 143 class DisplayChangeListener {
130 public: 144 public:
131 virtual ~DisplayChangeListener() {} 145 virtual ~DisplayChangeListener() {}
132 146
133 // Creates the platform specified DisplayChangeListener, or NULL if there 147 // Creates the platform specified DisplayChangeListener, or NULL if there
134 // isn't one. Caller owns the returned value. 148 // isn't one. Caller owns the returned value.
135 static DisplayChangeListener* Create(Widget* parent, 149 static DisplayChangeListener* Create(Widget* parent,
136 MenuRunner* runner); 150 MenuRunner* runner);
137 151
138 protected: 152 protected:
139 DisplayChangeListener() {} 153 DisplayChangeListener() {}
140 }; 154 };
141 155
142 } 156 }
143 157
144 } // namespace views 158 } // namespace views
145 159
146 #endif // UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_H_ 160 #endif // UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_H_
OLDNEW
« no previous file with comments | « ui/views/controls/combobox/combobox_unittest.cc ('k') | ui/views/controls/menu/menu_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698