| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #import "ui/views/controls/scrollbar/cocoa_scroll_bar.h" | 5 #import "ui/views/controls/scrollbar/cocoa_scroll_bar.h" |
| 6 | 6 |
| 7 #import "base/mac/sdk_forward_declarations.h" | 7 #import "base/mac/sdk_forward_declarations.h" |
| 8 #include "third_party/skia/include/core/SkColor.h" | 8 #include "third_party/skia/include/core/SkColor.h" |
| 9 #include "third_party/skia/include/effects/SkGradientShader.h" | 9 #include "third_party/skia/include/effects/SkGradientShader.h" |
| 10 #include "ui/compositor/layer.h" | 10 #include "ui/compositor/layer.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 // the scrollview. The thumb will be set back to its hover or normal state | 154 // the scrollview. The thumb will be set back to its hover or normal state |
| 155 // when the mouse is released. | 155 // when the mouse is released. |
| 156 if (GetState() != CustomButton::STATE_PRESSED) | 156 if (GetState() != CustomButton::STATE_PRESSED) |
| 157 SetState(CustomButton::STATE_NORMAL); | 157 SetState(CustomButton::STATE_NORMAL); |
| 158 } | 158 } |
| 159 | 159 |
| 160 ////////////////////////////////////////////////////////////////// | 160 ////////////////////////////////////////////////////////////////// |
| 161 // CocoaScrollBar class | 161 // CocoaScrollBar class |
| 162 | 162 |
| 163 CocoaScrollBar::CocoaScrollBar(bool horizontal) | 163 CocoaScrollBar::CocoaScrollBar(bool horizontal) |
| 164 : BaseScrollBar(horizontal, new CocoaScrollBarThumb(this)), | 164 : BaseScrollBar(horizontal), |
| 165 hide_scrollbar_timer_( | 165 hide_scrollbar_timer_( |
| 166 FROM_HERE, | 166 FROM_HERE, |
| 167 base::TimeDelta::FromMilliseconds(kScrollbarHideTimeoutMs), | 167 base::TimeDelta::FromMilliseconds(kScrollbarHideTimeoutMs), |
| 168 base::Bind(&CocoaScrollBar::HideScrollbar, base::Unretained(this)), | 168 base::Bind(&CocoaScrollBar::HideScrollbar, base::Unretained(this)), |
| 169 false), | 169 false), |
| 170 thickness_animation_(this), | 170 thickness_animation_(this), |
| 171 last_contents_scroll_offset_(0), | 171 last_contents_scroll_offset_(0), |
| 172 is_expanded_(false), | 172 is_expanded_(false), |
| 173 did_start_dragging_(false) { | 173 did_start_dragging_(false) { |
| 174 SetThumb(new CocoaScrollBarThumb(this)); |
| 174 bridge_.reset([[ViewsScrollbarBridge alloc] initWithDelegate:this]); | 175 bridge_.reset([[ViewsScrollbarBridge alloc] initWithDelegate:this]); |
| 175 scroller_style_ = [ViewsScrollbarBridge getPreferredScrollerStyle]; | 176 scroller_style_ = [ViewsScrollbarBridge getPreferredScrollerStyle]; |
| 176 | 177 |
| 177 thickness_animation_.SetSlideDuration(kExpandDurationMs); | 178 thickness_animation_.SetSlideDuration(kExpandDurationMs); |
| 178 | 179 |
| 179 SetPaintToLayer(true); | 180 SetPaintToLayer(true); |
| 180 has_scrolltrack_ = scroller_style_ == NSScrollerStyleLegacy; | 181 has_scrolltrack_ = scroller_style_ == NSScrollerStyleLegacy; |
| 181 layer()->SetOpacity(scroller_style_ == NSScrollerStyleOverlay ? 0.0f : 1.0f); | 182 layer()->SetOpacity(scroller_style_ == NSScrollerStyleOverlay ? 0.0f : 1.0f); |
| 182 } | 183 } |
| 183 | 184 |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 CocoaScrollBarThumb* CocoaScrollBar::GetCocoaScrollBarThumb() const { | 536 CocoaScrollBarThumb* CocoaScrollBar::GetCocoaScrollBarThumb() const { |
| 536 return static_cast<CocoaScrollBarThumb*>(GetThumb()); | 537 return static_cast<CocoaScrollBarThumb*>(GetThumb()); |
| 537 } | 538 } |
| 538 | 539 |
| 539 // static | 540 // static |
| 540 base::Timer* BaseScrollBar::GetHideTimerForTest(BaseScrollBar* scroll_bar) { | 541 base::Timer* BaseScrollBar::GetHideTimerForTest(BaseScrollBar* scroll_bar) { |
| 541 return &static_cast<CocoaScrollBar*>(scroll_bar)->hide_scrollbar_timer_; | 542 return &static_cast<CocoaScrollBar*>(scroll_bar)->hide_scrollbar_timer_; |
| 542 } | 543 } |
| 543 | 544 |
| 544 } // namespace views | 545 } // namespace views |
| OLD | NEW |