| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_SQUARE_INK_DROP_RIPPLE_H_ | 5 #ifndef UI_VIEWS_ANIMATION_SQUARE_INK_DROP_RIPPLE_H_ |
| 6 #define UI_VIEWS_ANIMATION_SQUARE_INK_DROP_RIPPLE_H_ | 6 #define UI_VIEWS_ANIMATION_SQUARE_INK_DROP_RIPPLE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // The shape to use for the ACTIVATED/DEACTIVATED states. | 53 // The shape to use for the ACTIVATED/DEACTIVATED states. |
| 54 enum ActivatedShape { CIRCLE, ROUNDED_RECT }; | 54 enum ActivatedShape { CIRCLE, ROUNDED_RECT }; |
| 55 | 55 |
| 56 SquareInkDropRipple(const gfx::Size& large_size, | 56 SquareInkDropRipple(const gfx::Size& large_size, |
| 57 int large_corner_radius, | 57 int large_corner_radius, |
| 58 const gfx::Size& small_size, | 58 const gfx::Size& small_size, |
| 59 int small_corner_radius, | 59 int small_corner_radius, |
| 60 const gfx::Point& center_point, | 60 const gfx::Point& center_point, |
| 61 SkColor color, | 61 SkColor color, |
| 62 float visible_opacity); | 62 float visible_opacity); |
| 63 | |
| 64 SquareInkDropRipple(const gfx::Size& large_size, | |
| 65 int large_corner_radius, | |
| 66 const gfx::Size& small_size, | |
| 67 int small_corner_radius, | |
| 68 const gfx::Point& initial_center_point, | |
| 69 const gfx::Point& target_center_point, | |
| 70 SkColor color, | |
| 71 float visible_opacity); | |
| 72 ~SquareInkDropRipple() override; | 63 ~SquareInkDropRipple() override; |
| 73 | 64 |
| 74 void set_activated_shape(ActivatedShape shape) { activated_shape_ = shape; } | 65 void set_activated_shape(ActivatedShape shape) { activated_shape_ = shape; } |
| 75 | 66 |
| 76 // InkDropRipple: | 67 // InkDropRipple: |
| 77 void SnapToActivated() override; | 68 void SnapToActivated() override; |
| 78 ui::Layer* GetRootLayer() override; | 69 ui::Layer* GetRootLayer() override; |
| 79 | 70 |
| 80 private: | 71 private: |
| 81 friend class test::SquareInkDropRippleTestApi; | 72 friend class test::SquareInkDropRippleTestApi; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 101 | 92 |
| 102 float GetCurrentOpacity() const; | 93 float GetCurrentOpacity() const; |
| 103 | 94 |
| 104 // InkDropRipple: | 95 // InkDropRipple: |
| 105 void AnimateStateChange(InkDropState old_ink_drop_state, | 96 void AnimateStateChange(InkDropState old_ink_drop_state, |
| 106 InkDropState new_ink_drop_state, | 97 InkDropState new_ink_drop_state, |
| 107 ui::LayerAnimationObserver* observer) override; | 98 ui::LayerAnimationObserver* observer) override; |
| 108 void SetStateToHidden() override; | 99 void SetStateToHidden() override; |
| 109 void AbortAllAnimations() override; | 100 void AbortAllAnimations() override; |
| 110 | 101 |
| 111 // Animates the |root_layer_| to the specified |center_point|. The animation | |
| 112 // will be configured with the given |duration|, |tween|, and | |
| 113 // |preemption_strategy| values. The |observer| will be added to all | |
| 114 // LayerAnimationSequences if not null. | |
| 115 void AnimateCenterPoint( | |
| 116 const gfx::Point& center_point, | |
| 117 base::TimeDelta duration, | |
| 118 ui::LayerAnimator::PreemptionStrategy preemption_strategy, | |
| 119 gfx::Tween::Type tween, | |
| 120 ui::LayerAnimationObserver* observer); | |
| 121 | |
| 122 // Animates all of the painted shape layers to the specified |transforms|. The | 102 // Animates all of the painted shape layers to the specified |transforms|. The |
| 123 // animation will be configured with the given |duration|, |tween|, and | 103 // animation will be configured with the given |duration|, |tween|, and |
| 124 // |preemption_strategy| values. The |observer| will be added to all | 104 // |preemption_strategy| values. The |observer| will be added to all |
| 125 // LayerAnimationSequences if not null. | 105 // LayerAnimationSequences if not null. |
| 126 void AnimateToTransforms( | 106 void AnimateToTransforms( |
| 127 const InkDropTransforms transforms, | 107 const InkDropTransforms transforms, |
| 128 base::TimeDelta duration, | 108 base::TimeDelta duration, |
| 129 ui::LayerAnimator::PreemptionStrategy preemption_strategy, | 109 ui::LayerAnimator::PreemptionStrategy preemption_strategy, |
| 130 gfx::Tween::Type tween, | 110 gfx::Tween::Type tween, |
| 131 ui::LayerAnimationObserver* observer); | 111 ui::LayerAnimationObserver* observer); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 // Transforms for the DEACTIVATED animation. | 152 // Transforms for the DEACTIVATED animation. |
| 173 void GetDeactivatedTargetTransforms(InkDropTransforms* transforms_out) const; | 153 void GetDeactivatedTargetTransforms(InkDropTransforms* transforms_out) const; |
| 174 | 154 |
| 175 // Adds and configures a new |painted_shape| layer to |painted_layers_|. | 155 // Adds and configures a new |painted_shape| layer to |painted_layers_|. |
| 176 void AddPaintLayer(PaintedShape painted_shape); | 156 void AddPaintLayer(PaintedShape painted_shape); |
| 177 | 157 |
| 178 // The shape used for the ACTIVATED/DEACTIVATED states. | 158 // The shape used for the ACTIVATED/DEACTIVATED states. |
| 179 ActivatedShape activated_shape_; | 159 ActivatedShape activated_shape_; |
| 180 | 160 |
| 181 // Ink drop opacity when it is visible. | 161 // Ink drop opacity when it is visible. |
| 182 float visible_opacity_; | 162 const float visible_opacity_; |
| 183 | |
| 184 // The center point that the ripple will animate to. | |
| 185 gfx::Point target_center_point_; | |
| 186 | 163 |
| 187 // Maximum size that an ink drop will be drawn to for any InkDropState whose | 164 // Maximum size that an ink drop will be drawn to for any InkDropState whose |
| 188 // final frame should be large. | 165 // final frame should be large. |
| 189 gfx::Size large_size_; | 166 const gfx::Size large_size_; |
| 190 | 167 |
| 191 // Corner radius used to draw the rounded rectangles corner for any | 168 // Corner radius used to draw the rounded rectangles corner for any |
| 192 // InkDropState whose final frame should be large. | 169 // InkDropState whose final frame should be large. |
| 193 int large_corner_radius_; | 170 const int large_corner_radius_; |
| 194 | 171 |
| 195 // Maximum size that an ink drop will be drawn to for any InkDropState whose | 172 // Maximum size that an ink drop will be drawn to for any InkDropState whose |
| 196 // final frame should be small. | 173 // final frame should be small. |
| 197 gfx::Size small_size_; | 174 const gfx::Size small_size_; |
| 198 | 175 |
| 199 // Corner radius used to draw the rounded rectangles corner for any | 176 // Corner radius used to draw the rounded rectangles corner for any |
| 200 // InkDropState whose final frame should be small. | 177 // InkDropState whose final frame should be small. |
| 201 int small_corner_radius_; | 178 const int small_corner_radius_; |
| 202 | 179 |
| 203 // ui::LayerDelegate to paint circles for all the circle layers. | 180 // ui::LayerDelegate to paint circles for all the circle layers. |
| 204 std::unique_ptr<CircleLayerDelegate> circle_layer_delegate_; | 181 std::unique_ptr<CircleLayerDelegate> circle_layer_delegate_; |
| 205 | 182 |
| 206 // ui::LayerDelegate to paint rectangles for all the rectangle layers. | 183 // ui::LayerDelegate to paint rectangles for all the rectangle layers. |
| 207 std::unique_ptr<RectangleLayerDelegate> rect_layer_delegate_; | 184 std::unique_ptr<RectangleLayerDelegate> rect_layer_delegate_; |
| 208 | 185 |
| 209 // The root layer that parents the animating layers. The root layer is used to | 186 // The root layer that parents the animating layers. The root layer is used to |
| 210 // manipulate opacity and location, and its children are used to manipulate | 187 // manipulate opacity and location, and its children are used to manipulate |
| 211 // the different painted shapes that compose the ink drop. | 188 // the different painted shapes that compose the ink drop. |
| 212 ui::Layer root_layer_; | 189 ui::Layer root_layer_; |
| 213 | 190 |
| 214 // ui::Layers for all of the painted shape layers that compose the ink drop. | 191 // ui::Layers for all of the painted shape layers that compose the ink drop. |
| 215 std::unique_ptr<ui::Layer> painted_layers_[PAINTED_SHAPE_COUNT]; | 192 std::unique_ptr<ui::Layer> painted_layers_[PAINTED_SHAPE_COUNT]; |
| 216 | 193 |
| 217 DISALLOW_COPY_AND_ASSIGN(SquareInkDropRipple); | 194 DISALLOW_COPY_AND_ASSIGN(SquareInkDropRipple); |
| 218 }; | 195 }; |
| 219 | 196 |
| 220 } // namespace views | 197 } // namespace views |
| 221 | 198 |
| 222 #endif // UI_VIEWS_ANIMATION_SQUARE_INK_DROP_RIPPLE_H_ | 199 #endif // UI_VIEWS_ANIMATION_SQUARE_INK_DROP_RIPPLE_H_ |
| OLD | NEW |