| Index: ui/views/animation/ink_drop_animation_controller.h
|
| diff --git a/ui/views/animation/ink_drop_animation_controller.h b/ui/views/animation/ink_drop_animation_controller.h
|
| index 8fb9162f81205ae52e0e56281cbf92d76b454503..b2f3a4adb53c784f169180da5d72b262b9eb8c74 100644
|
| --- a/ui/views/animation/ink_drop_animation_controller.h
|
| +++ b/ui/views/animation/ink_drop_animation_controller.h
|
| @@ -7,7 +7,10 @@
|
|
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/time/time.h"
|
| +#include "ui/compositor/layer_tree_owner.h"
|
| #include "ui/events/event_handler.h"
|
| +#include "ui/gfx/geometry/rect.h"
|
| +#include "ui/gfx/geometry/size.h"
|
| #include "ui/views/views_export.h"
|
|
|
| namespace ui {
|
| @@ -17,18 +20,46 @@ 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 {
|
| +// The different states that the ink drop animation can be animated to.
|
| +enum class InkDropState {
|
| + // The ink drop is not visible.
|
| + HIDDEN,
|
| + // The view is being interacted with but the action to be triggered has not
|
| + // yet been determined.
|
| + ACTION_PENDING,
|
| + // The quick action for the view has been triggered. e.g. A tap gesture to
|
| + // click a button.
|
| + QUICK_ACTION,
|
| + // The slow action for the view has been triggered. e.g. A long press to bring
|
| + // up a menu.
|
| + SLOW_ACTION,
|
| + // An active state for a view that is no longer being interacted with. e.g. A
|
| + // pressed button that is showing a menu.
|
| + ACTIVATED
|
| +};
|
| +
|
| +// Controls an ink drop animation which is hosted by an InkDropHost.
|
| +class VIEWS_EXPORT 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 InkDropAnimationController(InkDropHost* ink_drop_host);
|
| + virtual ~InkDropAnimationController();
|
| +
|
| + // Animates from the current InkDropState to |state|.
|
| + void AnimateToState(InkDropState state);
|
| +
|
| + // Set the size of the ink drop.
|
| + void SetSize(const gfx::Size& size);
|
| +
|
| + gfx::Rect bounds() const { return bounds_; }
|
| +
|
| + // 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 SetBounds(const gfx::Rect& bounds);
|
|
|
| private:
|
| // Starts the animation of a touch event.
|
| @@ -46,23 +77,22 @@ 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;
|
| + // Owns the ink drop layer tree.
|
| + ui::LayerTreeOwner layer_tree_;
|
|
|
| - // 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_;
|
| + // The layer for animating a user touch. It will be stacked behind
|
| + // |long_press_layer_| in the |layer_tree_|.
|
| + ui::Layer* ink_drop_layer_;
|
|
|
| // ui::LayerDelegate responsible for painting to |ink_drop_layer_|.
|
| scoped_ptr<InkDropDelegate> ink_drop_delegate_;
|
| @@ -71,9 +101,9 @@ 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_;
|
| + // The layer for animating a long press. It will be stacked in front of the
|
| + // |ink_drop_layer_| in the |layer_tree_|.
|
| + ui::Layer* long_press_layer_;
|
|
|
| // ui::LayerDelegate responsible for painting to |long_press_layer_|.
|
| scoped_ptr<InkDropDelegate> long_press_delegate_;
|
| @@ -82,8 +112,9 @@ 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 bounds_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(InkDropAnimationController);
|
| };
|
|
|