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

Side by Side Diff: ui/views/controls/scrollbar/base_scroll_bar.cc

Issue 16979002: Add ContextMenuSourceType to views::ContextMenuController::ShowContextMenuForView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 7 years, 6 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 | Annotate | Revision Log
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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 enum ScrollBarContextMenuCommands { 266 enum ScrollBarContextMenuCommands {
267 ScrollBarContextMenuCommand_ScrollHere = 1, 267 ScrollBarContextMenuCommand_ScrollHere = 1,
268 ScrollBarContextMenuCommand_ScrollStart, 268 ScrollBarContextMenuCommand_ScrollStart,
269 ScrollBarContextMenuCommand_ScrollEnd, 269 ScrollBarContextMenuCommand_ScrollEnd,
270 ScrollBarContextMenuCommand_ScrollPageUp, 270 ScrollBarContextMenuCommand_ScrollPageUp,
271 ScrollBarContextMenuCommand_ScrollPageDown, 271 ScrollBarContextMenuCommand_ScrollPageDown,
272 ScrollBarContextMenuCommand_ScrollPrev, 272 ScrollBarContextMenuCommand_ScrollPrev,
273 ScrollBarContextMenuCommand_ScrollNext 273 ScrollBarContextMenuCommand_ScrollNext
274 }; 274 };
275 275
276 void BaseScrollBar::ShowContextMenuForView(View* source, const gfx::Point& p) { 276 void BaseScrollBar::ShowContextMenuForView(View* source,
277 const gfx::Point& p,
278 ui::MenuSourceType source_type) {
277 Widget* widget = GetWidget(); 279 Widget* widget = GetWidget();
278 gfx::Rect widget_bounds = widget->GetWindowBoundsInScreen(); 280 gfx::Rect widget_bounds = widget->GetWindowBoundsInScreen();
279 gfx::Point temp_pt(p.x() - widget_bounds.x(), p.y() - widget_bounds.y()); 281 gfx::Point temp_pt(p.x() - widget_bounds.x(), p.y() - widget_bounds.y());
280 View::ConvertPointFromWidget(this, &temp_pt); 282 View::ConvertPointFromWidget(this, &temp_pt);
281 context_menu_mouse_position_ = IsHorizontal() ? temp_pt.x() : temp_pt.y(); 283 context_menu_mouse_position_ = IsHorizontal() ? temp_pt.x() : temp_pt.y();
282 284
283 views::MenuItemView* menu = new views::MenuItemView(this); 285 views::MenuItemView* menu = new views::MenuItemView(this);
284 // MenuRunner takes ownership of |menu|. 286 // MenuRunner takes ownership of |menu|.
285 menu_runner_.reset(new MenuRunner(menu)); 287 menu_runner_.reset(new MenuRunner(menu));
286 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollHere); 288 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollHere);
287 menu->AppendSeparator(); 289 menu->AppendSeparator();
288 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollStart); 290 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollStart);
289 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollEnd); 291 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollEnd);
290 menu->AppendSeparator(); 292 menu->AppendSeparator();
291 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPageUp); 293 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPageUp);
292 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPageDown); 294 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPageDown);
293 menu->AppendSeparator(); 295 menu->AppendSeparator();
294 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPrev); 296 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPrev);
295 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollNext); 297 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollNext);
296 if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(p, gfx::Size()), 298 if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(p, gfx::Size()),
297 MenuItemView::TOPLEFT, MenuRunner::HAS_MNEMONICS | 299 views::MenuItemView::TOPLEFT, source_type, MenuRunner::HAS_MNEMONICS |
298 views::MenuRunner::CONTEXT_MENU) == 300 views::MenuRunner::CONTEXT_MENU) ==
299 MenuRunner::MENU_DELETED) 301 MenuRunner::MENU_DELETED)
300 return; 302 return;
301 } 303 }
302 304
303 /////////////////////////////////////////////////////////////////////////////// 305 ///////////////////////////////////////////////////////////////////////////////
304 // BaseScrollBar, Menu::Delegate implementation: 306 // BaseScrollBar, Menu::Delegate implementation:
305 307
306 string16 BaseScrollBar::GetLabel(int id) const { 308 string16 BaseScrollBar::GetLabel(int id) const {
307 int ids_value = 0; 309 int ids_value = 0;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 thumb_position = thumb_position - (thumb_->GetSize() / 2); 493 thumb_position = thumb_position - (thumb_->GetSize() / 2);
492 return (thumb_position * contents_size_) / GetTrackSize(); 494 return (thumb_position * contents_size_) / GetTrackSize();
493 } 495 }
494 496
495 void BaseScrollBar::SetThumbTrackState(CustomButton::ButtonState state) { 497 void BaseScrollBar::SetThumbTrackState(CustomButton::ButtonState state) {
496 thumb_track_state_ = state; 498 thumb_track_state_ = state;
497 SchedulePaint(); 499 SchedulePaint();
498 } 500 }
499 501
500 } // namespace views 502 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/scrollbar/base_scroll_bar.h ('k') | ui/views/controls/textfield/native_textfield_views.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698