Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Side by Side Diff: ui/views/controls/scrollbar/cocoa_scroll_bar.mm

Issue 2639203007: Update SetPaintToLayer to accept LayerType (Closed)
Patch Set: Refactor Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "ui/compositor/layer_animator.h" 11 #include "ui/compositor/layer_animator.h"
12 #include "ui/compositor/layer_type.h"
12 #include "ui/compositor/scoped_layer_animation_settings.h" 13 #include "ui/compositor/scoped_layer_animation_settings.h"
13 #include "ui/gfx/canvas.h" 14 #include "ui/gfx/canvas.h"
14 #include "ui/views/controls/scrollbar/base_scroll_bar_thumb.h" 15 #include "ui/views/controls/scrollbar/base_scroll_bar_thumb.h"
15 16
16 namespace views { 17 namespace views {
17 18
18 namespace { 19 namespace {
19 20
20 // The length of the fade animation. 21 // The length of the fade animation.
21 const int kFadeDurationMs = 240; 22 const int kFadeDurationMs = 240;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 89
89 DISALLOW_COPY_AND_ASSIGN(CocoaScrollBarThumb); 90 DISALLOW_COPY_AND_ASSIGN(CocoaScrollBarThumb);
90 }; 91 };
91 92
92 CocoaScrollBarThumb::CocoaScrollBarThumb(CocoaScrollBar* scroll_bar) 93 CocoaScrollBarThumb::CocoaScrollBarThumb(CocoaScrollBar* scroll_bar)
93 : BaseScrollBarThumb(scroll_bar) { 94 : BaseScrollBarThumb(scroll_bar) {
94 DCHECK(scroll_bar); 95 DCHECK(scroll_bar);
95 96
96 // This is necessary, otherwise the thumb will be rendered below the views if 97 // This is necessary, otherwise the thumb will be rendered below the views if
97 // those views paint to their own layers. 98 // those views paint to their own layers.
98 SetPaintToLayer(true); 99 SetPaintToLayer(ui::LAYER_TEXTURED);
99 layer()->SetFillsBoundsOpaquely(false); 100 layer()->SetFillsBoundsOpaquely(false);
100 } 101 }
101 102
102 CocoaScrollBarThumb::~CocoaScrollBarThumb() {} 103 CocoaScrollBarThumb::~CocoaScrollBarThumb() {}
103 104
104 bool CocoaScrollBarThumb::IsStateHovered() const { 105 bool CocoaScrollBarThumb::IsStateHovered() const {
105 return GetState() == CustomButton::STATE_HOVERED; 106 return GetState() == CustomButton::STATE_HOVERED;
106 } 107 }
107 108
108 bool CocoaScrollBarThumb::IsStatePressed() const { 109 bool CocoaScrollBarThumb::IsStatePressed() const {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 thickness_animation_(this), 171 thickness_animation_(this),
171 last_contents_scroll_offset_(0), 172 last_contents_scroll_offset_(0),
172 is_expanded_(false), 173 is_expanded_(false),
173 did_start_dragging_(false) { 174 did_start_dragging_(false) {
174 SetThumb(new CocoaScrollBarThumb(this)); 175 SetThumb(new CocoaScrollBarThumb(this));
175 bridge_.reset([[ViewsScrollbarBridge alloc] initWithDelegate:this]); 176 bridge_.reset([[ViewsScrollbarBridge alloc] initWithDelegate:this]);
176 scroller_style_ = [ViewsScrollbarBridge getPreferredScrollerStyle]; 177 scroller_style_ = [ViewsScrollbarBridge getPreferredScrollerStyle];
177 178
178 thickness_animation_.SetSlideDuration(kExpandDurationMs); 179 thickness_animation_.SetSlideDuration(kExpandDurationMs);
179 180
180 SetPaintToLayer(true); 181 SetPaintToLayer(ui::LAYER_TEXTURED);
181 has_scrolltrack_ = scroller_style_ == NSScrollerStyleLegacy; 182 has_scrolltrack_ = scroller_style_ == NSScrollerStyleLegacy;
182 layer()->SetOpacity(scroller_style_ == NSScrollerStyleOverlay ? 0.0f : 1.0f); 183 layer()->SetOpacity(scroller_style_ == NSScrollerStyleOverlay ? 0.0f : 1.0f);
183 } 184 }
184 185
185 CocoaScrollBar::~CocoaScrollBar() { 186 CocoaScrollBar::~CocoaScrollBar() {
186 [bridge_ clearDelegate]; 187 [bridge_ clearDelegate];
187 } 188 }
188 189
189 ////////////////////////////////////////////////////////////////// 190 //////////////////////////////////////////////////////////////////
190 // CocoaScrollBar, BaseScrollBar: 191 // CocoaScrollBar, BaseScrollBar:
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 CocoaScrollBarThumb* CocoaScrollBar::GetCocoaScrollBarThumb() const { 537 CocoaScrollBarThumb* CocoaScrollBar::GetCocoaScrollBarThumb() const {
537 return static_cast<CocoaScrollBarThumb*>(GetThumb()); 538 return static_cast<CocoaScrollBarThumb*>(GetThumb());
538 } 539 }
539 540
540 // static 541 // static
541 base::Timer* BaseScrollBar::GetHideTimerForTest(BaseScrollBar* scroll_bar) { 542 base::Timer* BaseScrollBar::GetHideTimerForTest(BaseScrollBar* scroll_bar) {
542 return &static_cast<CocoaScrollBar*>(scroll_bar)->hide_scrollbar_timer_; 543 return &static_cast<CocoaScrollBar*>(scroll_bar)->hide_scrollbar_timer_;
543 } 544 }
544 545
545 } // namespace views 546 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698