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

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

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

Powered by Google App Engine
This is Rietveld 408576698