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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 ScrollBarContextMenuCommand_ScrollStart, | 212 ScrollBarContextMenuCommand_ScrollStart, |
213 ScrollBarContextMenuCommand_ScrollEnd, | 213 ScrollBarContextMenuCommand_ScrollEnd, |
214 ScrollBarContextMenuCommand_ScrollPageUp, | 214 ScrollBarContextMenuCommand_ScrollPageUp, |
215 ScrollBarContextMenuCommand_ScrollPageDown, | 215 ScrollBarContextMenuCommand_ScrollPageDown, |
216 ScrollBarContextMenuCommand_ScrollPrev, | 216 ScrollBarContextMenuCommand_ScrollPrev, |
217 ScrollBarContextMenuCommand_ScrollNext | 217 ScrollBarContextMenuCommand_ScrollNext |
218 }; | 218 }; |
219 | 219 |
220 void BaseScrollBar::ShowContextMenuForView(View* source, const gfx::Point& p) { | 220 void BaseScrollBar::ShowContextMenuForView(View* source, const gfx::Point& p) { |
221 Widget* widget = GetWidget(); | 221 Widget* widget = GetWidget(); |
222 gfx::Rect widget_bounds = widget->GetWindowScreenBounds(); | 222 gfx::Rect widget_bounds = widget->GetWindowBoundsInScreen(); |
223 gfx::Point temp_pt(p.x() - widget_bounds.x(), p.y() - widget_bounds.y()); | 223 gfx::Point temp_pt(p.x() - widget_bounds.x(), p.y() - widget_bounds.y()); |
224 View::ConvertPointFromWidget(this, &temp_pt); | 224 View::ConvertPointFromWidget(this, &temp_pt); |
225 context_menu_mouse_position_ = IsHorizontal() ? temp_pt.x() : temp_pt.y(); | 225 context_menu_mouse_position_ = IsHorizontal() ? temp_pt.x() : temp_pt.y(); |
226 | 226 |
227 views::MenuItemView* menu = new views::MenuItemView(this); | 227 views::MenuItemView* menu = new views::MenuItemView(this); |
228 // MenuRunner takes ownership of |menu|. | 228 // MenuRunner takes ownership of |menu|. |
229 menu_runner_.reset(new MenuRunner(menu)); | 229 menu_runner_.reset(new MenuRunner(menu)); |
230 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollHere); | 230 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollHere); |
231 menu->AppendSeparator(); | 231 menu->AppendSeparator(); |
232 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollStart); | 232 menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollStart); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 thumb_position = thumb_position - (thumb_->GetSize() / 2); | 422 thumb_position = thumb_position - (thumb_->GetSize() / 2); |
423 return (thumb_position * contents_size_) / GetTrackSize(); | 423 return (thumb_position * contents_size_) / GetTrackSize(); |
424 } | 424 } |
425 | 425 |
426 void BaseScrollBar::SetThumbTrackState(CustomButton::ButtonState state) { | 426 void BaseScrollBar::SetThumbTrackState(CustomButton::ButtonState state) { |
427 thumb_track_state_ = state; | 427 thumb_track_state_ = state; |
428 SchedulePaint(); | 428 SchedulePaint(); |
429 } | 429 } |
430 | 430 |
431 } // namespace views | 431 } // namespace views |
OLD | NEW |