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

Side by Side Diff: ui/views/controls/scrollbar/base_scroll_bar.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/combobox/combobox.cc ('k') | ui/views/controls/textfield/textfield.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/controls/scrollbar/base_scroll_bar.h" 5 #include "ui/views/controls/scrollbar/base_scroll_bar.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 const gfx::Point& p, 283 const gfx::Point& p,
284 ui::MenuSourceType source_type) { 284 ui::MenuSourceType source_type) {
285 Widget* widget = GetWidget(); 285 Widget* widget = GetWidget();
286 gfx::Rect widget_bounds = widget->GetWindowBoundsInScreen(); 286 gfx::Rect widget_bounds = widget->GetWindowBoundsInScreen();
287 gfx::Point temp_pt(p.x() - widget_bounds.x(), p.y() - widget_bounds.y()); 287 gfx::Point temp_pt(p.x() - widget_bounds.x(), p.y() - widget_bounds.y());
288 View::ConvertPointFromWidget(this, &temp_pt); 288 View::ConvertPointFromWidget(this, &temp_pt);
289 context_menu_mouse_position_ = IsHorizontal() ? temp_pt.x() : temp_pt.y(); 289 context_menu_mouse_position_ = IsHorizontal() ? temp_pt.x() : temp_pt.y();
290 290
291 views::MenuItemView* menu = new views::MenuItemView(this); 291 views::MenuItemView* menu = new views::MenuItemView(this);
292 // MenuRunner takes ownership of |menu|. 292 // MenuRunner takes ownership of |menu|.
293 menu_runner_.reset(new MenuRunner( 293 menu_runner_.reset(new MenuRunner(menu, MenuRunner::HAS_MNEMONICS |
294 menu, MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU)); 294 views::MenuRunner::CONTEXT_MENU |
295 views::MenuRunner::ASYNC));
295 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollHere); 296 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollHere);
296 menu->AppendSeparator(); 297 menu->AppendSeparator();
297 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollStart); 298 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollStart);
298 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollEnd); 299 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollEnd);
299 menu->AppendSeparator(); 300 menu->AppendSeparator();
300 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPageUp); 301 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPageUp);
301 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPageDown); 302 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPageDown);
302 menu->AppendSeparator(); 303 menu->AppendSeparator();
303 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPrev); 304 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPrev);
304 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollNext); 305 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollNext);
305 if (menu_runner_->RunMenuAt(GetWidget(), 306 menu_runner_->RunMenuAt(GetWidget(), nullptr, gfx::Rect(p, gfx::Size()),
306 NULL, 307 MENU_ANCHOR_TOPLEFT, source_type);
307 gfx::Rect(p, gfx::Size()),
308 MENU_ANCHOR_TOPLEFT,
309 source_type) == MenuRunner::MENU_DELETED) {
310 return;
311 }
312 } 308 }
313 309
314 /////////////////////////////////////////////////////////////////////////////// 310 ///////////////////////////////////////////////////////////////////////////////
315 // BaseScrollBar, Menu::Delegate implementation: 311 // BaseScrollBar, Menu::Delegate implementation:
316 312
317 base::string16 BaseScrollBar::GetLabel(int id) const { 313 base::string16 BaseScrollBar::GetLabel(int id) const {
318 int ids_value = 0; 314 int ids_value = 0;
319 switch (id) { 315 switch (id) {
320 case ScrollBarContextMenuCommand_ScrollHere: 316 case ScrollBarContextMenuCommand_ScrollHere:
321 ids_value = IDS_APP_SCROLLBAR_CXMENU_SCROLLHERE; 317 ids_value = IDS_APP_SCROLLBAR_CXMENU_SCROLLHERE;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 return (thumb_position * (contents_size_ - viewport_size_)) / 506 return (thumb_position * (contents_size_ - viewport_size_)) /
511 (track_size - thumb_size); 507 (track_size - thumb_size);
512 } 508 }
513 509
514 void BaseScrollBar::SetThumbTrackState(CustomButton::ButtonState state) { 510 void BaseScrollBar::SetThumbTrackState(CustomButton::ButtonState state) {
515 thumb_track_state_ = state; 511 thumb_track_state_ = state;
516 SchedulePaint(); 512 SchedulePaint();
517 } 513 }
518 514
519 } // namespace views 515 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/combobox/combobox.cc ('k') | ui/views/controls/textfield/textfield.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698