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

Side by Side Diff: ui/views/examples/menu_example.cc

Issue 2264403006: Update ui/views menus to use async (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review Updates Created 4 years, 3 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/textfield/textfield.cc ('k') | ui/views/examples/tree_view_example.h » ('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/examples/menu_example.h" 5 #include "ui/views/examples/menu_example.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 172
173 ExampleMenuButton::ExampleMenuButton(const base::string16& test) 173 ExampleMenuButton::ExampleMenuButton(const base::string16& test)
174 : MenuButton(test, this, true) {} 174 : MenuButton(test, this, true) {}
175 175
176 ExampleMenuButton::~ExampleMenuButton() { 176 ExampleMenuButton::~ExampleMenuButton() {
177 } 177 }
178 178
179 void ExampleMenuButton::OnMenuButtonClicked(MenuButton* source, 179 void ExampleMenuButton::OnMenuButtonClicked(MenuButton* source,
180 const gfx::Point& point, 180 const gfx::Point& point,
181 const ui::Event* event) { 181 const ui::Event* event) {
182 menu_runner_.reset(new MenuRunner(GetMenuModel(), MenuRunner::HAS_MNEMONICS)); 182 menu_runner_.reset(new MenuRunner(
183 GetMenuModel(), MenuRunner::HAS_MNEMONICS | MenuRunner::ASYNC));
183 184
184 if (menu_runner_->RunMenuAt(source->GetWidget()->GetTopLevelWidget(), 185 menu_runner_->RunMenuAt(source->GetWidget()->GetTopLevelWidget(), this,
185 this, 186 gfx::Rect(point, gfx::Size()), MENU_ANCHOR_TOPRIGHT,
186 gfx::Rect(point, gfx::Size()), 187 ui::MENU_SOURCE_NONE);
187 MENU_ANCHOR_TOPRIGHT,
188 ui::MENU_SOURCE_NONE) ==
189 MenuRunner::MENU_DELETED) {
190 return;
191 }
192 } 188 }
193 189
194 ui::SimpleMenuModel* ExampleMenuButton::GetMenuModel() { 190 ui::SimpleMenuModel* ExampleMenuButton::GetMenuModel() {
195 if (!menu_model_.get()) 191 if (!menu_model_.get())
196 menu_model_.reset(new ExampleMenuModel); 192 menu_model_.reset(new ExampleMenuModel);
197 return menu_model_.get(); 193 return menu_model_.get();
198 } 194 }
199 195
200 } // namespace 196 } // namespace
201 197
202 MenuExample::MenuExample() : ExampleBase("Menu") { 198 MenuExample::MenuExample() : ExampleBase("Menu") {
203 } 199 }
204 200
205 MenuExample::~MenuExample() { 201 MenuExample::~MenuExample() {
206 } 202 }
207 203
208 void MenuExample::CreateExampleView(View* container) { 204 void MenuExample::CreateExampleView(View* container) {
209 // We add a button to open a menu. 205 // We add a button to open a menu.
210 ExampleMenuButton* menu_button = new ExampleMenuButton( 206 ExampleMenuButton* menu_button = new ExampleMenuButton(
211 ASCIIToUTF16("Open a menu")); 207 ASCIIToUTF16("Open a menu"));
212 container->SetLayoutManager(new FillLayout); 208 container->SetLayoutManager(new FillLayout);
213 container->AddChildView(menu_button); 209 container->AddChildView(menu_button);
214 } 210 }
215 211
216 } // namespace examples 212 } // namespace examples
217 } // namespace views 213 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/textfield.cc ('k') | ui/views/examples/tree_view_example.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698