 Chromium Code Reviews
 Chromium Code Reviews Issue 1298513003:
  Implemented prototype for new ink drop specs.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1298513003:
  Implemented prototype for new ink drop specs.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| 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 9c50f3a47d98d9d734fe9f07b4e6b17cf1e30d14..7347df98f9096cd55707c61f909ebdb44b2bfe98 100644 | 
| --- a/ui/views/animation/ink_drop_animation.h | 
| +++ b/ui/views/animation/ink_drop_animation.h | 
| @@ -8,90 +8,140 @@ | 
| #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. | 
| +namespace test { | 
| +class InkDropAnimationTestApi; | 
| +} // namespace test | 
| + | 
| +// An ink drop animation that smoothly animates between a circle and a rounded | 
| +// rectangle of different sizes for each of the different InkDropStates. The | 
| +// final frame for each InkDropState will be bounded by either a |large_size_| | 
| +// rectangle or a |small_size_| rectangle. | 
| 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. | 
| + // The root Layer that can be added in to a Layer tree. | 
| ui::Layer* root_layer() { return root_layer_.get(); } | 
| - // Animates from the current |state_| to |state|. | 
| - void AnimateToState(InkDropState state); | 
| - | 
| - // Sets the size of the ink drop. | 
| - void SetInkDropSize(const gfx::Size& size); | 
| + InkDropState ink_drop_state() const { return ink_drop_state_; } | 
| - // Returns the ink drop bounds. | 
| - gfx::Rect GetInkDropBounds() const; | 
| + // Animates from the current |ink_drop_state_| to a new |ink_drop_state|. It | 
| + // is possible to animate from any |ink_drop_state_| to any new | 
| + // |ink_drop_state|. Note that some state transitions will also perform an | 
| + // implicit transition to the another state. e.g. AnimateToState(QUICK_ACTION) | 
| + // will implicitly transition to the HIDDEN state. | 
| + void AnimateToState(InkDropState ink_drop_state); | 
| - // 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); | 
| + // Sets the |center_point| of the ink drop layer relative to its parent Layer. | 
| + void SetCenterPoint(const gfx::Point& center_point); | 
| private: | 
| - // Starts the animation of a touch event. | 
| - void AnimateTapDown(); | 
| - | 
| - // 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(); | 
| - | 
| - // Starts the animation of a long press, and cancels hiding |ink_drop_layer_| | 
| - // until the long press has completed. | 
| - void AnimateLongPress(); | 
| - | 
| - // Starts the showing animation on |layer|, with a |duration| in milliseconds. | 
| - void AnimateShow(ui::Layer* layer, | 
| - AppearAnimationObserver* observer, | 
| - base::TimeDelta duration); | 
| - | 
| - // Sets the bounds for |layer|. | 
| - void SetLayerBounds(ui::Layer* layer); | 
| - | 
| - // Initializes |layer|'s properties. | 
| - void SetupAnimationLayer(ui::Layer* layer, InkDropDelegate* delegate); | 
| - | 
| - // The root layer that parents the animating layers. | 
| + friend class test::InkDropAnimationTestApi; | 
| + | 
| + // Enumeration of the different shapes that compose the ink drop. | 
| + enum PaintedShape { | 
| + TOP_LEFT_CIRCLE, | 
| 
sadrul
2015/09/14 20:05:40
= 0
 
bruthig
2015/09/15 19:47:09
Done.
 | 
| + TOP_RIGHT_CIRCLE, | 
| + BOTTOM_RIGHT_CIRCLE, | 
| + BOTTOM_LEFT_CIRCLE, | 
| + HORIZONTAL_RECT, | 
| + VERTICAL_RECT, | 
| + // The total number of shapes, not an actual shape. | 
| + PAINTED_SHAPE_COUNT | 
| + }; | 
| + | 
| + // Type that contains a gfx::Tansform for each of the layers required by the | 
| + // ink drop. | 
| + typedef gfx::Transform InkDropTransforms[PAINTED_SHAPE_COUNT]; | 
| + | 
| + // Animates all of the painted shape layers to the specified |transforms| and | 
| + // |opacity|. | 
| + void AnimateToTransforms( | 
| + InkDropTransforms transforms, | 
| 
sadrul
2015/09/14 20:05:40
const
 
bruthig
2015/09/15 19:47:09
Done.
 | 
| + float opacity, | 
| + base::TimeDelta duration, | 
| + ui::LayerAnimator::PreemptionStrategy preemption_strategy); | 
| + | 
| + // Resets the Transforms on all the owned Layers to a minium size. | 
| 
tdanderson
2015/09/10 15:37:51
nit: minium -> minimum
 
bruthig
2015/09/15 19:47:09
Done.
 | 
| + void ResetTransformsToMinSize(); | 
| + | 
| + // Sets the |transforms| on all of the shape layers. Note that this does not | 
| + // perform any animation. | 
| + void SetTransforms(InkDropTransforms transforms); | 
| 
sadrul
2015/09/14 20:05:40
const
 
bruthig
2015/09/15 19:47:09
Done.
 | 
| + | 
| + // Sets the opacity of the ink drop. | 
| + void SetOpacity(float opacity); | 
| + | 
| + // Updates all of the Transforms in |transforms| for a circle of the given | 
| + // |size|. | 
| + void CalculateCircleTransforms(const gfx::SizeF size, | 
| 
sadrul
2015/09/14 20:05:40
const &
 
bruthig
2015/09/15 19:47:09
Done.
 | 
| + InkDropTransforms transforms) const; | 
| 
sadrul
2015/09/14 20:05:40
const
 
bruthig
2015/09/15 19:47:09
|transforms| is an output parameter.
 | 
| + | 
| + // Updates all of the Transforms in |transforms| for a rounded rectangle of | 
| + // the given |size| and |corner_radius|. | 
| + void CalculateRectTransforms(const gfx::SizeF size, | 
| 
sadrul
2015/09/14 20:05:40
const &
 
bruthig
2015/09/15 19:47:09
Done.
 | 
| + float corner_radius, | 
| + InkDropTransforms transforms) const; | 
| 
sadrul
2015/09/14 20:05:41
const
 
bruthig
2015/09/15 19:47:09
|transforms| is an output parameter.
 | 
| + | 
| + // Updates all of the Transforms in |transforms| to the current target | 
| + // Transforms of the Layers. | 
| + void GetCurrentTansforms(InkDropTransforms transforms) const; | 
| 
sadrul
2015/09/14 20:05:40
*Transforms
InkDropTransforms* since out-param.
 
bruthig
2015/09/15 19:47:09
Done.
 | 
| + | 
| + // Adds and configures a new |painted_shape| layer to |painted_layers_|. | 
| + void AddPaintLayer(PaintedShape painted_shape); | 
| + | 
| + // Maximum size that an ink drop will be drawn to for any InkDropState whose | 
| + // final frame should be large. | 
| + gfx::Size large_size_; | 
| + | 
| + // Corner radius used to draw the rounded rectangles corner for any | 
| + // InkDropState whose final frame should be large. | 
| + int large_corner_radius_; | 
| + | 
| + // Maximum size that an ink drop will be drawn to for any InkDropState whose | 
| + // final frame should be small. | 
| + gfx::Size small_size_; | 
| + | 
| + // Corner radius used to draw the rounded rectangles corner for any | 
| + // InkDropState whose final frame should be small. | 
| + 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 location, and its children are used to manipulate | 
| + // the different painted shapes that compose the ink drop. | 
| scoped_ptr<ui::Layer> root_layer_; | 
| - // The layer used for animating a user touch. | 
| - scoped_ptr<ui::Layer> ink_drop_layer_; | 
| - | 
| - // ui::LayerDelegate responsible for painting to |ink_drop_layer_|. | 
| - scoped_ptr<InkDropDelegate> ink_drop_delegate_; | 
| - | 
| - // 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_; | 
| - | 
| - // The layer used for animating a long press. | 
| - scoped_ptr<ui::Layer> long_press_layer_; | 
| - | 
| - // ui::LayerDelegate responsible for painting to |long_press_layer_|. | 
| - scoped_ptr<InkDropDelegate> long_press_delegate_; | 
| - | 
| - // 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> painted_layers_[PAINTED_SHAPE_COUNT]; | 
| - // 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); | 
| }; |