Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 // Conditionally adds the |root_layer_| to the |ink_drop_host_|. | |
| 72 void AddRootLayerToHost(); | |
|
varkha
2016/04/28 20:35:00
MaybeAddRootLayerToHost? Also I think it could be
bruthig
2016/04/29 11:02:34
I've opted to use the 'IfNeeded' Suffix. WDYT?
| |
| 73 | |
| 74 // Conditionally removes the |root_layer_| from the |ink_drop_host_|. | |
| 75 void RemoveRootLayerFromHost(); | |
| 76 | |
| 69 // Returns true if the hover animation is in the process of fading in or | 77 // Returns true if the hover animation is in the process of fading in or |
| 70 // is visible. | 78 // is visible. |
| 71 bool IsHoverFadingInOrVisible() const; | 79 bool IsHoverFadingInOrVisible() const; |
| 72 | 80 |
| 73 // views::InkDropAnimationObserver: | 81 // views::InkDropAnimationObserver: |
| 74 void AnimationStarted(InkDropState ink_drop_state) override; | 82 void AnimationStarted(InkDropState ink_drop_state) override; |
| 75 void AnimationEnded(InkDropState ink_drop_state, | 83 void AnimationEnded(InkDropState ink_drop_state, |
| 76 InkDropAnimationEndedReason reason) override; | 84 InkDropAnimationEndedReason reason) override; |
| 77 | 85 |
| 86 // views::InkDropHoverObserver: | |
| 87 void AnimationStarted(InkDropHover::AnimationType animation_type) override; | |
| 88 void AnimationEnded(InkDropHover::AnimationType animation_type, | |
| 89 InkDropAnimationEndedReason reason) override; | |
| 90 | |
| 78 // Enables or disables the hover state based on |is_hovered| and if an | 91 // 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 | 92 // animation is triggered it will be scheduled to have the given |
| 80 // |animation_duration|. If |explode| is true the hover will expand as it | 93 // |animation_duration|. If |explode| is true the hover will expand as it |
| 81 // fades out. |explode| is ignored when |is_hovered| is true. | 94 // fades out. |explode| is ignored when |is_hovered| is true. |
| 82 void SetHoveredInternal(bool is_hovered, | 95 void SetHoveredInternal(bool is_hovered, |
| 83 base::TimeDelta animation_duration, | 96 base::TimeDelta animation_duration, |
| 84 bool explode); | 97 bool explode); |
| 85 | 98 |
| 86 // Starts the |hover_after_animation_timer_| timer. This will stop the current | 99 // Starts the |hover_after_animation_timer_| timer. This will stop the current |
| 87 // |hover_after_animation_timer_| instance if it exists. | 100 // |hover_after_animation_timer_| instance if it exists. |
| 88 void StartHoverAfterAnimationTimer(); | 101 void StartHoverAfterAnimationTimer(); |
| 89 | 102 |
| 90 // Stops and destroys the current |hover_after_animation_timer_| instance. | 103 // Stops and destroys the current |hover_after_animation_timer_| instance. |
| 91 void StopHoverAfterAnimationTimer(); | 104 void StopHoverAfterAnimationTimer(); |
| 92 | 105 |
| 93 // Callback for when the |hover_after_animation_timer_| fires. | 106 // Callback for when the |hover_after_animation_timer_| fires. |
| 94 void HoverAfterAnimationTimerFired(); | 107 void HoverAfterAnimationTimerFired(); |
| 95 | 108 |
| 96 // The host of the ink drop. Used to poll for information such as whether the | 109 // The host of the ink drop. Used to poll for information such as whether the |
| 97 // hover should be shown or not. | 110 // hover should be shown or not. |
| 98 InkDropHost* ink_drop_host_; | 111 InkDropHost* ink_drop_host_; |
| 99 | 112 |
| 100 // The root Layer that parents the InkDropAnimation layers and the | 113 // The root Layer that parents the InkDropAnimation layers and the |
| 101 // InkDropHover layers. The |root_layer_| is the one that is added and removed | 114 // InkDropHover layers. The |root_layer_| is the one that is added and removed |
| 102 // from the InkDropHost. | 115 // from the InkDropHost. |
| 103 std::unique_ptr<ui::Layer> root_layer_; | 116 std::unique_ptr<ui::Layer> root_layer_; |
| 104 | 117 |
| 118 // True when the |root_layer_| has been added to the |ink_drop_host_|. | |
| 119 bool root_layer_added_to_host_; | |
| 120 | |
| 105 // The current InkDropHover. Lazily created using CreateInkDropHover(); | 121 // The current InkDropHover. Lazily created using CreateInkDropHover(); |
|
varkha
2016/04/28 20:35:00
Not sure about it myself and definitely not in thi
bruthig
2016/04/29 11:02:34
100% agreed. I was thinking InkDropRipple and Ink
| |
| 106 std::unique_ptr<InkDropHover> hover_; | 122 std::unique_ptr<InkDropHover> hover_; |
| 107 | 123 |
| 108 // Tracks the logical hovered state of |this| as manipulated by the public | 124 // Tracks the logical hovered state of |this| as manipulated by the public |
| 109 // SetHovered() function. | 125 // SetHovered() function. |
| 110 bool is_hovered_; | 126 bool is_hovered_; |
| 111 | 127 |
| 112 // The current InkDropAnimation. Created on demand using | 128 // The current InkDropAnimation. Created on demand using |
| 113 // CreateInkDropAnimation(). | 129 // CreateInkDropAnimation(). |
| 114 std::unique_ptr<InkDropAnimation> ink_drop_animation_; | 130 std::unique_ptr<InkDropAnimation> ink_drop_animation_; |
| 115 | 131 |
| 116 // The timer used to delay the hover fade in after an ink drop animation. | 132 // The timer used to delay the hover fade in after an ink drop animation. |
| 117 std::unique_ptr<base::Timer> hover_after_animation_timer_; | 133 std::unique_ptr<base::Timer> hover_after_animation_timer_; |
| 118 | 134 |
| 119 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerImpl); | 135 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerImpl); |
| 120 }; | 136 }; |
| 121 | 137 |
| 122 } // namespace views | 138 } // namespace views |
| 123 | 139 |
| 124 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_IMPL_H_ | 140 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_IMPL_H_ |
| OLD | NEW |