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

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

Issue 2790773002: Cleanup MenuRunner API (Closed)
Patch Set: Rebase Created 3 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
« no previous file with comments | « ui/views/controls/textfield/textfield.cc ('k') | ui/views/examples/tree_view_example.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 #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( 182 menu_runner_.reset(new MenuRunner(GetMenuModel(), MenuRunner::HAS_MNEMONICS));
183 GetMenuModel(), MenuRunner::HAS_MNEMONICS | MenuRunner::ASYNC));
184 183
185 menu_runner_->RunMenuAt(source->GetWidget()->GetTopLevelWidget(), this, 184 menu_runner_->RunMenuAt(source->GetWidget()->GetTopLevelWidget(), this,
186 gfx::Rect(point, gfx::Size()), MENU_ANCHOR_TOPRIGHT, 185 gfx::Rect(point, gfx::Size()), MENU_ANCHOR_TOPRIGHT,
187 ui::MENU_SOURCE_NONE); 186 ui::MENU_SOURCE_NONE);
188 } 187 }
189 188
190 ui::SimpleMenuModel* ExampleMenuButton::GetMenuModel() { 189 ui::SimpleMenuModel* ExampleMenuButton::GetMenuModel() {
191 if (!menu_model_.get()) 190 if (!menu_model_.get())
192 menu_model_.reset(new ExampleMenuModel); 191 menu_model_.reset(new ExampleMenuModel);
193 return menu_model_.get(); 192 return menu_model_.get();
(...skipping 10 matching lines...) Expand all
204 void MenuExample::CreateExampleView(View* container) { 203 void MenuExample::CreateExampleView(View* container) {
205 // We add a button to open a menu. 204 // We add a button to open a menu.
206 ExampleMenuButton* menu_button = new ExampleMenuButton( 205 ExampleMenuButton* menu_button = new ExampleMenuButton(
207 ASCIIToUTF16("Open a menu")); 206 ASCIIToUTF16("Open a menu"));
208 container->SetLayoutManager(new FillLayout); 207 container->SetLayoutManager(new FillLayout);
209 container->AddChildView(menu_button); 208 container->AddChildView(menu_button);
210 } 209 }
211 210
212 } // namespace examples 211 } // namespace examples
213 } // namespace views 212 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/textfield.cc ('k') | ui/views/examples/tree_view_example.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698