| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 ApplyOpacity(1.f - progress); | 65 ApplyOpacity(1.f - progress); |
| 66 else | 66 else |
| 67 ApplyThumbThicknessScale(ThumbThicknessScaleAt(progress)); | 67 ApplyThumbThicknessScale(ThumbThicknessScaleAt(progress)); |
| 68 | 68 |
| 69 client_->SetNeedsRedrawForScrollbarAnimation(); | 69 client_->SetNeedsRedrawForScrollbarAnimation(); |
| 70 if (progress == 1.f) { | 70 if (progress == 1.f) { |
| 71 StopAnimation(); | 71 StopAnimation(); |
| 72 if (current_animating_property_ == THICKNESS) { | 72 if (current_animating_property_ == THICKNESS) { |
| 73 thickness_change_ = NONE; | 73 thickness_change_ = NONE; |
| 74 SetCurrentAnimatingProperty(OPACITY); | 74 SetCurrentAnimatingProperty(OPACITY); |
| 75 PostDelayedAnimationTask(false); | 75 if (!mouse_is_near_scrollbar_) |
| 76 PostDelayedAnimationTask(false); |
| 76 } | 77 } |
| 77 } | 78 } |
| 78 } | 79 } |
| 79 | 80 |
| 80 const base::TimeDelta& ScrollbarAnimationControllerThinning::Duration() { | 81 const base::TimeDelta& ScrollbarAnimationControllerThinning::Duration() { |
| 81 if (current_animating_property_ == OPACITY) | 82 if (current_animating_property_ == OPACITY) |
| 82 return fade_duration_; | 83 return fade_duration_; |
| 83 else | 84 else |
| 84 return thinning_duration_; | 85 return thinning_duration_; |
| 85 } | 86 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 100 | 101 |
| 101 captured_ = false; | 102 captured_ = false; |
| 102 StopAnimation(); | 103 StopAnimation(); |
| 103 | 104 |
| 104 if (!mouse_is_near_scrollbar_) { | 105 if (!mouse_is_near_scrollbar_) { |
| 105 SetCurrentAnimatingProperty(THICKNESS); | 106 SetCurrentAnimatingProperty(THICKNESS); |
| 106 thickness_change_ = DECREASE; | 107 thickness_change_ = DECREASE; |
| 107 StartAnimation(); | 108 StartAnimation(); |
| 108 } else { | 109 } else { |
| 109 SetCurrentAnimatingProperty(OPACITY); | 110 SetCurrentAnimatingProperty(OPACITY); |
| 110 PostDelayedAnimationTask(false); | |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 void ScrollbarAnimationControllerThinning::DidMouseLeave() { | 114 void ScrollbarAnimationControllerThinning::DidMouseLeave() { |
| 115 if (!mouse_is_over_scrollbar_ && !mouse_is_near_scrollbar_) | 115 if (!mouse_is_over_scrollbar_ && !mouse_is_near_scrollbar_) |
| 116 return; | 116 return; |
| 117 | 117 |
| 118 mouse_is_over_scrollbar_ = false; | 118 mouse_is_over_scrollbar_ = false; |
| 119 mouse_is_near_scrollbar_ = false; | 119 mouse_is_near_scrollbar_ = false; |
| 120 | 120 |
| 121 if (captured_ || opacity_ == 0.0f) | 121 if (captured_ || opacity_ == 0.0f) |
| 122 return; | 122 return; |
| 123 | 123 |
| 124 thickness_change_ = DECREASE; | 124 thickness_change_ = DECREASE; |
| 125 SetCurrentAnimatingProperty(THICKNESS); | 125 SetCurrentAnimatingProperty(THICKNESS); |
| 126 StartAnimation(); | 126 StartAnimation(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void ScrollbarAnimationControllerThinning::DidScrollUpdate(bool on_resize) { | 129 void ScrollbarAnimationControllerThinning::DidScrollUpdate(bool on_resize) { |
| 130 if (captured_) | 130 if (captured_) |
| 131 return; | 131 return; |
| 132 | 132 |
| 133 ScrollbarAnimationController::DidScrollUpdate(on_resize); | 133 ScrollbarAnimationController::DidScrollUpdate(on_resize); |
| 134 ApplyOpacity(1.f); | 134 ApplyOpacity(1.f); |
| 135 ApplyThumbThicknessScale(mouse_is_near_scrollbar_ ? 1.f | 135 ApplyThumbThicknessScale(mouse_is_near_scrollbar_ ? 1.f |
| 136 : kIdleThicknessScale); | 136 : kIdleThicknessScale); |
| 137 SetCurrentAnimatingProperty(OPACITY); | 137 SetCurrentAnimatingProperty(OPACITY); |
| 138 |
| 139 // Don't fade out the scrollbar when mouse is near. |
| 140 if (mouse_is_near_scrollbar_) |
| 141 StopAnimation(); |
| 142 } |
| 143 |
| 144 void ScrollbarAnimationControllerThinning::DidScrollEnd() { |
| 145 ScrollbarAnimationController::DidScrollEnd(); |
| 146 |
| 147 // Don't fade out the scrollbar when mouse is near. |
| 148 if (mouse_is_near_scrollbar_) |
| 149 StopAnimation(); |
| 138 } | 150 } |
| 139 | 151 |
| 140 void ScrollbarAnimationControllerThinning::DidMouseMoveNear(float distance) { | 152 void ScrollbarAnimationControllerThinning::DidMouseMoveNear(float distance) { |
| 141 bool mouse_is_over_scrollbar = distance == 0.0f; | 153 bool mouse_is_over_scrollbar = distance == 0.0f; |
| 142 bool mouse_is_near_scrollbar = | 154 bool mouse_is_near_scrollbar = |
| 143 distance < mouse_move_distance_to_trigger_animation_; | 155 distance < mouse_move_distance_to_trigger_animation_; |
| 144 | 156 |
| 145 if (captured_ || opacity_ == 0.0f) { | 157 if (captured_ || opacity_ == 0.0f) { |
| 146 mouse_is_near_scrollbar_ = mouse_is_near_scrollbar; | 158 mouse_is_near_scrollbar_ = mouse_is_near_scrollbar; |
| 147 mouse_is_over_scrollbar_ = mouse_is_over_scrollbar; | 159 mouse_is_over_scrollbar_ = mouse_is_over_scrollbar; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 if (current_animating_property_ == property) | 255 if (current_animating_property_ == property) |
| 244 return; | 256 return; |
| 245 | 257 |
| 246 StopAnimation(); | 258 StopAnimation(); |
| 247 current_animating_property_ = property; | 259 current_animating_property_ = property; |
| 248 if (current_animating_property_ == THICKNESS) | 260 if (current_animating_property_ == THICKNESS) |
| 249 ApplyOpacity(1.f); | 261 ApplyOpacity(1.f); |
| 250 } | 262 } |
| 251 | 263 |
| 252 } // namespace cc | 264 } // namespace cc |
| OLD | NEW |