OLD | NEW |
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 "cc/input/scrollbar_animation_controller_thinning.h" | 5 #include "cc/input/scrollbar_animation_controller_thinning.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "cc/layers/layer_impl.h" | 9 #include "cc/layers/layer_impl.h" |
10 #include "cc/layers/scrollbar_layer_impl_base.h" | 10 #include "cc/layers/scrollbar_layer_impl_base.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 | 157 |
158 if (mouse_is_near_scrollbar_ != mouse_is_near_scrollbar) { | 158 if (mouse_is_near_scrollbar_ != mouse_is_near_scrollbar) { |
159 mouse_is_near_scrollbar_ = mouse_is_near_scrollbar; | 159 mouse_is_near_scrollbar_ = mouse_is_near_scrollbar; |
160 thickness_change_ = mouse_is_near_scrollbar_ ? INCREASE : DECREASE; | 160 thickness_change_ = mouse_is_near_scrollbar_ ? INCREASE : DECREASE; |
161 } | 161 } |
162 | 162 |
163 SetCurrentAnimatingProperty(THICKNESS); | 163 SetCurrentAnimatingProperty(THICKNESS); |
164 StartAnimation(); | 164 StartAnimation(); |
165 } | 165 } |
166 | 166 |
| 167 bool ScrollbarAnimationControllerThinning::ScrollbarsHidden() const { |
| 168 return opacity_ == 0.0f; |
| 169 } |
| 170 |
167 float ScrollbarAnimationControllerThinning::ThumbThicknessScaleAt( | 171 float ScrollbarAnimationControllerThinning::ThumbThicknessScaleAt( |
168 float progress) { | 172 float progress) { |
169 if (thickness_change_ == NONE) | 173 if (thickness_change_ == NONE) |
170 return mouse_is_near_scrollbar_ ? 1.f : kIdleThicknessScale; | 174 return mouse_is_near_scrollbar_ ? 1.f : kIdleThicknessScale; |
171 float factor = thickness_change_ == INCREASE ? progress : (1.f - progress); | 175 float factor = thickness_change_ == INCREASE ? progress : (1.f - progress); |
172 return ((1.f - kIdleThicknessScale) * factor) + kIdleThicknessScale; | 176 return ((1.f - kIdleThicknessScale) * factor) + kIdleThicknessScale; |
173 } | 177 } |
174 | 178 |
175 float ScrollbarAnimationControllerThinning::AdjustScale( | 179 float ScrollbarAnimationControllerThinning::AdjustScale( |
176 float new_value, | 180 float new_value, |
(...skipping 29 matching lines...) Expand all Loading... |
206 // be overwritten anyway when property trees are pushed. | 210 // be overwritten anyway when property trees are pushed. |
207 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, | 211 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, |
208 scrollbar->id())) { | 212 scrollbar->id())) { |
209 property_trees->effect_tree.OnOpacityAnimated( | 213 property_trees->effect_tree.OnOpacityAnimated( |
210 effective_opacity, | 214 effective_opacity, |
211 property_trees->effect_id_to_index_map[scrollbar->id()], | 215 property_trees->effect_id_to_index_map[scrollbar->id()], |
212 scrollbar->layer_tree_impl()); | 216 scrollbar->layer_tree_impl()); |
213 } | 217 } |
214 } | 218 } |
215 | 219 |
| 220 bool previouslyVisible = opacity_ > 0.0f; |
| 221 bool currentlyVisible = opacity > 0.0f; |
| 222 |
216 opacity_ = opacity; | 223 opacity_ = opacity; |
| 224 |
| 225 if (previouslyVisible != currentlyVisible) |
| 226 client_->DidChangeScrollbarVisibility(); |
217 } | 227 } |
218 | 228 |
219 void ScrollbarAnimationControllerThinning::ApplyThumbThicknessScale( | 229 void ScrollbarAnimationControllerThinning::ApplyThumbThicknessScale( |
220 float thumb_thickness_scale) { | 230 float thumb_thickness_scale) { |
221 for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) { | 231 for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) { |
222 if (!scrollbar->is_overlay_scrollbar()) | 232 if (!scrollbar->is_overlay_scrollbar()) |
223 continue; | 233 continue; |
224 | 234 |
225 scrollbar->SetThumbThicknessScaleFactor(AdjustScale( | 235 scrollbar->SetThumbThicknessScaleFactor(AdjustScale( |
226 thumb_thickness_scale, scrollbar->thumb_thickness_scale_factor(), | 236 thumb_thickness_scale, scrollbar->thumb_thickness_scale_factor(), |
227 thickness_change_, kIdleThicknessScale, 1)); | 237 thickness_change_, kIdleThicknessScale, 1)); |
228 } | 238 } |
229 } | 239 } |
230 | 240 |
231 void ScrollbarAnimationControllerThinning::SetCurrentAnimatingProperty( | 241 void ScrollbarAnimationControllerThinning::SetCurrentAnimatingProperty( |
232 AnimatingProperty property) { | 242 AnimatingProperty property) { |
233 if (current_animating_property_ == property) | 243 if (current_animating_property_ == property) |
234 return; | 244 return; |
235 | 245 |
236 StopAnimation(); | 246 StopAnimation(); |
237 current_animating_property_ = property; | 247 current_animating_property_ = property; |
238 if (current_animating_property_ == THICKNESS) | 248 if (current_animating_property_ == THICKNESS) |
239 ApplyOpacity(1.f); | 249 ApplyOpacity(1.f); |
240 } | 250 } |
241 | 251 |
242 } // namespace cc | 252 } // namespace cc |
OLD | NEW |