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 1390113006: Added material design mouse hover feedback support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved MouseEntered/Exit() to hover handling in to the ButtonInkDropDelegate. Created 4 years, 11 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/views_export.h" 14 #include "ui/views/views_export.h"
15 15
16 namespace base {
17 class Timer;
18 } // namespace base
19
16 namespace views { 20 namespace views {
17 class InkDropAnimation; 21 class InkDropAnimation;
18 class InkDropHost; 22 class InkDropHost;
23 class InkDropHover;
24 class InkDropAnimationControllerFactoryTest;
19 25
20 // A functional implementation of an InkDropAnimationController. 26 // A functional implementation of an InkDropAnimationController.
21 class VIEWS_EXPORT InkDropAnimationControllerImpl 27 class VIEWS_EXPORT InkDropAnimationControllerImpl
22 : public InkDropAnimationController, 28 : public InkDropAnimationController,
23 public InkDropAnimationObserver { 29 public InkDropAnimationObserver {
24 public: 30 public:
25 // Constructs an ink drop controller that will attach the ink drop to the 31 // Constructs an ink drop controller that will attach the ink drop to the
26 // given |ink_drop_host|. 32 // given |ink_drop_host|.
27 explicit InkDropAnimationControllerImpl(InkDropHost* ink_drop_host); 33 explicit InkDropAnimationControllerImpl(InkDropHost* ink_drop_host);
28 ~InkDropAnimationControllerImpl() override; 34 ~InkDropAnimationControllerImpl() override;
29 35
30 // InkDropAnimationController: 36 // InkDropAnimationController:
31 InkDropState GetInkDropState() const override; 37 InkDropState GetInkDropState() const override;
32 void AnimateToState(InkDropState ink_drop_state) override; 38 void AnimateToState(InkDropState ink_drop_state) override;
39 void SetHovered(bool is_hovered) override;
40 bool IsHovered() const override;
33 gfx::Size GetInkDropLargeSize() const override; 41 gfx::Size GetInkDropLargeSize() const override;
34 void SetInkDropSize(const gfx::Size& large_size, 42 void SetInkDropSize(const gfx::Size& large_size,
35 int large_corner_radius, 43 int large_corner_radius,
36 const gfx::Size& small_size, 44 const gfx::Size& small_size,
37 int small_corner_radius) override; 45 int small_corner_radius) override;
38 void SetInkDropCenter(const gfx::Point& center_point) override; 46 void SetInkDropCenter(const gfx::Point& center_point) override;
39 47
40 private: 48 private:
49 friend class InkDropAnimationControllerFactoryTest;
50
51 base::Timer* hover_after_animation_timer_for_test() {
sadrul 2016/01/22 15:23:18 Don't need this since FactoryTest is already a fri
bruthig 2016/01/25 22:39:17 Removed.
52 return hover_after_animation_timer_.get();
53 }
54
41 // Creates a new InkDropAnimation and sets it to |ink_drop_animation_|. If 55 // Creates a new InkDropAnimation and sets it to |ink_drop_animation_|. If
42 // |ink_drop_animation_| wasn't null then it will be destroyed using 56 // |ink_drop_animation_| wasn't null then it will be destroyed using
43 // DestroyInkDropAnimation(). 57 // DestroyInkDropAnimation().
44 void CreateInkDropAnimation(); 58 void CreateInkDropAnimation();
45 59
46 // Destroys the current |ink_drop_animation_|. 60 // Destroys the current |ink_drop_animation_|.
47 void DestroyInkDropAnimation(); 61 void DestroyInkDropAnimation();
48 62
63 // Creates a new InkDropHover and sets it to |hover_|. If |hover_| wasn't null
64 // then it will be destroyed using DestroyInkDropHover().
65 void CreateInkDropHover();
66
67 // Destroys the current |hover_|.
68 void DestroyInkDropHover();
69
49 // views::InkDropAnimationObserver: 70 // views::InkDropAnimationObserver:
50 void InkDropAnimationStarted(InkDropState ink_drop_state) override; 71 void InkDropAnimationStarted(InkDropState ink_drop_state) override;
51 void InkDropAnimationEnded(InkDropState ink_drop_state, 72 void InkDropAnimationEnded(InkDropState ink_drop_state,
52 InkDropAnimationEndedReason reason) override; 73 InkDropAnimationEndedReason reason) override;
53 74
54 // The host of the ink drop. 75 // Enables or disables the hover state based on |is_hovered| and if an
76 // animation is triggered it will be scheduled to have the given
77 // |animation_duration|.
78 void SetHoveredInternal(bool is_hovered, base::TimeDelta animation_duration);
79
80 // Starts the |hover_after_animation_timer_| timer. This will stop the current
81 // |hover_after_animation_timer_| instance if it exists.
82 void StartHoverAfterAnimationTimer();
83
84 // Stops and destroys the current |hover_after_animation_timer_| instance.
85 void StopHoverAfterAnimationTimer();
86
87 // Callback for when the |hover_after_animation_timer_| fires.
88 void HoverAfterAnimationTimerFired();
89
90 // The host of the ink drop. Used to poll for information such as whether the
91 // hover should be shown or not.
55 InkDropHost* ink_drop_host_; 92 InkDropHost* ink_drop_host_;
56 93
57 // Cached size for the ink drop's large size animations. 94 // Cached size for the ink drop's large size animations.
58 gfx::Size ink_drop_large_size_; 95 gfx::Size ink_drop_large_size_;
59 96
60 // Cached corner radius for the ink drop's large size animations. 97 // Cached corner radius for the ink drop's large size animations.
61 int ink_drop_large_corner_radius_; 98 int ink_drop_large_corner_radius_;
62 99
63 // Cached size for the ink drop's small size animations. 100 // Cached size for the ink drop's small size animations.
64 gfx::Size ink_drop_small_size_; 101 gfx::Size ink_drop_small_size_;
65 102
66 // Cached corner radius for the ink drop's small size animations. 103 // Cached corner radius for the ink drop's small size animations.
67 int ink_drop_small_corner_radius_; 104 int ink_drop_small_corner_radius_;
68 105
69 // Cached center point for the ink drop. 106 // Cached center point for the ink drop.
70 gfx::Point ink_drop_center_; 107 gfx::Point ink_drop_center_;
71 108
109 // The root Layer that parents the InkDropAnimation layers and the
110 // InkDropHover layers. The |root_layer_| is the one that is added and removed
111 // from the InkDropHost.
112 scoped_ptr<ui::Layer> root_layer_;
113
114 // The current InkDropHover. Lazily created using CreateInkDropHover();
115 scoped_ptr<InkDropHover> hover_;
116
72 // The current InkDropAnimation. Created on demand using 117 // The current InkDropAnimation. Created on demand using
73 // CreateInkDropAnimation(). 118 // CreateInkDropAnimation().
74 scoped_ptr<InkDropAnimation> ink_drop_animation_; 119 scoped_ptr<InkDropAnimation> ink_drop_animation_;
75 120
121 // The timer used to delay the hover fade in after an ink drop animation.
122 scoped_ptr<base::Timer> hover_after_animation_timer_;
sadrul 2016/01/22 15:23:18 Why a scoped_ptr<>?
bruthig 2016/01/25 22:39:17 This was originally done so that the Timer could b
123
76 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerImpl); 124 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerImpl);
77 }; 125 };
78 126
79 } // namespace views 127 } // namespace views
80 128
81 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_IMPL_H_ 129 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698