| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_H_ | 5 #ifndef UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_H_ |
| 6 #define UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_H_ | 6 #define UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "ui/compositor/layer_animator.h" | 12 #include "ui/compositor/layer_animator.h" |
| 13 #include "ui/gfx/geometry/point.h" |
| 13 #include "ui/gfx/geometry/size.h" | 14 #include "ui/gfx/geometry/size.h" |
| 14 #include "ui/gfx/transform.h" | 15 #include "ui/gfx/transform.h" |
| 15 #include "ui/views/animation/ink_drop_state.h" | 16 #include "ui/views/animation/ink_drop_state.h" |
| 16 #include "ui/views/views_export.h" | 17 #include "ui/views/views_export.h" |
| 17 | 18 |
| 18 namespace ui { | 19 namespace ui { |
| 19 class CallbackLayerAnimationObserver; | 20 class CallbackLayerAnimationObserver; |
| 20 class Layer; | 21 class Layer; |
| 21 class LayerAnimationObserver; | 22 class LayerAnimationObserver; |
| 22 class LayerDelegate; | 23 class LayerDelegate; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 82 |
| 82 // Type that contains a gfx::Tansform for each of the layers required by the | 83 // Type that contains a gfx::Tansform for each of the layers required by the |
| 83 // ink drop. | 84 // ink drop. |
| 84 typedef gfx::Transform InkDropTransforms[PAINTED_SHAPE_COUNT]; | 85 typedef gfx::Transform InkDropTransforms[PAINTED_SHAPE_COUNT]; |
| 85 | 86 |
| 86 // Animates the ripple to |ink_drop_state| and attaches |observer| to all | 87 // Animates the ripple to |ink_drop_state| and attaches |observer| to all |
| 87 // LayerAnimationSequence's used. | 88 // LayerAnimationSequence's used. |
| 88 void AnimateToStateInternal(InkDropState ink_drop_state, | 89 void AnimateToStateInternal(InkDropState ink_drop_state, |
| 89 ui::LayerAnimationObserver* observer); | 90 ui::LayerAnimationObserver* observer); |
| 90 | 91 |
| 91 // Animates all of the painted shape layers to the specified |transforms| and | 92 // Animates all of the painted shape layers to the specified |transforms|. The |
| 92 // |opacity|. The animation will use the given |duration| and | 93 // animation will use the given |duration| and |preemption_strategy|, and |
| 93 // |preemption_strategy|, and |observer| will be added to all | 94 // |observer| will be added to all LayerAnimationSequences. |
| 94 // LayerAnimationSequences. | |
| 95 void AnimateToTransforms( | 95 void AnimateToTransforms( |
| 96 const InkDropTransforms transforms, | 96 const InkDropTransforms transforms, |
| 97 float opacity, | |
| 98 base::TimeDelta duration, | 97 base::TimeDelta duration, |
| 99 ui::LayerAnimator::PreemptionStrategy preemption_strategy, | 98 ui::LayerAnimator::PreemptionStrategy preemption_strategy, |
| 100 ui::LayerAnimationObserver* observer); | 99 ui::LayerAnimationObserver* observer); |
| 101 | 100 |
| 102 // Updates the Transforms and opacity to the HIDDEN state. | 101 // Updates the Transforms and opacity to the HIDDEN state. |
| 103 void SetStateToHidden(); | 102 void SetStateToHidden(); |
| 104 | 103 |
| 105 // Sets the |transforms| on all of the shape layers. Note that this does not | 104 // Sets the |transforms| on all of the shape layers. Note that this does not |
| 106 // perform any animation. | 105 // perform any animation. |
| 107 void SetTransforms(const InkDropTransforms transforms); | 106 void SetTransforms(const InkDropTransforms transforms); |
| 108 | 107 |
| 109 // Sets the opacity of the ink drop. | 108 // Sets the opacity of the ink drop. |
| 110 void SetOpacity(float opacity); | 109 void SetOpacity(float opacity); |
| 111 | 110 |
| 111 // Animates all of the painted shape layers to the specified |opacity|. The |
| 112 // animation will use the given |duration| and |preemption_strategy|, and |
| 113 // |observer| will be added to all LayerAnimationSequences. |
| 114 void AnimateToOpacity( |
| 115 float opacity, |
| 116 base::TimeDelta duration, |
| 117 ui::LayerAnimator::PreemptionStrategy preemption_strategy, |
| 118 ui::LayerAnimationObserver* animation_observer); |
| 119 |
| 112 // Updates all of the Transforms in |transforms_out| for a circle of the given | 120 // Updates all of the Transforms in |transforms_out| for a circle of the given |
| 113 // |size|. | 121 // |size|. |
| 114 void CalculateCircleTransforms(const gfx::Size& size, | 122 void CalculateCircleTransforms(const gfx::Size& size, |
| 115 InkDropTransforms* transforms_out) const; | 123 InkDropTransforms* transforms_out) const; |
| 116 | 124 |
| 117 // Updates all of the Transforms in |transforms_out| for a rounded rectangle | 125 // Updates all of the Transforms in |transforms_out| for a rounded rectangle |
| 118 // of the given |size| and |corner_radius|. | 126 // of the given |size| and |corner_radius|. |
| 119 void CalculateRectTransforms(const gfx::Size& size, | 127 void CalculateRectTransforms(const gfx::Size& size, |
| 120 float corner_radius, | 128 float corner_radius, |
| 121 InkDropTransforms* transforms_out) const; | 129 InkDropTransforms* transforms_out) const; |
| 122 | 130 |
| 123 // Updates all of the Transforms in |transforms_out| to the current target | 131 // Updates all of the Transforms in |transforms_out| to the current Transforms |
| 124 // Transforms of the Layers. | 132 // of the Layers. |
| 125 void GetCurrentTansforms(InkDropTransforms* transforms_out) const; | 133 void GetCurrentTransforms(InkDropTransforms* transforms_out) const; |
| 126 | 134 |
| 127 // Adds and configures a new |painted_shape| layer to |painted_layers_|. | 135 // Adds and configures a new |painted_shape| layer to |painted_layers_|. |
| 128 void AddPaintLayer(PaintedShape painted_shape); | 136 void AddPaintLayer(PaintedShape painted_shape); |
| 129 | 137 |
| 130 void AbortAllAnimations(); | 138 void AbortAllAnimations(); |
| 131 | 139 |
| 140 // Calculates an estimated distance ratio between 0.0 and 1.0 that estimates |
| 141 // how close the painted shape |transforms| are away from the final |
| 142 // QUICK_ACTION transforms. |
| 143 float CalculateDistanceEstimateToQuickAction( |
| 144 const InkDropTransforms& transforms) const; |
| 145 |
| 132 // The Callback invoked when all of the animation sequences for the specific | 146 // The Callback invoked when all of the animation sequences for the specific |
| 133 // |ink_drop_state| animation have started. |observer| is the | 147 // |ink_drop_state| animation have started. |observer| is the |
| 134 // ui::CallbackLayerAnimationObserver which is notifying the callback. | 148 // ui::CallbackLayerAnimationObserver which is notifying the callback. |
| 135 void AnimationStartedCallback( | 149 void AnimationStartedCallback( |
| 136 InkDropState ink_drop_state, | 150 InkDropState ink_drop_state, |
| 137 const ui::CallbackLayerAnimationObserver& observer); | 151 const ui::CallbackLayerAnimationObserver& observer); |
| 138 | 152 |
| 139 // The Callback invoked when all of the animation sequences for the specific | 153 // The Callback invoked when all of the animation sequences for the specific |
| 140 // |ink_drop_state| animation have finished. |observer| is the | 154 // |ink_drop_state| animation have finished. |observer| is the |
| 141 // ui::CallbackLayerAnimationObserver which is notifying the callback. | 155 // ui::CallbackLayerAnimationObserver which is notifying the callback. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 192 |
| 179 // List of observers to notify when animations have finished. | 193 // List of observers to notify when animations have finished. |
| 180 base::ObserverList<InkDropAnimationObserver> observers_; | 194 base::ObserverList<InkDropAnimationObserver> observers_; |
| 181 | 195 |
| 182 DISALLOW_COPY_AND_ASSIGN(InkDropAnimation); | 196 DISALLOW_COPY_AND_ASSIGN(InkDropAnimation); |
| 183 }; | 197 }; |
| 184 | 198 |
| 185 } // namespace views | 199 } // namespace views |
| 186 | 200 |
| 187 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_H_ | 201 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_H_ |
| OLD | NEW |