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

Side by Side Diff: ui/views/controls/scrollbar/overlay_scroll_bar.cc

Issue 2639203007: Update SetPaintToLayer to accept LayerType (Closed)
Patch Set: fix comments Created 3 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/overlay_scroll_bar.h" 5 #include "ui/views/controls/scrollbar/overlay_scroll_bar.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "third_party/skia/include/core/SkColor.h" 8 #include "third_party/skia/include/core/SkColor.h"
9 #include "ui/compositor/scoped_layer_animation_settings.h" 9 #include "ui/compositor/scoped_layer_animation_settings.h"
10 #include "ui/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
(...skipping 16 matching lines...) Expand all
27 27
28 OverlayScrollBar::Thumb::Thumb(OverlayScrollBar* scroll_bar) 28 OverlayScrollBar::Thumb::Thumb(OverlayScrollBar* scroll_bar)
29 : BaseScrollBarThumb(scroll_bar), scroll_bar_(scroll_bar) { 29 : BaseScrollBarThumb(scroll_bar), scroll_bar_(scroll_bar) {
30 // |scroll_bar| isn't done being constructed; it's not safe to do anything 30 // |scroll_bar| isn't done being constructed; it's not safe to do anything
31 // that might reference it yet. 31 // that might reference it yet.
32 } 32 }
33 33
34 OverlayScrollBar::Thumb::~Thumb() {} 34 OverlayScrollBar::Thumb::~Thumb() {}
35 35
36 void OverlayScrollBar::Thumb::Init() { 36 void OverlayScrollBar::Thumb::Init() {
37 SetPaintToLayer(true); 37 SetPaintToLayer();
38 layer()->SetFillsBoundsOpaquely(false); 38 layer()->SetFillsBoundsOpaquely(false);
39 // Animate all changes to the layer except the first one. 39 // Animate all changes to the layer except the first one.
40 OnStateChanged(); 40 OnStateChanged();
41 layer()->SetAnimator(ui::LayerAnimator::CreateImplicitAnimator()); 41 layer()->SetAnimator(ui::LayerAnimator::CreateImplicitAnimator());
42 } 42 }
43 43
44 gfx::Size OverlayScrollBar::Thumb::GetPreferredSize() const { 44 gfx::Size OverlayScrollBar::Thumb::GetPreferredSize() const {
45 // The visual size of the thumb is kThumbThickness, but it slides back and 45 // The visual size of the thumb is kThumbThickness, but it slides back and
46 // forth by kThumbHoverOffset. To make event targetting work well, expand the 46 // forth by kThumbHoverOffset. To make event targetting work well, expand the
47 // width of the thumb such that it's always taking up the full width of the 47 // width of the thumb such that it's always taking up the full width of the
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 layer()->SetOpacity(kThumbHoverAlpha); 106 layer()->SetOpacity(kThumbHoverAlpha);
107 } 107 }
108 } 108 }
109 109
110 OverlayScrollBar::OverlayScrollBar(bool horizontal) 110 OverlayScrollBar::OverlayScrollBar(bool horizontal)
111 : BaseScrollBar(horizontal), hide_timer_(false, false) { 111 : BaseScrollBar(horizontal), hide_timer_(false, false) {
112 auto thumb = new Thumb(this); 112 auto thumb = new Thumb(this);
113 SetThumb(thumb); 113 SetThumb(thumb);
114 thumb->Init(); 114 thumb->Init();
115 set_notify_enter_exit_on_child(true); 115 set_notify_enter_exit_on_child(true);
116 SetPaintToLayer(true); 116 SetPaintToLayer();
117 layer()->SetMasksToBounds(true); 117 layer()->SetMasksToBounds(true);
118 layer()->SetFillsBoundsOpaquely(false); 118 layer()->SetFillsBoundsOpaquely(false);
119 } 119 }
120 120
121 OverlayScrollBar::~OverlayScrollBar() {} 121 OverlayScrollBar::~OverlayScrollBar() {}
122 122
123 gfx::Rect OverlayScrollBar::GetTrackBounds() const { 123 gfx::Rect OverlayScrollBar::GetTrackBounds() const {
124 gfx::Rect local = GetLocalBounds(); 124 gfx::Rect local = GetLocalBounds();
125 // The track has to be wide enough for the thumb. 125 // The track has to be wide enough for the thumb.
126 local.Inset(gfx::Insets(IsHorizontal() ? -kThumbHoverOffset : 0, 126 local.Inset(gfx::Insets(IsHorizontal() ? -kThumbHoverOffset : 0,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 170
171 void OverlayScrollBar::StartHideCountdown() { 171 void OverlayScrollBar::StartHideCountdown() {
172 if (IsMouseHovered()) 172 if (IsMouseHovered())
173 return; 173 return;
174 hide_timer_.Start( 174 hide_timer_.Start(
175 FROM_HERE, base::TimeDelta::FromSeconds(1), 175 FROM_HERE, base::TimeDelta::FromSeconds(1),
176 base::Bind(&OverlayScrollBar::Hide, base::Unretained(this))); 176 base::Bind(&OverlayScrollBar::Hide, base::Unretained(this)));
177 } 177 }
178 178
179 } // namespace views 179 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698