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

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

Issue 1897073002: Add MD Ink Drop Layers to InkDropHost only when a ripple/hover is active. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed InkDropHoverTests to use proper expectation comparisons. 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" 14 #include "ui/views/animation/ink_drop_animation_observer.h"
15 #include "ui/views/animation/ink_drop_hover_observer.h"
15 #include "ui/views/views_export.h" 16 #include "ui/views/views_export.h"
16 17
17 namespace base { 18 namespace base {
18 class Timer; 19 class Timer;
19 } // namespace base 20 } // namespace base
20 21
21 namespace views { 22 namespace views {
22 namespace test { 23 namespace test {
23 class InkDropAnimationControllerImplTestApi; 24 class InkDropAnimationControllerImplTestApi;
24 } // namespace test 25 } // namespace test
25 26
26 class InkDropAnimation; 27 class InkDropAnimation;
27 class InkDropHost; 28 class InkDropHost;
28 class InkDropHover; 29 class InkDropHover;
29 class InkDropAnimationControllerFactoryTest; 30 class InkDropAnimationControllerFactoryTest;
30 31
31 // A functional implementation of an InkDropAnimationController. 32 // A functional implementation of an InkDropAnimationController.
32 class VIEWS_EXPORT InkDropAnimationControllerImpl 33 class VIEWS_EXPORT InkDropAnimationControllerImpl
33 : public InkDropAnimationController, 34 : public InkDropAnimationController,
34 public InkDropAnimationObserver { 35 public InkDropAnimationObserver,
36 public InkDropHoverObserver {
35 public: 37 public:
36 // 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
37 // given |ink_drop_host|. 39 // given |ink_drop_host|.
38 explicit InkDropAnimationControllerImpl(InkDropHost* ink_drop_host); 40 explicit InkDropAnimationControllerImpl(InkDropHost* ink_drop_host);
39 ~InkDropAnimationControllerImpl() override; 41 ~InkDropAnimationControllerImpl() override;
40 42
41 // InkDropAnimationController: 43 // InkDropAnimationController:
42 InkDropState GetTargetInkDropState() const override; 44 InkDropState GetTargetInkDropState() const override;
43 bool IsVisible() const override; 45 bool IsVisible() const override;
44 void AnimateToState(InkDropState ink_drop_state) override; 46 void AnimateToState(InkDropState ink_drop_state) override;
(...skipping 14 matching lines...) Expand all
59 // Destroys the current |ink_drop_animation_|. 61 // Destroys the current |ink_drop_animation_|.
60 void DestroyInkDropAnimation(); 62 void DestroyInkDropAnimation();
61 63
62 // 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
63 // then it will be destroyed using DestroyInkDropHover(). 65 // then it will be destroyed using DestroyInkDropHover().
64 void CreateInkDropHover(); 66 void CreateInkDropHover();
65 67
66 // Destroys the current |hover_|. 68 // Destroys the current |hover_|.
67 void DestroyInkDropHover(); 69 void DestroyInkDropHover();
68 70
71 // Adds the |root_layer_| to the |ink_drop_host_| if it hasn't already been
72 // added.
73 void AddRootLayerToHostIfNeeded();
74
75 // Removes the |root_layer_| from the |ink_drop_host_| if no ink drop ripple
76 // or hover is active.
77 void RemoveRootLayerFromHostIfNeeded();
78
69 // 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
70 // is visible. 80 // is visible.
71 bool IsHoverFadingInOrVisible() const; 81 bool IsHoverFadingInOrVisible() const;
72 82
73 // views::InkDropAnimationObserver: 83 // views::InkDropAnimationObserver:
74 void AnimationStarted(InkDropState ink_drop_state) override; 84 void AnimationStarted(InkDropState ink_drop_state) override;
75 void AnimationEnded(InkDropState ink_drop_state, 85 void AnimationEnded(InkDropState ink_drop_state,
76 InkDropAnimationEndedReason reason) override; 86 InkDropAnimationEndedReason reason) override;
77 87
88 // views::InkDropHoverObserver:
89 void AnimationStarted(InkDropHover::AnimationType animation_type) override;
90 void AnimationEnded(InkDropHover::AnimationType animation_type,
91 InkDropAnimationEndedReason reason) override;
92
78 // 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
79 // animation is triggered it will be scheduled to have the given 94 // animation is triggered it will be scheduled to have the given
80 // |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
81 // fades out. |explode| is ignored when |is_hovered| is true. 96 // fades out. |explode| is ignored when |is_hovered| is true.
82 void SetHoveredInternal(bool is_hovered, 97 void SetHoveredInternal(bool is_hovered,
83 base::TimeDelta animation_duration, 98 base::TimeDelta animation_duration,
84 bool explode); 99 bool explode);
85 100
86 // Starts the |hover_after_animation_timer_| timer. This will stop the current 101 // Starts the |hover_after_animation_timer_| timer. This will stop the current
87 // |hover_after_animation_timer_| instance if it exists. 102 // |hover_after_animation_timer_| instance if it exists.
88 void StartHoverAfterAnimationTimer(); 103 void StartHoverAfterAnimationTimer();
89 104
90 // Stops and destroys the current |hover_after_animation_timer_| instance. 105 // Stops and destroys the current |hover_after_animation_timer_| instance.
91 void StopHoverAfterAnimationTimer(); 106 void StopHoverAfterAnimationTimer();
92 107
93 // Callback for when the |hover_after_animation_timer_| fires. 108 // Callback for when the |hover_after_animation_timer_| fires.
94 void HoverAfterAnimationTimerFired(); 109 void HoverAfterAnimationTimerFired();
95 110
96 // 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
97 // hover should be shown or not. 112 // hover should be shown or not.
98 InkDropHost* ink_drop_host_; 113 InkDropHost* ink_drop_host_;
99 114
100 // The root Layer that parents the InkDropAnimation layers and the 115 // The root Layer that parents the InkDropAnimation layers and the
101 // InkDropHover layers. The |root_layer_| is the one that is added and removed 116 // InkDropHover layers. The |root_layer_| is the one that is added and removed
102 // from the InkDropHost. 117 // from the InkDropHost.
103 std::unique_ptr<ui::Layer> root_layer_; 118 std::unique_ptr<ui::Layer> root_layer_;
104 119
120 // True when the |root_layer_| has been added to the |ink_drop_host_|.
121 bool root_layer_added_to_host_;
122
105 // The current InkDropHover. Lazily created using CreateInkDropHover(); 123 // The current InkDropHover. Lazily created using CreateInkDropHover();
106 std::unique_ptr<InkDropHover> hover_; 124 std::unique_ptr<InkDropHover> hover_;
107 125
108 // 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
109 // SetHovered() function. 127 // SetHovered() function.
110 bool is_hovered_; 128 bool is_hovered_;
111 129
112 // The current InkDropAnimation. Created on demand using 130 // The current InkDropAnimation. Created on demand using
113 // CreateInkDropAnimation(). 131 // CreateInkDropAnimation().
114 std::unique_ptr<InkDropAnimation> ink_drop_animation_; 132 std::unique_ptr<InkDropAnimation> ink_drop_animation_;
115 133
116 // The timer used to delay the hover fade in after an ink drop animation. 134 // The timer used to delay the hover fade in after an ink drop animation.
117 std::unique_ptr<base::Timer> hover_after_animation_timer_; 135 std::unique_ptr<base::Timer> hover_after_animation_timer_;
118 136
119 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerImpl); 137 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerImpl);
120 }; 138 };
121 139
122 } // namespace views 140 } // namespace views
123 141
124 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_IMPL_H_ 142 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698