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

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

Issue 2641023003: Views overlay scrollbars - show on mouse hover. (Closed)
Patch Set: 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
« no previous file with comments | « ui/views/controls/scrollbar/overlay_scroll_bar.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 if (IsHorizontal()) { 142 if (IsHorizontal()) {
143 thumb_bounds.set_x(thumb->x()); 143 thumb_bounds.set_x(thumb->x());
144 thumb_bounds.set_width(thumb->width()); 144 thumb_bounds.set_width(thumb->width());
145 } else { 145 } else {
146 thumb_bounds.set_y(thumb->y()); 146 thumb_bounds.set_y(thumb->y());
147 thumb_bounds.set_height(thumb->height()); 147 thumb_bounds.set_height(thumb->height());
148 } 148 }
149 thumb->SetBoundsRect(thumb_bounds); 149 thumb->SetBoundsRect(thumb_bounds);
150 } 150 }
151 151
152 bool OverlayScrollBar::CanAcceptEvent(const ui::Event& event) {
153 return layer()->opacity() > 0 && BaseScrollBar::CanAcceptEvent(event);
154 }
155
156 void OverlayScrollBar::OnMouseEntered(const ui::MouseEvent& event) { 152 void OverlayScrollBar::OnMouseEntered(const ui::MouseEvent& event) {
157 // Note that events are only accepted when the scrollbar is already visible 153 Show();
158 // (due to a change in the scroll value). Don't let the scrollbar vanish from
159 // under the mouse pointer.
160 hide_timer_.Stop();
161 } 154 }
162 155
163 void OverlayScrollBar::OnMouseExited(const ui::MouseEvent& event) { 156 void OverlayScrollBar::OnMouseExited(const ui::MouseEvent& event) {
164 StartHideCountdown(); 157 StartHideCountdown();
165 } 158 }
166 159
167 void OverlayScrollBar::Show() { 160 void OverlayScrollBar::Show() {
168 layer()->SetOpacity(1.0f); 161 layer()->SetOpacity(1.0f);
169 hide_timer_.Stop(); 162 hide_timer_.Stop();
170 } 163 }
171 164
172 void OverlayScrollBar::Hide() { 165 void OverlayScrollBar::Hide() {
173 ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator()); 166 ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator());
174 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(200)); 167 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(200));
175 layer()->SetOpacity(0.0f); 168 layer()->SetOpacity(0.0f);
176 } 169 }
177 170
178 void OverlayScrollBar::StartHideCountdown() { 171 void OverlayScrollBar::StartHideCountdown() {
179 if (IsMouseHovered()) 172 if (IsMouseHovered())
180 return; 173 return;
181 hide_timer_.Start( 174 hide_timer_.Start(
182 FROM_HERE, base::TimeDelta::FromSeconds(1), 175 FROM_HERE, base::TimeDelta::FromSeconds(1),
183 base::Bind(&OverlayScrollBar::Hide, base::Unretained(this))); 176 base::Bind(&OverlayScrollBar::Hide, base::Unretained(this)));
184 } 177 }
185 178
186 } // namespace views 179 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/scrollbar/overlay_scroll_bar.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698