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

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

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

Powered by Google App Engine
This is Rietveld 408576698