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/controls/scrollbar/base_scroll_bar.cc

Issue 331993009: MacViews: Run native Cocoa context menus to support Services. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add VIEWS_EXPORT for unit test access Created 6 years, 5 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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 const gfx::Point& p, 287 const gfx::Point& p,
288 ui::MenuSourceType source_type) { 288 ui::MenuSourceType source_type) {
289 Widget* widget = GetWidget(); 289 Widget* widget = GetWidget();
290 gfx::Rect widget_bounds = widget->GetWindowBoundsInScreen(); 290 gfx::Rect widget_bounds = widget->GetWindowBoundsInScreen();
291 gfx::Point temp_pt(p.x() - widget_bounds.x(), p.y() - widget_bounds.y()); 291 gfx::Point temp_pt(p.x() - widget_bounds.x(), p.y() - widget_bounds.y());
292 View::ConvertPointFromWidget(this, &temp_pt); 292 View::ConvertPointFromWidget(this, &temp_pt);
293 context_menu_mouse_position_ = IsHorizontal() ? temp_pt.x() : temp_pt.y(); 293 context_menu_mouse_position_ = IsHorizontal() ? temp_pt.x() : temp_pt.y();
294 294
295 views::MenuItemView* menu = new views::MenuItemView(this); 295 views::MenuItemView* menu = new views::MenuItemView(this);
296 // MenuRunner takes ownership of |menu|. 296 // MenuRunner takes ownership of |menu|.
297 menu_runner_.reset(new MenuRunner(menu)); 297 menu_runner_.reset(new MenuRunner(
298 menu, MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU));
298 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollHere); 299 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollHere);
299 menu->AppendSeparator(); 300 menu->AppendSeparator();
300 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollStart); 301 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollStart);
301 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollEnd); 302 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollEnd);
302 menu->AppendSeparator(); 303 menu->AppendSeparator();
303 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPageUp); 304 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPageUp);
304 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPageDown); 305 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPageDown);
305 menu->AppendSeparator(); 306 menu->AppendSeparator();
306 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPrev); 307 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPrev);
307 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollNext); 308 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollNext);
308 if (menu_runner_->RunMenuAt( 309 if (menu_runner_->RunMenuAt(GetWidget(),
309 GetWidget(), 310 NULL,
310 NULL, 311 gfx::Rect(p, gfx::Size()),
311 gfx::Rect(p, gfx::Size()), 312 MENU_ANCHOR_TOPLEFT,
312 MENU_ANCHOR_TOPLEFT, 313 source_type) == MenuRunner::MENU_DELETED) {
313 source_type,
314 MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) ==
315 MenuRunner::MENU_DELETED) {
316 return; 314 return;
317 } 315 }
318 } 316 }
319 317
320 /////////////////////////////////////////////////////////////////////////////// 318 ///////////////////////////////////////////////////////////////////////////////
321 // BaseScrollBar, Menu::Delegate implementation: 319 // BaseScrollBar, Menu::Delegate implementation:
322 320
323 base::string16 BaseScrollBar::GetLabel(int id) const { 321 base::string16 BaseScrollBar::GetLabel(int id) const {
324 int ids_value = 0; 322 int ids_value = 0;
325 switch (id) { 323 switch (id) {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 thumb_position = thumb_position - (thumb_->GetSize() / 2); 508 thumb_position = thumb_position - (thumb_->GetSize() / 2);
511 return (thumb_position * contents_size_) / GetTrackSize(); 509 return (thumb_position * contents_size_) / GetTrackSize();
512 } 510 }
513 511
514 void BaseScrollBar::SetThumbTrackState(CustomButton::ButtonState state) { 512 void BaseScrollBar::SetThumbTrackState(CustomButton::ButtonState state) {
515 thumb_track_state_ = state; 513 thumb_track_state_ = state;
516 SchedulePaint(); 514 SchedulePaint();
517 } 515 }
518 516
519 } // namespace views 517 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698