Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: ui/views/animation/ink_drop_animation_controller_impl.h

Issue 1280953003: Enhance the material design ripple API so the ripple's state can be controlled by it's owning View. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed minor typo. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_INK_DROP_ANIMATION_CONTROLLER_H_ 5 #ifndef UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_IMPL_H_
6 #define UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_H_ 6 #define UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_IMPL_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "ui/events/event_handler.h" 10 #include "ui/events/event_handler.h"
11 #include "ui/gfx/geometry/rect.h"
12 #include "ui/gfx/geometry/size.h"
13 #include "ui/views/animation/ink_drop_animation_controller.h"
11 #include "ui/views/views_export.h" 14 #include "ui/views/views_export.h"
12 15
13 namespace ui { 16 namespace ui {
14 class Layer; 17 class Layer;
15 } 18 }
16 19
17 namespace views { 20 namespace views {
18 class AppearAnimationObserver; 21 class AppearAnimationObserver;
19 class InkDropDelegate; 22 class InkDropDelegate;
23 class InkDropHost;
20 class View; 24 class View;
21 25
22 // Controls an animation which can be associated to a ui::Layer backed View. 26 // Controls an ink drop animation which is hosted by an InkDropHost.
23 // It sets itself as the pre-target handler for the supplied view, providing 27 class VIEWS_EXPORT InkDropAnimationControllerImpl
24 // animations for user interactions. The events will not be consumed. 28 : public InkDropAnimationController {
25 //
26 // The supplied views::View will be forced to have a layer, and this controller
27 // will add child layers to that.
28 class VIEWS_EXPORT InkDropAnimationController : public ui::EventHandler {
29 public: 29 public:
30 explicit InkDropAnimationController(View* view); 30 // Constructs an ink drop controller that will attach the ink drop to the
31 ~InkDropAnimationController() override; 31 // given |ink_drop_host|.
32 explicit InkDropAnimationControllerImpl(InkDropHost* ink_drop_host);
33 ~InkDropAnimationControllerImpl() override;
34
35 // InkDropAnimationController:
36 void AnimateToState(InkDropState state) override;
37 void SetInkDropSize(const gfx::Size& size) override;
38 gfx::Rect GetInkDropBounds() const override;
39 void SetInkDropBounds(const gfx::Rect& bounds) override;
32 40
33 private: 41 private:
34 // Starts the animation of a touch event. 42 // Starts the animation of a touch event.
35 void AnimateTapDown(); 43 void AnimateTapDown();
36 44
37 // Schedules the hide animation of |ink_drop_layer_| for once its current 45 // Schedules the hide animation of |ink_drop_layer_| for once its current
38 // animation has completed. If |ink_drop_layer_| is not animating, the hide 46 // animation has completed. If |ink_drop_layer_| is not animating, the hide
39 // animation begins immediately. 47 // animation begins immediately.
40 void AnimateHide(); 48 void AnimateHide();
41 49
42 // Starts the animation of a long press, and cancels hiding |ink_drop_layer_| 50 // Starts the animation of a long press, and cancels hiding |ink_drop_layer_|
43 // until the long press has completed. 51 // until the long press has completed.
44 void AnimateLongPress(); 52 void AnimateLongPress();
45 53
46 // Starts the showing animation on |layer|, with a |duration| in milliseconds. 54 // Starts the showing animation on |layer|, with a |duration| in milliseconds.
47 void AnimateShow(ui::Layer* layer, 55 void AnimateShow(ui::Layer* layer,
48 AppearAnimationObserver* observer, 56 AppearAnimationObserver* observer,
49 bool circle,
50 base::TimeDelta duration); 57 base::TimeDelta duration);
51 58
52 // Sets the bounds for |layer|. 59 // Sets the bounds for |layer|.
53 void SetLayerBounds(ui::Layer* layer, bool circle, int width, int height); 60 void SetLayerBounds(ui::Layer* layer);
54 61
55 // Initializes |layer| and attaches it to |parent|. 62 // Initializes |layer|'s properties.
56 void SetupAnimationLayer(ui::Layer* parent, 63 void SetupAnimationLayer(ui::Layer* layer, InkDropDelegate* delegate);
57 ui::Layer* layer,
58 InkDropDelegate* delegate);
59 64
60 // ui::EventHandler: 65 InkDropHost* ink_drop_host_;
61 void OnGestureEvent(ui::GestureEvent* event) override;
62 66
63 // The layer for animating a user touch. Added as a child to |view_|'s layer. 67 // The root layer that parents the animating layers.
64 // It will be stacked underneath. 68 scoped_ptr<ui::Layer> root_layer_;
69
70 // The layer used for animating a user touch.
65 scoped_ptr<ui::Layer> ink_drop_layer_; 71 scoped_ptr<ui::Layer> ink_drop_layer_;
66 72
67 // ui::LayerDelegate responsible for painting to |ink_drop_layer_|. 73 // ui::LayerDelegate responsible for painting to |ink_drop_layer_|.
68 scoped_ptr<InkDropDelegate> ink_drop_delegate_; 74 scoped_ptr<InkDropDelegate> ink_drop_delegate_;
69 75
70 // ui::ImplicitAnimationObserver which observes |ink_drop_layer_| and can be 76 // ui::ImplicitAnimationObserver which observes |ink_drop_layer_| and can be
71 // used to automatically trigger a hide animation upon completion. 77 // used to automatically trigger a hide animation upon completion.
72 scoped_ptr<AppearAnimationObserver> appear_animation_observer_; 78 scoped_ptr<AppearAnimationObserver> appear_animation_observer_;
73 79
74 // The layer for animating a long press. Added as a child to |view_|'s layer. 80 // The layer used for animating a long press.
75 // It will be stacked underneath.
76 scoped_ptr<ui::Layer> long_press_layer_; 81 scoped_ptr<ui::Layer> long_press_layer_;
77 82
78 // ui::LayerDelegate responsible for painting to |long_press_layer_|. 83 // ui::LayerDelegate responsible for painting to |long_press_layer_|.
79 scoped_ptr<InkDropDelegate> long_press_delegate_; 84 scoped_ptr<InkDropDelegate> long_press_delegate_;
80 85
81 // ui::ImplicitAnimationObserver which observers |long_press_layer_| and can 86 // ui::ImplicitAnimationObserver which observers |long_press_layer_| and can
82 // be used to automatically trigger a hide animation upon completion. 87 // be used to automatically trigger a hide animation upon completion.
83 scoped_ptr<AppearAnimationObserver> long_press_animation_observer_; 88 scoped_ptr<AppearAnimationObserver> long_press_animation_observer_;
84 89
85 // The View for which InkDropAnimationController is a PreTargetHandler. 90 // The bounds of the ink drop layers. Defined in the coordinate space of the
86 View* view_; 91 // parent ui::Layer that the ink drop layers were added to.
92 gfx::Rect ink_drop_bounds_;
87 93
88 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationController); 94 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerImpl);
89 }; 95 };
90 96
91 } // namespace views 97 } // namespace views
92 98
93 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_H_ 99 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_IMPL_H_
OLDNEW
« no previous file with comments | « ui/views/animation/ink_drop_animation_controller_factory.cc ('k') | ui/views/animation/ink_drop_animation_controller_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698