Chromium Code Reviews| Index: ui/views/animation/ink_drop_animation_controller_impl.h |
| diff --git a/ui/views/animation/ink_drop_animation_controller.h b/ui/views/animation/ink_drop_animation_controller_impl.h |
| similarity index 51% |
| copy from ui/views/animation/ink_drop_animation_controller.h |
| copy to ui/views/animation/ink_drop_animation_controller_impl.h |
| index 8fb9162f81205ae52e0e56281cbf92d76b454503..6a0539e3ea56858ab7000376dfe6c41285a2f1af 100644 |
| --- a/ui/views/animation/ink_drop_animation_controller.h |
| +++ b/ui/views/animation/ink_drop_animation_controller_impl.h |
| @@ -2,12 +2,16 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_H_ |
| -#define UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_H_ |
| +#ifndef UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_IMPL_H_ |
| +#define UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_IMPL_H_ |
| #include "base/memory/scoped_ptr.h" |
| #include "base/time/time.h" |
| +#include "ui/compositor/layer_owner.h" |
| #include "ui/events/event_handler.h" |
| +#include "ui/gfx/geometry/rect.h" |
| +#include "ui/gfx/geometry/size.h" |
| +#include "ui/views/animation/ink_drop_animation_controller.h" |
| #include "ui/views/views_export.h" |
| namespace ui { |
| @@ -17,18 +21,23 @@ class Layer; |
| namespace views { |
| class AppearAnimationObserver; |
| class InkDropDelegate; |
| +class InkDropHost; |
| class View; |
| -// Controls an animation which can be associated to a ui::Layer backed View. |
| -// It sets itself as the pre-target handler for the supplied view, providing |
| -// animations for user interactions. The events will not be consumed. |
| -// |
| -// The supplied views::View will be forced to have a layer, and this controller |
| -// will add child layers to that. |
| -class VIEWS_EXPORT InkDropAnimationController : public ui::EventHandler { |
| +// Controls an ink drop animation which is hosted by an InkDropHost. |
| +class VIEWS_EXPORT InkDropAnimationControllerImpl |
| + : public InkDropAnimationController { |
| public: |
| - explicit InkDropAnimationController(View* view); |
| - ~InkDropAnimationController() override; |
| + // Constructs an ink drop controller that will attach the ink drop to the |
| + // given |ink_drop_host|. |
| + explicit InkDropAnimationControllerImpl(InkDropHost* ink_drop_host); |
| + ~InkDropAnimationControllerImpl() override; |
| + |
| + // InkDropAnimationController: |
| + void AnimateToState(InkDropState state) override; |
| + void SetInkDropSize(const gfx::Size& size) override; |
| + gfx::Rect GetInkDropBounds() const override; |
| + void SetInkDropBounds(const gfx::Rect& bounds) override; |
| private: |
| // Starts the animation of a touch event. |
| @@ -46,23 +55,21 @@ class VIEWS_EXPORT InkDropAnimationController : public ui::EventHandler { |
| // Starts the showing animation on |layer|, with a |duration| in milliseconds. |
| void AnimateShow(ui::Layer* layer, |
| AppearAnimationObserver* observer, |
| - bool circle, |
| base::TimeDelta duration); |
| // Sets the bounds for |layer|. |
| - void SetLayerBounds(ui::Layer* layer, bool circle, int width, int height); |
| + void SetLayerBounds(ui::Layer* layer); |
| + |
| + // Initializes |layer|'s properties. |
| + void SetupAnimationLayer(ui::Layer* layer, InkDropDelegate* delegate); |
| - // Initializes |layer| and attaches it to |parent|. |
| - void SetupAnimationLayer(ui::Layer* parent, |
| - ui::Layer* layer, |
| - InkDropDelegate* delegate); |
| + InkDropHost* ink_drop_host_; |
| - // ui::EventHandler: |
| - void OnGestureEvent(ui::GestureEvent* event) override; |
| + // Owner of the root layer that parents the animating layers. |
| + ui::LayerOwner root_layer_owner_; |
| - // The layer for animating a user touch. Added as a child to |view_|'s layer. |
| - // It will be stacked underneath. |
| - scoped_ptr<ui::Layer> ink_drop_layer_; |
| + // Owner of the layer used for animating a user touch. |
| + ui::LayerOwner ink_drop_layer_owner_; |
| // ui::LayerDelegate responsible for painting to |ink_drop_layer_|. |
| scoped_ptr<InkDropDelegate> ink_drop_delegate_; |
| @@ -71,9 +78,8 @@ class VIEWS_EXPORT InkDropAnimationController : public ui::EventHandler { |
| // used to automatically trigger a hide animation upon completion. |
| scoped_ptr<AppearAnimationObserver> appear_animation_observer_; |
| - // The layer for animating a long press. Added as a child to |view_|'s layer. |
| - // It will be stacked underneath. |
| - scoped_ptr<ui::Layer> long_press_layer_; |
| + // Owner of the layer used for animating a long press. |
| + ui::LayerOwner long_press_layer_owner_; |
|
sadrul
2015/08/18 17:51:49
Is there a reason to not use scoped_ptr<Layer> for
bruthig
2015/08/18 19:04:38
Yes, ScreenRotationAnimator creates a copy of all
sadrul
2015/08/18 19:52:38
That sounds odd (and a buggy behaviour; ScreenRota
bruthig
2015/08/18 20:58:04
Hmm, you are right, I was mistaken. I've changed
|
| // ui::LayerDelegate responsible for painting to |long_press_layer_|. |
| scoped_ptr<InkDropDelegate> long_press_delegate_; |
| @@ -82,12 +88,13 @@ class VIEWS_EXPORT InkDropAnimationController : public ui::EventHandler { |
| // be used to automatically trigger a hide animation upon completion. |
| scoped_ptr<AppearAnimationObserver> long_press_animation_observer_; |
| - // The View for which InkDropAnimationController is a PreTargetHandler. |
| - View* view_; |
| + // 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_; |
| - DISALLOW_COPY_AND_ASSIGN(InkDropAnimationController); |
| + DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerImpl); |
| }; |
| } // namespace views |
| -#endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_H_ |
| +#endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_IMPL_H_ |