| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_thumb.h" | 5 #include "ui/views/controls/scrollbar/base_scroll_bar_thumb.h" |
| 6 | 6 |
| 7 #include "ui/gfx/canvas.h" | 7 #include "ui/gfx/canvas.h" |
| 8 #include "ui/gfx/rect.h" | 8 #include "ui/gfx/rect.h" |
| 9 #include "ui/views/controls/scrollbar/base_scroll_bar.h" | 9 #include "ui/views/controls/scrollbar/base_scroll_bar.h" |
| 10 | 10 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 thumb_x *= -1; | 103 thumb_x *= -1; |
| 104 scroll_bar_->ScrollToThumbPosition(GetPosition() + thumb_x, false); | 104 scroll_bar_->ScrollToThumbPosition(GetPosition() + thumb_x, false); |
| 105 } else { | 105 } else { |
| 106 int thumb_y = event.y() - mouse_offset_; | 106 int thumb_y = event.y() - mouse_offset_; |
| 107 scroll_bar_->ScrollToThumbPosition(GetPosition() + thumb_y, false); | 107 scroll_bar_->ScrollToThumbPosition(GetPosition() + thumb_y, false); |
| 108 } | 108 } |
| 109 return true; | 109 return true; |
| 110 } | 110 } |
| 111 | 111 |
| 112 void BaseScrollBarThumb::OnMouseReleased(const ui::MouseEvent& event) { | 112 void BaseScrollBarThumb::OnMouseReleased(const ui::MouseEvent& event) { |
| 113 SetState(HitTestPoint(event.location()) ? | 113 SetState(HitTestPoint(gfx::ToFlooredPoint(event.location())) |
| 114 CustomButton::STATE_HOVERED : CustomButton::STATE_NORMAL); | 114 ? CustomButton::STATE_HOVERED |
| 115 : CustomButton::STATE_NORMAL); |
| 115 } | 116 } |
| 116 | 117 |
| 117 void BaseScrollBarThumb::OnMouseCaptureLost() { | 118 void BaseScrollBarThumb::OnMouseCaptureLost() { |
| 118 SetState(CustomButton::STATE_HOVERED); | 119 SetState(CustomButton::STATE_HOVERED); |
| 119 } | 120 } |
| 120 | 121 |
| 121 CustomButton::ButtonState BaseScrollBarThumb::GetState() const { | 122 CustomButton::ButtonState BaseScrollBarThumb::GetState() const { |
| 122 return state_; | 123 return state_; |
| 123 } | 124 } |
| 124 | 125 |
| 125 void BaseScrollBarThumb::SetState(CustomButton::ButtonState state) { | 126 void BaseScrollBarThumb::SetState(CustomButton::ButtonState state) { |
| 126 if (state_ == state) | 127 if (state_ == state) |
| 127 return; | 128 return; |
| 128 | 129 |
| 129 CustomButton::ButtonState old_state = state_; | 130 CustomButton::ButtonState old_state = state_; |
| 130 state_ = state; | 131 state_ = state; |
| 131 scroll_bar_->OnThumbStateChanged(old_state, state); | 132 scroll_bar_->OnThumbStateChanged(old_state, state); |
| 132 SchedulePaint(); | 133 SchedulePaint(); |
| 133 } | 134 } |
| 134 | 135 |
| 135 } // namespace views | 136 } // namespace views |
| OLD | NEW |