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

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

Issue 1937103003: Rename of InkDropAnimation classes to InkDropRipple. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed test_ink_drop_animation_observer.h from views.gyp and doc update. Created 4 years, 7 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_IMPL_H_ 5 #ifndef UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_IMPL_H_
6 #define UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_IMPL_H_ 6 #define UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_IMPL_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.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/gfx/geometry/size.h"
13 #include "ui/views/animation/ink_drop_animation_controller.h" 13 #include "ui/views/animation/ink_drop_animation_controller.h"
14 #include "ui/views/animation/ink_drop_animation_observer.h"
15 #include "ui/views/animation/ink_drop_hover_observer.h" 14 #include "ui/views/animation/ink_drop_hover_observer.h"
15 #include "ui/views/animation/ink_drop_ripple_observer.h"
16 #include "ui/views/views_export.h" 16 #include "ui/views/views_export.h"
17 17
18 namespace base { 18 namespace base {
19 class Timer; 19 class Timer;
20 } // namespace base 20 } // namespace base
21 21
22 namespace views { 22 namespace views {
23 namespace test { 23 namespace test {
24 class InkDropAnimationControllerImplTestApi; 24 class InkDropAnimationControllerImplTestApi;
25 } // namespace test 25 } // namespace test
26 26
27 class InkDropAnimation; 27 class InkDropRipple;
28 class InkDropHost; 28 class InkDropHost;
29 class InkDropHover; 29 class InkDropHover;
30 class InkDropAnimationControllerFactoryTest; 30 class InkDropAnimationControllerFactoryTest;
31 31
32 // A functional implementation of an InkDropAnimationController. 32 // A functional implementation of an InkDropAnimationController.
33 class VIEWS_EXPORT InkDropAnimationControllerImpl 33 class VIEWS_EXPORT InkDropAnimationControllerImpl
34 : public InkDropAnimationController, 34 : public InkDropAnimationController,
35 public InkDropAnimationObserver, 35 public InkDropRippleObserver,
36 public InkDropHoverObserver { 36 public InkDropHoverObserver {
37 public: 37 public:
38 // Constructs an ink drop controller that will attach the ink drop to the 38 // Constructs an ink drop controller that will attach the ink drop to the
39 // given |ink_drop_host|. 39 // given |ink_drop_host|.
40 explicit InkDropAnimationControllerImpl(InkDropHost* ink_drop_host); 40 explicit InkDropAnimationControllerImpl(InkDropHost* ink_drop_host);
41 ~InkDropAnimationControllerImpl() override; 41 ~InkDropAnimationControllerImpl() override;
42 42
43 // InkDropAnimationController: 43 // InkDropAnimationController:
44 InkDropState GetTargetInkDropState() const override; 44 InkDropState GetTargetInkDropState() const override;
45 bool IsVisible() const override; 45 bool IsVisible() const override;
46 void AnimateToState(InkDropState ink_drop_state) override; 46 void AnimateToState(InkDropState ink_drop_state) override;
47 void SnapToActivated() override; 47 void SnapToActivated() override;
48 void SetHovered(bool is_hovered) override; 48 void SetHovered(bool is_hovered) override;
49 49
50 private: 50 private:
51 friend class test::InkDropAnimationControllerImplTestApi; 51 friend class test::InkDropAnimationControllerImplTestApi;
52 52
53 // Destroys |ink_drop_animation_| if it's targeted to the HIDDEN state. 53 // Destroys |ink_drop_ripple_| if it's targeted to the HIDDEN state.
54 void DestroyHiddenTargetedAnimations(); 54 void DestroyHiddenTargetedAnimations();
55 55
56 // Creates a new InkDropAnimation and sets it to |ink_drop_animation_|. If 56 // Creates a new InkDropRipple and sets it to |ink_drop_ripple_|. If
57 // |ink_drop_animation_| wasn't null then it will be destroyed using 57 // |ink_drop_ripple_| wasn't null then it will be destroyed using
58 // DestroyInkDropAnimation(). 58 // DestroyInkDropRipple().
59 void CreateInkDropAnimation(); 59 void CreateInkDropRipple();
60 60
61 // Destroys the current |ink_drop_animation_|. 61 // Destroys the current |ink_drop_ripple_|.
62 void DestroyInkDropAnimation(); 62 void DestroyInkDropRipple();
63 63
64 // Creates a new InkDropHover and sets it to |hover_|. If |hover_| wasn't null 64 // Creates a new InkDropHover and sets it to |hover_|. If |hover_| wasn't null
65 // then it will be destroyed using DestroyInkDropHover(). 65 // then it will be destroyed using DestroyInkDropHover().
66 void CreateInkDropHover(); 66 void CreateInkDropHover();
67 67
68 // Destroys the current |hover_|. 68 // Destroys the current |hover_|.
69 void DestroyInkDropHover(); 69 void DestroyInkDropHover();
70 70
71 // Adds the |root_layer_| to the |ink_drop_host_| if it hasn't already been 71 // Adds the |root_layer_| to the |ink_drop_host_| if it hasn't already been
72 // added. 72 // added.
73 void AddRootLayerToHostIfNeeded(); 73 void AddRootLayerToHostIfNeeded();
74 74
75 // Removes the |root_layer_| from the |ink_drop_host_| if no ink drop ripple 75 // Removes the |root_layer_| from the |ink_drop_host_| if no ink drop ripple
76 // or hover is active. 76 // or hover is active.
77 void RemoveRootLayerFromHostIfNeeded(); 77 void RemoveRootLayerFromHostIfNeeded();
78 78
79 // Returns true if the hover animation is in the process of fading in or 79 // Returns true if the hover animation is in the process of fading in or
80 // is visible. 80 // is visible.
81 bool IsHoverFadingInOrVisible() const; 81 bool IsHoverFadingInOrVisible() const;
82 82
83 // views::InkDropAnimationObserver: 83 // views::InkDropRippleObserver:
84 void AnimationStarted(InkDropState ink_drop_state) override; 84 void AnimationStarted(InkDropState ink_drop_state) override;
85 void AnimationEnded(InkDropState ink_drop_state, 85 void AnimationEnded(InkDropState ink_drop_state,
86 InkDropAnimationEndedReason reason) override; 86 InkDropAnimationEndedReason reason) override;
87 87
88 // views::InkDropHoverObserver: 88 // views::InkDropHoverObserver:
89 void AnimationStarted(InkDropHover::AnimationType animation_type) override; 89 void AnimationStarted(InkDropHover::AnimationType animation_type) override;
90 void AnimationEnded(InkDropHover::AnimationType animation_type, 90 void AnimationEnded(InkDropHover::AnimationType animation_type,
91 InkDropAnimationEndedReason reason) override; 91 InkDropAnimationEndedReason reason) override;
92 92
93 // Enables or disables the hover state based on |is_hovered| and if an 93 // Enables or disables the hover state based on |is_hovered| and if an
94 // animation is triggered it will be scheduled to have the given 94 // animation is triggered it will be scheduled to have the given
95 // |animation_duration|. If |explode| is true the hover will expand as it 95 // |animation_duration|. If |explode| is true the hover will expand as it
96 // fades out. |explode| is ignored when |is_hovered| is true. 96 // fades out. |explode| is ignored when |is_hovered| is true.
97 void SetHoveredInternal(bool is_hovered, 97 void SetHoveredInternal(bool is_hovered,
98 base::TimeDelta animation_duration, 98 base::TimeDelta animation_duration,
99 bool explode); 99 bool explode);
100 100
101 // Starts the |hover_after_animation_timer_| timer. This will stop the current 101 // Starts the |hover_after_ripple_timer_| timer. This will stop the current
102 // |hover_after_animation_timer_| instance if it exists. 102 // |hover_after_ripple_timer_| instance if it exists.
103 void StartHoverAfterAnimationTimer(); 103 void StartHoverAfterRippleTimer();
104 104
105 // Stops and destroys the current |hover_after_animation_timer_| instance. 105 // Stops and destroys the current |hover_after_ripple_timer_| instance.
106 void StopHoverAfterAnimationTimer(); 106 void StopHoverAfterRippleTimer();
107 107
108 // Callback for when the |hover_after_animation_timer_| fires. 108 // Callback for when the |hover_after_ripple_timer_| fires.
109 void HoverAfterAnimationTimerFired(); 109 void HoverAfterRippleTimerFired();
110 110
111 // The host of the ink drop. Used to poll for information such as whether the 111 // The host of the ink drop. Used to poll for information such as whether the
112 // hover should be shown or not. 112 // hover should be shown or not.
113 InkDropHost* ink_drop_host_; 113 InkDropHost* ink_drop_host_;
114 114
115 // The root Layer that parents the InkDropAnimation layers and the 115 // The root Layer that parents the InkDropRipple layers and the InkDropHover
116 // InkDropHover layers. The |root_layer_| is the one that is added and removed 116 // layers. The |root_layer_| is the one that is added and removed from the
117 // from the InkDropHost. 117 // InkDropHost.
118 std::unique_ptr<ui::Layer> root_layer_; 118 std::unique_ptr<ui::Layer> root_layer_;
119 119
120 // True when the |root_layer_| has been added to the |ink_drop_host_|. 120 // True when the |root_layer_| has been added to the |ink_drop_host_|.
121 bool root_layer_added_to_host_; 121 bool root_layer_added_to_host_;
122 122
123 // The current InkDropHover. Lazily created using CreateInkDropHover(); 123 // The current InkDropHover. Lazily created using CreateInkDropHover();
124 std::unique_ptr<InkDropHover> hover_; 124 std::unique_ptr<InkDropHover> hover_;
125 125
126 // Tracks the logical hovered state of |this| as manipulated by the public 126 // Tracks the logical hovered state of |this| as manipulated by the public
127 // SetHovered() function. 127 // SetHovered() function.
128 bool is_hovered_; 128 bool is_hovered_;
129 129
130 // The current InkDropAnimation. Created on demand using 130 // The current InkDropRipple. Created on demand using CreateInkDropRipple().
131 // CreateInkDropAnimation(). 131 std::unique_ptr<InkDropRipple> ink_drop_ripple_;
132 std::unique_ptr<InkDropAnimation> ink_drop_animation_;
133 132
134 // The timer used to delay the hover fade in after an ink drop animation. 133 // The timer used to delay the hover fade in after an ink drop ripple
135 std::unique_ptr<base::Timer> hover_after_animation_timer_; 134 // animation.
135 std::unique_ptr<base::Timer> hover_after_ripple_timer_;
136 136
137 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerImpl); 137 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerImpl);
138 }; 138 };
139 139
140 } // namespace views 140 } // namespace views
141 141
142 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_IMPL_H_ 142 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_IMPL_H_
OLDNEW
« no previous file with comments | « ui/views/animation/ink_drop_animation_controller.h ('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