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

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

Issue 1286693004: Extracted InkDropAnimator class from InkDropAnimationController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge branch 'master' 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
« no previous file with comments | « no previous file | ui/views/animation/ink_drop_animation.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_IMPL_H_ 5 #ifndef UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_H_
6 #define UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_IMPL_H_ 6 #define UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_H_
7 7
8 #include "base/macros.h"
8 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
9 #include "base/time/time.h" 10 #include "base/time/time.h"
10 #include "ui/events/event_handler.h"
11 #include "ui/gfx/geometry/rect.h" 11 #include "ui/gfx/geometry/rect.h"
12 #include "ui/gfx/geometry/size.h" 12 #include "ui/views/animation/ink_drop_state.h"
13 #include "ui/views/animation/ink_drop_animation_controller.h"
14 #include "ui/views/views_export.h" 13 #include "ui/views/views_export.h"
15 14
16 namespace ui { 15 namespace ui {
17 class Layer; 16 class Layer;
18 } 17 } // namespace ui
19 18
20 namespace views { 19 namespace views {
21 class AppearAnimationObserver; 20 class AppearAnimationObserver;
22 class InkDropDelegate; 21 class InkDropDelegate;
23 class InkDropHost;
24 class View;
25 22
26 // Controls an ink drop animation which is hosted by an InkDropHost. 23 // An ink drop animation that animates between the different InkDropStates.
27 class VIEWS_EXPORT InkDropAnimationControllerImpl 24 class VIEWS_EXPORT InkDropAnimation {
28 : public InkDropAnimationController {
29 public: 25 public:
30 // Constructs an ink drop controller that will attach the ink drop to the 26 InkDropAnimation();
31 // given |ink_drop_host|. 27 ~InkDropAnimation();
32 explicit InkDropAnimationControllerImpl(InkDropHost* ink_drop_host);
33 ~InkDropAnimationControllerImpl() override;
34 28
35 // InkDropAnimationController: 29 // The root that can be added in to a Layer tree.
36 void AnimateToState(InkDropState state) override; 30 ui::Layer* root_layer() { return root_layer_.get(); }
37 void SetInkDropSize(const gfx::Size& size) override; 31
38 gfx::Rect GetInkDropBounds() const override; 32 // Animates from the current |state_| to |state|.
39 void SetInkDropBounds(const gfx::Rect& bounds) override; 33 void AnimateToState(InkDropState state);
34
35 // Sets the size of the ink drop.
36 void SetInkDropSize(const gfx::Size& size);
37
38 // Returns the ink drop bounds.
39 gfx::Rect GetInkDropBounds() const;
40
41 // Sets the bounds for the ink drop. |bounds| are in the coordinate space of
42 // the parent ui::Layer that the ink drop layer is added to.
43 void SetInkDropBounds(const gfx::Rect& bounds);
40 44
41 private: 45 private:
42 // Starts the animation of a touch event. 46 // Starts the animation of a touch event.
43 void AnimateTapDown(); 47 void AnimateTapDown();
44 48
45 // Schedules the hide animation of |ink_drop_layer_| for once its current 49 // Schedules the hide animation of |ink_drop_layer_| for once its current
46 // animation has completed. If |ink_drop_layer_| is not animating, the hide 50 // animation has completed. If |ink_drop_layer_| is not animating, the hide
47 // animation begins immediately. 51 // animation begins immediately.
48 void AnimateHide(); 52 void AnimateHide();
49 53
50 // Starts the animation of a long press, and cancels hiding |ink_drop_layer_| 54 // Starts the animation of a long press, and cancels hiding |ink_drop_layer_|
51 // until the long press has completed. 55 // until the long press has completed.
52 void AnimateLongPress(); 56 void AnimateLongPress();
53 57
54 // Starts the showing animation on |layer|, with a |duration| in milliseconds. 58 // Starts the showing animation on |layer|, with a |duration| in milliseconds.
55 void AnimateShow(ui::Layer* layer, 59 void AnimateShow(ui::Layer* layer,
56 AppearAnimationObserver* observer, 60 AppearAnimationObserver* observer,
57 base::TimeDelta duration); 61 base::TimeDelta duration);
58 62
59 // Sets the bounds for |layer|. 63 // Sets the bounds for |layer|.
60 void SetLayerBounds(ui::Layer* layer); 64 void SetLayerBounds(ui::Layer* layer);
61 65
62 // Initializes |layer|'s properties. 66 // Initializes |layer|'s properties.
63 void SetupAnimationLayer(ui::Layer* layer, InkDropDelegate* delegate); 67 void SetupAnimationLayer(ui::Layer* layer, InkDropDelegate* delegate);
64 68
65 InkDropHost* ink_drop_host_;
66
67 // The root layer that parents the animating layers. 69 // The root layer that parents the animating layers.
68 scoped_ptr<ui::Layer> root_layer_; 70 scoped_ptr<ui::Layer> root_layer_;
69 71
70 // The layer used for animating a user touch. 72 // The layer used for animating a user touch.
71 scoped_ptr<ui::Layer> ink_drop_layer_; 73 scoped_ptr<ui::Layer> ink_drop_layer_;
72 74
73 // ui::LayerDelegate responsible for painting to |ink_drop_layer_|. 75 // ui::LayerDelegate responsible for painting to |ink_drop_layer_|.
74 scoped_ptr<InkDropDelegate> ink_drop_delegate_; 76 scoped_ptr<InkDropDelegate> ink_drop_delegate_;
75 77
76 // ui::ImplicitAnimationObserver which observes |ink_drop_layer_| and can be 78 // ui::ImplicitAnimationObserver which observes |ink_drop_layer_| and can be
77 // used to automatically trigger a hide animation upon completion. 79 // used to automatically trigger a hide animation upon completion.
78 scoped_ptr<AppearAnimationObserver> appear_animation_observer_; 80 scoped_ptr<AppearAnimationObserver> appear_animation_observer_;
79 81
80 // The layer used for animating a long press. 82 // The layer used for animating a long press.
81 scoped_ptr<ui::Layer> long_press_layer_; 83 scoped_ptr<ui::Layer> long_press_layer_;
82 84
83 // ui::LayerDelegate responsible for painting to |long_press_layer_|. 85 // ui::LayerDelegate responsible for painting to |long_press_layer_|.
84 scoped_ptr<InkDropDelegate> long_press_delegate_; 86 scoped_ptr<InkDropDelegate> long_press_delegate_;
85 87
86 // ui::ImplicitAnimationObserver which observers |long_press_layer_| and can 88 // ui::ImplicitAnimationObserver which observers |long_press_layer_| and can
87 // be used to automatically trigger a hide animation upon completion. 89 // be used to automatically trigger a hide animation upon completion.
88 scoped_ptr<AppearAnimationObserver> long_press_animation_observer_; 90 scoped_ptr<AppearAnimationObserver> long_press_animation_observer_;
89 91
90 // The bounds of the ink drop layers. Defined in the coordinate space of the 92 // The bounds of the ink drop layers. Defined in the coordinate space of the
91 // parent ui::Layer that the ink drop layers were added to. 93 // parent ui::Layer that the ink drop layers were added to.
92 gfx::Rect ink_drop_bounds_; 94 gfx::Rect ink_drop_bounds_;
93 95
94 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerImpl); 96 DISALLOW_COPY_AND_ASSIGN(InkDropAnimation);
95 }; 97 };
96 98
97 } // namespace views 99 } // namespace views
98 100
99 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_IMPL_H_ 101 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_H_
OLDNEW
« no previous file with comments | « no previous file | ui/views/animation/ink_drop_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698