Chromium Code Reviews| Index: ui/views/animation/ink_drop_animation.h |
| diff --git a/ui/views/animation/ink_drop_animation.h b/ui/views/animation/ink_drop_animation.h |
| index 6338480c5298df670743f107957892aab7084c76..4fd911cf9dbcece3c2851a7b57e0e37ab011eaf4 100644 |
| --- a/ui/views/animation/ink_drop_animation.h |
| +++ b/ui/views/animation/ink_drop_animation.h |
| @@ -8,90 +8,131 @@ |
| #include "base/macros.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/time/time.h" |
| -#include "ui/gfx/geometry/rect.h" |
| +#include "ui/compositor/layer_animator.h" |
| +#include "ui/gfx/geometry/size.h" |
| +#include "ui/gfx/geometry/size_f.h" |
| +#include "ui/gfx/transform.h" |
| #include "ui/views/animation/ink_drop_state.h" |
| #include "ui/views/views_export.h" |
| namespace ui { |
| class Layer; |
| +class LayerDelegate; |
| } // namespace ui |
| namespace views { |
| -class AppearAnimationObserver; |
| -class InkDropDelegate; |
| +class CircleLayerDelegate; |
| +class RectangleLayerDelegate; |
| // An ink drop animation that animates between the different InkDropStates. |
| +// TODO(bruthig): Document me better. |
| class VIEWS_EXPORT InkDropAnimation { |
| public: |
| - InkDropAnimation(); |
| + InkDropAnimation(const gfx::Size& large_size, |
| + int large_corner_radius, |
| + const gfx::Size& small_size, |
| + int small_corner_radius); |
| ~InkDropAnimation(); |
| // The root that can be added in to a Layer tree. |
| ui::Layer* GetRootLayer(); |
| - // Animates from the current |state_| to |state|. |
| + InkDropState ink_drop_state() const { return ink_drop_state_; } |
| + |
| + // Animates from the current |ink_drop_state_| to |state|. |
| void AnimateToState(InkDropState state); |
| - // Set the size of the ink drop. |
| - void SetInkDropSize(const gfx::Size& size); |
| + // Sets the origin of the ink drop. |
|
tdanderson
2015/08/19 22:11:19
Is this the origin in terms of where the input eve
bruthig
2015/08/20 20:35:35
Attempted to clarify in comment.
|
| + void SetOrigin(const gfx::Point& origin); |
| - // Returns the ink drop bounds. |
| - gfx::Rect GetInkDropBounds() const; |
| + private: |
| + // Structure that contains a gfx::Tansform for each of the layers required |
| + // by the ink drop. |
| + struct InkDropTransforms { |
| + InkDropTransforms(); |
| + ~InkDropTransforms(); |
| - // Sets the bounds for the ink drop. |bounds| are in the coordinate space of |
| - // the parent ui::Layer that the ink drop layer is added to. |
| - void SetInkDropBounds(const gfx::Rect& bounds); |
| + gfx::Transform top_left_circle; |
| + gfx::Transform top_right_circle; |
| + gfx::Transform bottom_right_circle; |
| + gfx::Transform bottom_left_circle; |
| + gfx::Transform horizontal_rect; |
| + gfx::Transform vertical_rect; |
| + }; |
| - private: |
| - // Starts the animation of a touch event. |
| - void AnimateTapDown(); |
| + // TODO(bruthig): Document me. |
| + void AnimateToTransforms( |
| + const InkDropTransforms& transforms, |
| + float opacity, |
| + base::TimeDelta duration, |
| + ui::LayerAnimator::PreemptionStrategy preemption_strategy); |
| - // Schedules the hide animation of |ink_drop_layer_| for once its current |
| - // animation has completed. If |ink_drop_layer_| is not animating, the hide |
| - // animation begins immediately. |
| - void AnimateHide(); |
| + // TODO(bruthig): Document me. |
| + void AnimateToTransform( |
| + ui::Layer* layer, |
| + const gfx::Transform& target_transform, |
| + base::TimeDelta duration, |
| + ui::LayerAnimator::PreemptionStrategy preemption_strategy); |
| - // Starts the animation of a long press, and cancels hiding |ink_drop_layer_| |
| - // until the long press has completed. |
| - void AnimateLongPress(); |
| + // TODO(bruthig): Document me. |
| + void ResetTransformsToMinSize(); |
| - // Starts the showing animation on |layer|, with a |duration| in milliseconds. |
| - void AnimateShow(ui::Layer* layer, |
| - AppearAnimationObserver* observer, |
| - base::TimeDelta duration); |
| + // TODO(bruthig): Document me. |
| + void SetTransforms(const InkDropTransforms& transforms); |
| - // Sets the bounds for |layer|. |
| - void SetLayerBounds(ui::Layer* layer); |
| + // TODO(bruthig): Document me. |
| + void SetOpacity(float opacity); |
| - // Initializes |layer|'s properties. |
| - void SetupAnimationLayer(ui::Layer* layer, InkDropDelegate* delegate); |
| + // TODO(bruthig): Document me. |
| + InkDropTransforms CalculateCircleTransforms(const gfx::SizeF size) const; |
| - // The root layer that parents the animating layers. |
| - scoped_ptr<ui::Layer> root_layer_; |
| + // TODO(bruthig): Document me. |
| + InkDropTransforms CalculateRectTransforms(const gfx::SizeF size, |
| + float corner_radius) const; |
| + |
| + // TODO(bruthig): Document me. |
| + InkDropTransforms GetCurrentTansforms() const; |
| - // The layer used for animating a user touch. |
| - scoped_ptr<ui::Layer> ink_drop_layer_; |
| + // Creates and configures a new painted layer and adds it to |layer_tree_|. |
| + ui::Layer* AddPaintLayer(ui::LayerDelegate* delegate); |
| - // ui::LayerDelegate responsible for painting to |ink_drop_layer_|. |
| - scoped_ptr<InkDropDelegate> ink_drop_delegate_; |
| + // Size used for large size animations. |
| + gfx::Size large_size_; |
|
tdanderson
2015/08/19 22:11:19
I'm not clear from the documentation what "large"
bruthig
2015/09/03 21:21:04
I made an attempt to better explain this with vari
|
| - // ui::ImplicitAnimationObserver which observes |ink_drop_layer_| and can be |
| - // used to automatically trigger a hide animation upon completion. |
| - scoped_ptr<AppearAnimationObserver> appear_animation_observer_; |
| + // Corner radius used for large size animations. |
| + int large_corner_radius_; |
| - // The layer used for animating a long press. |
| - scoped_ptr<ui::Layer> long_press_layer_; |
| + // Size used for small size animations. |
| + gfx::Size small_size_; |
| + |
| + // Corner radius used for small size animations. |
| + int small_corner_radius_; |
| + |
| + // ui::LayerDelegate to paint circles for all the circle layers. |
| + scoped_ptr<CircleLayerDelegate> circle_layer_delegate_; |
| + |
| + // ui::LayerDelegate to paint rectangles for all the rectangle layers. |
| + scoped_ptr<RectangleLayerDelegate> rect_layer_delegate_; |
| + |
| + // The root layer that parents the animating layers. The root layer is used to |
| + // manipulate opacity and origin, and its children are used to manipulate the |
| + // different painted shapes that compose the ink drop. |
| + scoped_ptr<ui::Layer> root_layer_; |
| - // ui::LayerDelegate responsible for painting to |long_press_layer_|. |
| - scoped_ptr<InkDropDelegate> long_press_delegate_; |
| + // The gfx::Transform to apply to the |root_layer_|. This is used to place the |
| + // ink drop to the specified origin. |
| + gfx::Transform root_layer_transform_; |
| - // ui::ImplicitAnimationObserver which observers |long_press_layer_| and can |
| - // be used to automatically trigger a hide animation upon completion. |
| - scoped_ptr<AppearAnimationObserver> long_press_animation_observer_; |
| + // ui::Layers for all of the painted shape layers that compose the ink drop. |
| + scoped_ptr<ui::Layer> top_left_circle_layer_; |
| + scoped_ptr<ui::Layer> top_right_circle_layer_; |
| + scoped_ptr<ui::Layer> bottom_right_circle_layer_; |
| + scoped_ptr<ui::Layer> bottom_left_circle_layer_; |
| + scoped_ptr<ui::Layer> horizontal_rect_layer_; |
| + scoped_ptr<ui::Layer> vertical_rect_layer_; |
| - // The bounds of the ink drop layers. Defined in the coordinate space of the |
| - // parent ui::Layer that the ink drop layers were added to. |
| - gfx::Rect ink_drop_bounds_; |
| + // The current ink drop state. |
| + InkDropState ink_drop_state_; |
| DISALLOW_COPY_AND_ASSIGN(InkDropAnimation); |
| }; |