OLD | NEW |
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 Loading... |
266 const gfx::Point& p, | 266 const gfx::Point& p, |
267 ui::MenuSourceType source_type) { | 267 ui::MenuSourceType source_type) { |
268 Widget* widget = GetWidget(); | 268 Widget* widget = GetWidget(); |
269 gfx::Rect widget_bounds = widget->GetWindowBoundsInScreen(); | 269 gfx::Rect widget_bounds = widget->GetWindowBoundsInScreen(); |
270 gfx::Point temp_pt(p.x() - widget_bounds.x(), p.y() - widget_bounds.y()); | 270 gfx::Point temp_pt(p.x() - widget_bounds.x(), p.y() - widget_bounds.y()); |
271 View::ConvertPointFromWidget(this, &temp_pt); | 271 View::ConvertPointFromWidget(this, &temp_pt); |
272 context_menu_mouse_position_ = IsHorizontal() ? temp_pt.x() : temp_pt.y(); | 272 context_menu_mouse_position_ = IsHorizontal() ? temp_pt.x() : temp_pt.y(); |
273 | 273 |
274 views::MenuItemView* menu = new views::MenuItemView(this); | 274 views::MenuItemView* menu = new views::MenuItemView(this); |
275 // MenuRunner takes ownership of |menu|. | 275 // MenuRunner takes ownership of |menu|. |
276 menu_runner_.reset(new MenuRunner(menu, MenuRunner::HAS_MNEMONICS | | 276 menu_runner_.reset(new MenuRunner( |
277 views::MenuRunner::CONTEXT_MENU | | 277 menu, MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU)); |
278 views::MenuRunner::ASYNC)); | |
279 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollHere); | 278 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollHere); |
280 menu->AppendSeparator(); | 279 menu->AppendSeparator(); |
281 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollStart); | 280 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollStart); |
282 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollEnd); | 281 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollEnd); |
283 menu->AppendSeparator(); | 282 menu->AppendSeparator(); |
284 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPageUp); | 283 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPageUp); |
285 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPageDown); | 284 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPageDown); |
286 menu->AppendSeparator(); | 285 menu->AppendSeparator(); |
287 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPrev); | 286 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPrev); |
288 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollNext); | 287 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollNext); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 int track_size = GetTrackSize(); | 483 int track_size = GetTrackSize(); |
485 if (track_size == thumb_size) | 484 if (track_size == thumb_size) |
486 return 0; | 485 return 0; |
487 if (scroll_to_middle) | 486 if (scroll_to_middle) |
488 thumb_position = thumb_position - (thumb_size / 2); | 487 thumb_position = thumb_position - (thumb_size / 2); |
489 return (thumb_position * (contents_size_ - viewport_size_)) / | 488 return (thumb_position * (contents_size_ - viewport_size_)) / |
490 (track_size - thumb_size); | 489 (track_size - thumb_size); |
491 } | 490 } |
492 | 491 |
493 } // namespace views | 492 } // namespace views |
OLD | NEW |