| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // LayerAnimationSequences if not null. | 124 // LayerAnimationSequences if not null. |
| 125 void AnimateToOpacity( | 125 void AnimateToOpacity( |
| 126 float opacity, | 126 float opacity, |
| 127 base::TimeDelta duration, | 127 base::TimeDelta duration, |
| 128 ui::LayerAnimator::PreemptionStrategy preemption_strategy, | 128 ui::LayerAnimator::PreemptionStrategy preemption_strategy, |
| 129 gfx::Tween::Type tween, | 129 gfx::Tween::Type tween, |
| 130 ui::LayerAnimationObserver* observer); | 130 ui::LayerAnimationObserver* observer); |
| 131 | 131 |
| 132 // Updates all of the Transforms in |transforms_out| for a circle of the given | 132 // Updates all of the Transforms in |transforms_out| for a circle of the given |
| 133 // |size|. | 133 // |size|. |
| 134 void CalculateCircleTransforms(const gfx::Size& size, | 134 void CalculateCircleTransforms(const gfx::Size& desired_size, |
| 135 InkDropTransforms* transforms_out) const; | 135 InkDropTransforms* transforms_out) const; |
| 136 | 136 |
| 137 // Updates all of the Transforms in |transforms_out| for a rounded rectangle | 137 // Updates all of the Transforms in |transforms_out| for a rounded rectangle |
| 138 // of the given |size| and |corner_radius|. | 138 // of the given |desired_size| and |corner_radius|. The effective size may |
| 139 void CalculateRectTransforms(const gfx::Size& size, | 139 // differ from |desired_size| at certain scale factors to make sure the ripple |
| 140 // is pixel-aligned. |
| 141 void CalculateRectTransforms(const gfx::Size& desired_size, |
| 140 float corner_radius, | 142 float corner_radius, |
| 141 InkDropTransforms* transforms_out) const; | 143 InkDropTransforms* transforms_out) const; |
| 142 | 144 |
| 145 // Calculates a Transform for a circle layer. |
| 146 gfx::Transform CalculateCircleTransform(float scale, |
| 147 float target_center_x, |
| 148 float target_center_y) const; |
| 149 |
| 150 // Calculates a Transform for a rectangle layer. |
| 151 gfx::Transform CalculateRectTransform(float x_scale, float y_scale) const; |
| 152 |
| 143 // Updates all of the Transforms in |transforms_out| to the current Transforms | 153 // Updates all of the Transforms in |transforms_out| to the current Transforms |
| 144 // of the painted shape Layers. | 154 // of the painted shape Layers. |
| 145 void GetCurrentTransforms(InkDropTransforms* transforms_out) const; | 155 void GetCurrentTransforms(InkDropTransforms* transforms_out) const; |
| 146 | 156 |
| 147 // Updates all of the Transforms in |transforms_out| with the target | 157 // Updates all of the Transforms in |transforms_out| with the target |
| 148 // Transforms for the ACTIVATED animation. | 158 // Transforms for the ACTIVATED animation. |
| 149 void GetActivatedTargetTransforms(InkDropTransforms* transforms_out) const; | 159 void GetActivatedTargetTransforms(InkDropTransforms* transforms_out) const; |
| 150 | 160 |
| 151 // Updates all of the Transforms in |transforms_out| with the target | 161 // Updates all of the Transforms in |transforms_out| with the target |
| 152 // Transforms for the DEACTIVATED animation. | 162 // Transforms for the DEACTIVATED animation. |
| 153 void GetDeactivatedTargetTransforms(InkDropTransforms* transforms_out) const; | 163 void GetDeactivatedTargetTransforms(InkDropTransforms* transforms_out) const; |
| 154 | 164 |
| 155 // Adds and configures a new |painted_shape| layer to |painted_layers_|. | 165 // Adds and configures a new |painted_shape| layer to |painted_layers_|. |
| 156 void AddPaintLayer(PaintedShape painted_shape); | 166 void AddPaintLayer(PaintedShape painted_shape); |
| 157 | 167 |
| 158 // The shape used for the ACTIVATED/DEACTIVATED states. | 168 // The shape used for the ACTIVATED/DEACTIVATED states. |
| 159 ActivatedShape activated_shape_; | 169 ActivatedShape activated_shape_; |
| 160 | 170 |
| 161 // Ink drop opacity when it is visible. | 171 // Ink drop opacity when it is visible. |
| 162 const float visible_opacity_; | 172 float visible_opacity_; |
| 163 | 173 |
| 164 // Maximum size that an ink drop will be drawn to for any InkDropState whose | 174 // Maximum size that an ink drop will be drawn to for any InkDropState whose |
| 165 // final frame should be large. | 175 // final frame should be large. |
| 166 const gfx::Size large_size_; | 176 const gfx::Size large_size_; |
| 167 | 177 |
| 168 // Corner radius used to draw the rounded rectangles corner for any | 178 // Corner radius used to draw the rounded rectangles corner for any |
| 169 // InkDropState whose final frame should be large. | 179 // InkDropState whose final frame should be large. |
| 170 const int large_corner_radius_; | 180 const int large_corner_radius_; |
| 171 | 181 |
| 172 // Maximum size that an ink drop will be drawn to for any InkDropState whose | 182 // Maximum size that an ink drop will be drawn to for any InkDropState whose |
| 173 // final frame should be small. | 183 // final frame should be small. |
| 174 const gfx::Size small_size_; | 184 const gfx::Size small_size_; |
| 175 | 185 |
| 176 // Corner radius used to draw the rounded rectangles corner for any | 186 // Corner radius used to draw the rounded rectangles corner for any |
| 177 // InkDropState whose final frame should be small. | 187 // InkDropState whose final frame should be small. |
| 178 const int small_corner_radius_; | 188 const int small_corner_radius_; |
| 179 | 189 |
| 190 // The center point of the ripple, relative to the root layer's origin. |
| 191 gfx::Point center_point_; |
| 192 |
| 180 // ui::LayerDelegate to paint circles for all the circle layers. | 193 // ui::LayerDelegate to paint circles for all the circle layers. |
| 181 std::unique_ptr<CircleLayerDelegate> circle_layer_delegate_; | 194 std::unique_ptr<CircleLayerDelegate> circle_layer_delegate_; |
| 182 | 195 |
| 183 // ui::LayerDelegate to paint rectangles for all the rectangle layers. | 196 // ui::LayerDelegate to paint rectangles for all the rectangle layers. |
| 184 std::unique_ptr<RectangleLayerDelegate> rect_layer_delegate_; | 197 std::unique_ptr<RectangleLayerDelegate> rect_layer_delegate_; |
| 185 | 198 |
| 186 // The root layer that parents the animating layers. The root layer is used to | 199 // The root layer that parents the animating layers. The root layer is used to |
| 187 // manipulate opacity and location, and its children are used to manipulate | 200 // manipulate opacity and location, and its children are used to manipulate |
| 188 // the different painted shapes that compose the ink drop. | 201 // the different painted shapes that compose the ink drop. |
| 189 ui::Layer root_layer_; | 202 ui::Layer root_layer_; |
| 190 | 203 |
| 191 // ui::Layers for all of the painted shape layers that compose the ink drop. | 204 // ui::Layers for all of the painted shape layers that compose the ink drop. |
| 192 std::unique_ptr<ui::Layer> painted_layers_[PAINTED_SHAPE_COUNT]; | 205 std::unique_ptr<ui::Layer> painted_layers_[PAINTED_SHAPE_COUNT]; |
| 193 | 206 |
| 194 DISALLOW_COPY_AND_ASSIGN(SquareInkDropRipple); | 207 DISALLOW_COPY_AND_ASSIGN(SquareInkDropRipple); |
| 195 }; | 208 }; |
| 196 | 209 |
| 197 } // namespace views | 210 } // namespace views |
| 198 | 211 |
| 199 #endif // UI_VIEWS_ANIMATION_SQUARE_INK_DROP_RIPPLE_H_ | 212 #endif // UI_VIEWS_ANIMATION_SQUARE_INK_DROP_RIPPLE_H_ |
| OLD | NEW |