| 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_button.h" | 5 #include "ui/views/controls/scrollbar/base_scroll_bar_button.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 "ui/display/screen.h" |
| 9 #include "ui/events/event_utils.h" | 10 #include "ui/events/event_utils.h" |
| 10 #include "ui/gfx/screen.h" | |
| 11 | 11 |
| 12 namespace views { | 12 namespace views { |
| 13 | 13 |
| 14 BaseScrollBarButton::BaseScrollBarButton(ButtonListener* listener) | 14 BaseScrollBarButton::BaseScrollBarButton(ButtonListener* listener) |
| 15 : CustomButton(listener), | 15 : CustomButton(listener), |
| 16 repeater_(base::Bind(&BaseScrollBarButton::RepeaterNotifyClick, | 16 repeater_(base::Bind(&BaseScrollBarButton::RepeaterNotifyClick, |
| 17 base::Unretained(this))) { | 17 base::Unretained(this))) { |
| 18 } | 18 } |
| 19 | 19 |
| 20 BaseScrollBarButton::~BaseScrollBarButton() { | 20 BaseScrollBarButton::~BaseScrollBarButton() { |
| 21 } | 21 } |
| 22 | 22 |
| 23 bool BaseScrollBarButton::OnMousePressed(const ui::MouseEvent& event) { | 23 bool BaseScrollBarButton::OnMousePressed(const ui::MouseEvent& event) { |
| 24 Button::NotifyClick(event); | 24 Button::NotifyClick(event); |
| 25 repeater_.Start(); | 25 repeater_.Start(); |
| 26 return true; | 26 return true; |
| 27 } | 27 } |
| 28 | 28 |
| 29 void BaseScrollBarButton::OnMouseReleased(const ui::MouseEvent& event) { | 29 void BaseScrollBarButton::OnMouseReleased(const ui::MouseEvent& event) { |
| 30 OnMouseCaptureLost(); | 30 OnMouseCaptureLost(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void BaseScrollBarButton::OnMouseCaptureLost() { | 33 void BaseScrollBarButton::OnMouseCaptureLost() { |
| 34 repeater_.Stop(); | 34 repeater_.Stop(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void BaseScrollBarButton::RepeaterNotifyClick() { | 37 void BaseScrollBarButton::RepeaterNotifyClick() { |
| 38 // TODO(sky): See if we can convert to using |Screen| everywhere. | 38 // TODO(sky): See if we can convert to using |Screen| everywhere. |
| 39 gfx::Point cursor_point = gfx::Screen::GetScreen()->GetCursorScreenPoint(); | 39 gfx::Point cursor_point = |
| 40 display::Screen::GetScreen()->GetCursorScreenPoint(); |
| 40 ui::MouseEvent event(ui::ET_MOUSE_RELEASED, cursor_point, cursor_point, | 41 ui::MouseEvent event(ui::ET_MOUSE_RELEASED, cursor_point, cursor_point, |
| 41 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, | 42 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, |
| 42 ui::EF_LEFT_MOUSE_BUTTON); | 43 ui::EF_LEFT_MOUSE_BUTTON); |
| 43 Button::NotifyClick(event); | 44 Button::NotifyClick(event); |
| 44 } | 45 } |
| 45 | 46 |
| 46 } // namespace views | 47 } // namespace views |
| OLD | NEW |