| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 return false; | 193 return false; |
| 194 } | 194 } |
| 195 | 195 |
| 196 bool BaseScrollBar::OnMouseWheel(const ui::MouseWheelEvent& event) { | 196 bool BaseScrollBar::OnMouseWheel(const ui::MouseWheelEvent& event) { |
| 197 ScrollByContentsOffset(event.y_offset()); | 197 ScrollByContentsOffset(event.y_offset()); |
| 198 return true; | 198 return true; |
| 199 } | 199 } |
| 200 | 200 |
| 201 void BaseScrollBar::OnGestureEvent(ui::GestureEvent* event) { | 201 void BaseScrollBar::OnGestureEvent(ui::GestureEvent* event) { |
| 202 // If a fling is in progress, then stop the fling for any incoming gesture | 202 // If a fling is in progress, then stop the fling for any incoming gesture |
| 203 // event (except for the GESTURE_END event that is generated at the end of the | 203 // event. |
| 204 // fling). | 204 if (scroll_animator_.get() && scroll_animator_->is_scrolling()) |
| 205 if (scroll_animator_.get() && scroll_animator_->is_scrolling() && | |
| 206 (event->type() != ui::ET_GESTURE_END || | |
| 207 event->details().touch_points() > 1)) { | |
| 208 scroll_animator_->Stop(); | 205 scroll_animator_->Stop(); |
| 209 } | |
| 210 | 206 |
| 211 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { | 207 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { |
| 212 ProcessPressEvent(*event); | 208 ProcessPressEvent(*event); |
| 213 event->SetHandled(); | 209 event->SetHandled(); |
| 214 return; | 210 return; |
| 215 } | 211 } |
| 216 | 212 |
| 217 if (event->type() == ui::ET_GESTURE_LONG_PRESS) { | 213 if (event->type() == ui::ET_GESTURE_LONG_PRESS) { |
| 218 // For a long-press, the repeater started in tap-down should continue. So | 214 // For a long-press, the repeater started in tap-down should continue. So |
| 219 // return early. | 215 // return early. |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 thumb_position = thumb_position - (thumb_->GetSize() / 2); | 504 thumb_position = thumb_position - (thumb_->GetSize() / 2); |
| 509 return (thumb_position * contents_size_) / GetTrackSize(); | 505 return (thumb_position * contents_size_) / GetTrackSize(); |
| 510 } | 506 } |
| 511 | 507 |
| 512 void BaseScrollBar::SetThumbTrackState(CustomButton::ButtonState state) { | 508 void BaseScrollBar::SetThumbTrackState(CustomButton::ButtonState state) { |
| 513 thumb_track_state_ = state; | 509 thumb_track_state_ = state; |
| 514 SchedulePaint(); | 510 SchedulePaint(); |
| 515 } | 511 } |
| 516 | 512 |
| 517 } // namespace views | 513 } // namespace views |
| OLD | NEW |