| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 121   if (old_state == CustomButton::STATE_PRESSED && | 121   if (old_state == CustomButton::STATE_PRESSED && | 
| 122       new_state == CustomButton::STATE_NORMAL && | 122       new_state == CustomButton::STATE_NORMAL && | 
| 123       GetThumbTrackState() == CustomButton::STATE_HOVERED) { | 123       GetThumbTrackState() == CustomButton::STATE_HOVERED) { | 
| 124     SetThumbTrackState(CustomButton::STATE_NORMAL); | 124     SetThumbTrackState(CustomButton::STATE_NORMAL); | 
| 125   } | 125   } | 
| 126 } | 126 } | 
| 127 | 127 | 
| 128 /////////////////////////////////////////////////////////////////////////////// | 128 /////////////////////////////////////////////////////////////////////////////// | 
| 129 // BaseScrollBar, View implementation: | 129 // BaseScrollBar, View implementation: | 
| 130 | 130 | 
|  | 131 void BaseScrollBar::Layout() { | 
|  | 132   // Provide a default implementation that sets the thumb's bounds in the | 
|  | 133   // scrollbar. | 
|  | 134   gfx::Rect thumb_bounds = GetTrackBounds(); | 
|  | 135   if (IsHorizontal()) { | 
|  | 136     thumb_bounds.set_x(thumb_->x()); | 
|  | 137     thumb_bounds.set_width(thumb_->width()); | 
|  | 138   } else { | 
|  | 139     thumb_bounds.set_y(thumb_->y()); | 
|  | 140     thumb_bounds.set_height(thumb_->height()); | 
|  | 141   } | 
|  | 142   thumb_->SetBoundsRect(thumb_bounds); | 
|  | 143 } | 
|  | 144 | 
| 131 bool BaseScrollBar::OnMousePressed(const ui::MouseEvent& event) { | 145 bool BaseScrollBar::OnMousePressed(const ui::MouseEvent& event) { | 
| 132   if (event.IsOnlyLeftMouseButton()) | 146   if (event.IsOnlyLeftMouseButton()) | 
| 133     ProcessPressEvent(event); | 147     ProcessPressEvent(event); | 
| 134   return true; | 148   return true; | 
| 135 } | 149 } | 
| 136 | 150 | 
| 137 void BaseScrollBar::OnMouseReleased(const ui::MouseEvent& event) { | 151 void BaseScrollBar::OnMouseReleased(const ui::MouseEvent& event) { | 
| 138   SetState(HitTestPoint(event.location()) ? | 152   SetState(HitTestPoint(event.location()) ? | 
| 139            CustomButton::STATE_HOVERED : CustomButton::STATE_NORMAL); | 153            CustomButton::STATE_HOVERED : CustomButton::STATE_NORMAL); | 
| 140 } | 154 } | 
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 508     thumb_position = thumb_position - (thumb_->GetSize() / 2); | 522     thumb_position = thumb_position - (thumb_->GetSize() / 2); | 
| 509   return (thumb_position * contents_size_) / GetTrackSize(); | 523   return (thumb_position * contents_size_) / GetTrackSize(); | 
| 510 } | 524 } | 
| 511 | 525 | 
| 512 void BaseScrollBar::SetThumbTrackState(CustomButton::ButtonState state) { | 526 void BaseScrollBar::SetThumbTrackState(CustomButton::ButtonState state) { | 
| 513   thumb_track_state_ = state; | 527   thumb_track_state_ = state; | 
| 514   SchedulePaint(); | 528   SchedulePaint(); | 
| 515 } | 529 } | 
| 516 | 530 | 
| 517 }  // namespace views | 531 }  // namespace views | 
| OLD | NEW | 
|---|