| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 88 |
| 89 DISALLOW_COPY_AND_ASSIGN(CocoaScrollBarThumb); | 89 DISALLOW_COPY_AND_ASSIGN(CocoaScrollBarThumb); |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 CocoaScrollBarThumb::CocoaScrollBarThumb(CocoaScrollBar* scroll_bar) | 92 CocoaScrollBarThumb::CocoaScrollBarThumb(CocoaScrollBar* scroll_bar) |
| 93 : BaseScrollBarThumb(scroll_bar) { | 93 : BaseScrollBarThumb(scroll_bar) { |
| 94 DCHECK(scroll_bar); | 94 DCHECK(scroll_bar); |
| 95 | 95 |
| 96 // This is necessary, otherwise the thumb will be rendered below the views if | 96 // This is necessary, otherwise the thumb will be rendered below the views if |
| 97 // those views paint to their own layers. | 97 // those views paint to their own layers. |
| 98 SetPaintToLayer(true); | 98 SetPaintToLayer(); |
| 99 layer()->SetFillsBoundsOpaquely(false); | 99 layer()->SetFillsBoundsOpaquely(false); |
| 100 } | 100 } |
| 101 | 101 |
| 102 CocoaScrollBarThumb::~CocoaScrollBarThumb() {} | 102 CocoaScrollBarThumb::~CocoaScrollBarThumb() {} |
| 103 | 103 |
| 104 bool CocoaScrollBarThumb::IsStateHovered() const { | 104 bool CocoaScrollBarThumb::IsStateHovered() const { |
| 105 return GetState() == CustomButton::STATE_HOVERED; | 105 return GetState() == CustomButton::STATE_HOVERED; |
| 106 } | 106 } |
| 107 | 107 |
| 108 bool CocoaScrollBarThumb::IsStatePressed() const { | 108 bool CocoaScrollBarThumb::IsStatePressed() const { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 SetThumb(new CocoaScrollBarThumb(this)); |
| 175 bridge_.reset([[ViewsScrollbarBridge alloc] initWithDelegate:this]); | 175 bridge_.reset([[ViewsScrollbarBridge alloc] initWithDelegate:this]); |
| 176 scroller_style_ = [ViewsScrollbarBridge getPreferredScrollerStyle]; | 176 scroller_style_ = [ViewsScrollbarBridge getPreferredScrollerStyle]; |
| 177 | 177 |
| 178 thickness_animation_.SetSlideDuration(kExpandDurationMs); | 178 thickness_animation_.SetSlideDuration(kExpandDurationMs); |
| 179 | 179 |
| 180 SetPaintToLayer(true); | 180 SetPaintToLayer(); |
| 181 has_scrolltrack_ = scroller_style_ == NSScrollerStyleLegacy; | 181 has_scrolltrack_ = scroller_style_ == NSScrollerStyleLegacy; |
| 182 layer()->SetOpacity(scroller_style_ == NSScrollerStyleOverlay ? 0.0f : 1.0f); | 182 layer()->SetOpacity(scroller_style_ == NSScrollerStyleOverlay ? 0.0f : 1.0f); |
| 183 } | 183 } |
| 184 | 184 |
| 185 CocoaScrollBar::~CocoaScrollBar() { | 185 CocoaScrollBar::~CocoaScrollBar() { |
| 186 [bridge_ clearDelegate]; | 186 [bridge_ clearDelegate]; |
| 187 } | 187 } |
| 188 | 188 |
| 189 ////////////////////////////////////////////////////////////////// | 189 ////////////////////////////////////////////////////////////////// |
| 190 // CocoaScrollBar, BaseScrollBar: | 190 // CocoaScrollBar, BaseScrollBar: |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 CocoaScrollBarThumb* CocoaScrollBar::GetCocoaScrollBarThumb() const { | 536 CocoaScrollBarThumb* CocoaScrollBar::GetCocoaScrollBarThumb() const { |
| 537 return static_cast<CocoaScrollBarThumb*>(GetThumb()); | 537 return static_cast<CocoaScrollBarThumb*>(GetThumb()); |
| 538 } | 538 } |
| 539 | 539 |
| 540 // static | 540 // static |
| 541 base::Timer* BaseScrollBar::GetHideTimerForTest(BaseScrollBar* scroll_bar) { | 541 base::Timer* BaseScrollBar::GetHideTimerForTest(BaseScrollBar* scroll_bar) { |
| 542 return &static_cast<CocoaScrollBar*>(scroll_bar)->hide_scrollbar_timer_; | 542 return &static_cast<CocoaScrollBar*>(scroll_bar)->hide_scrollbar_timer_; |
| 543 } | 543 } |
| 544 | 544 |
| 545 } // namespace views | 545 } // namespace views |
| OLD | NEW |