| 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 "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "ui/gfx/geometry/rect.h" | 9 #include "ui/gfx/geometry/rect.h" |
| 10 #include "ui/gfx/geometry/size.h" | 10 #include "ui/gfx/geometry/size.h" |
| 11 #include "ui/views/animation/ink_drop_animation_controller.h" | 11 #include "ui/views/animation/ink_drop_animation_controller.h" |
| 12 #include "ui/views/animation/ink_drop_animation_observer.h" | 12 #include "ui/views/animation/ink_drop_animation_observer.h" |
| 13 #include "ui/views/views_export.h" | 13 #include "ui/views/views_export.h" |
| 14 | 14 |
| 15 namespace base { |
| 16 class OneShotTimer; |
| 17 } // namespace base |
| 18 |
| 15 namespace views { | 19 namespace views { |
| 16 class InkDropAnimation; | 20 class InkDropAnimation; |
| 21 class InkDropConsumer; |
| 17 class InkDropHost; | 22 class InkDropHost; |
| 23 class InkDropHover; |
| 18 | 24 |
| 19 // A functional implementation of an InkDropAnimationController. | 25 // A functional implementation of an InkDropAnimationController. |
| 20 class VIEWS_EXPORT InkDropAnimationControllerImpl | 26 class VIEWS_EXPORT InkDropAnimationControllerImpl |
| 21 : public InkDropAnimationController, | 27 : public InkDropAnimationController, |
| 22 public InkDropAnimationObserver { | 28 public InkDropAnimationObserver { |
| 23 public: | 29 public: |
| 24 // Constructs an ink drop controller that will attach the ink drop to the | 30 // Constructs an ink drop controller that will attach the ink drop to the |
| 25 // given |ink_drop_host|. | 31 // given |ink_drop_host|. |
| 26 explicit InkDropAnimationControllerImpl(InkDropHost* ink_drop_host); | 32 InkDropAnimationControllerImpl(InkDropHost* ink_drop_host, |
| 33 InkDropConsumer* ink_drop_consumer); |
| 27 ~InkDropAnimationControllerImpl() override; | 34 ~InkDropAnimationControllerImpl() override; |
| 28 | 35 |
| 29 // InkDropAnimationController: | 36 // InkDropAnimationController: |
| 30 InkDropState GetInkDropState() const override; | 37 InkDropState GetInkDropState() const override; |
| 31 void AnimateToState(InkDropState ink_drop_state) override; | 38 void AnimateToState(InkDropState ink_drop_state) override; |
| 39 bool WillAutoAnimateToHidden() const override; |
| 40 void SetHovered(bool is_hovered) override; |
| 41 bool IsHovered() const override; |
| 32 gfx::Size GetInkDropLargeSize() const override; | 42 gfx::Size GetInkDropLargeSize() const override; |
| 33 void SetInkDropSize(const gfx::Size& large_size, | 43 void SetInkDropSize(const gfx::Size& large_size, |
| 34 int large_corner_radius, | 44 int large_corner_radius, |
| 35 const gfx::Size& small_size, | 45 const gfx::Size& small_size, |
| 36 int small_corner_radius) override; | 46 int small_corner_radius) override; |
| 37 void SetInkDropCenter(const gfx::Point& center_point) override; | 47 void SetInkDropCenter(const gfx::Point& center_point) override; |
| 38 | 48 |
| 39 private: | 49 private: |
| 40 // Creates a new InkDropAnimation and sets it to |ink_drop_animation_|. If | 50 // Creates a new InkDropAnimation and sets it to |ink_drop_animation_|. If |
| 41 // |ink_drop_animation_| wasn't null then it will be destroyed using | 51 // |ink_drop_animation_| wasn't null then it will be destroyed using |
| 42 // DestroyInkDropAnimation(). | 52 // DestroyInkDropAnimation(). |
| 43 void CreateInkDropAnimation(); | 53 void CreateInkDropAnimation(); |
| 44 | 54 |
| 45 // Destroys the current |ink_drop_animation_|. | 55 // Destroys the current |ink_drop_animation_|. |
| 46 void DestroyInkDropAnimation(); | 56 void DestroyInkDropAnimation(); |
| 47 | 57 |
| 58 // Creates a new InkDropHover and sets it to |hover_|. If |hover_| wasn't null |
| 59 // then it will be destroyed using DestroyInkDropHover(). |
| 60 void CreateInkDropHover(); |
| 61 |
| 62 // Destroys the current |hover_|. |
| 63 void DestroyInkDropHover(); |
| 64 |
| 48 // views::InkDropAnimationObserver: | 65 // views::InkDropAnimationObserver: |
| 49 void InkDropAnimationStarted(InkDropState ink_drop_state) override; | 66 void InkDropAnimationStarted(InkDropState ink_drop_state) override; |
| 50 void InkDropAnimationEnded(InkDropState ink_drop_state, | 67 void InkDropAnimationEnded(InkDropState ink_drop_state, |
| 51 InkDropAnimationEndedReason reason) override; | 68 InkDropAnimationEndedReason reason) override; |
| 52 | 69 |
| 70 // Enables or disables the hover state based on |is_hovered| and if an |
| 71 // animation is triggered it will be scheduled to have the given |
| 72 // |animation_duration|. |
| 73 void SetHoveredInternal(bool is_hovered, base::TimeDelta animation_duration); |
| 74 |
| 75 // Starts the |hover_after_animation_timer_| timer. This will stop the current |
| 76 // |hover_after_animation_timer_| instance if it exists. |
| 77 void StartHoverAfterAnimationTimer(); |
| 78 |
| 79 // Stops and destroys the current |hover_after_animation_timer_| instance. |
| 80 void StopHoverAfterAnimationTimer(); |
| 81 |
| 82 // Callback for when the |hover_after_animation_timer_| fires. |
| 83 void HoverAfterAnimationTimerFired(); |
| 84 |
| 53 // The host of the ink drop. | 85 // The host of the ink drop. |
| 54 InkDropHost* ink_drop_host_; | 86 InkDropHost* ink_drop_host_; |
| 55 | 87 |
| 88 // The consuming surface of the ink drop. Used to poll for information such as |
| 89 // whether the hover should be shown or not. |
| 90 InkDropConsumer* ink_drop_consumer_; |
| 91 |
| 56 // Cached size for the ink drop's large size animations. | 92 // Cached size for the ink drop's large size animations. |
| 57 gfx::Size ink_drop_large_size_; | 93 gfx::Size ink_drop_large_size_; |
| 58 | 94 |
| 59 // Cached corner radius for the ink drop's large size animations. | 95 // Cached corner radius for the ink drop's large size animations. |
| 60 int ink_drop_large_corner_radius_; | 96 int ink_drop_large_corner_radius_; |
| 61 | 97 |
| 62 // Cached size for the ink drop's small size animations. | 98 // Cached size for the ink drop's small size animations. |
| 63 gfx::Size ink_drop_small_size_; | 99 gfx::Size ink_drop_small_size_; |
| 64 | 100 |
| 65 // Cached corner radius for the ink drop's small size animations. | 101 // Cached corner radius for the ink drop's small size animations. |
| 66 int ink_drop_small_corner_radius_; | 102 int ink_drop_small_corner_radius_; |
| 67 | 103 |
| 68 // Cached center point for the ink drop. | 104 // Cached center point for the ink drop. |
| 69 gfx::Point ink_drop_center_; | 105 gfx::Point ink_drop_center_; |
| 70 | 106 |
| 107 // The root Layer that parents the InkDropAnimation layers and the |
| 108 // InkDropHover layers. The |root_layer_| is the one that is added and removed |
| 109 // from the InkDropHost. |
| 110 scoped_ptr<ui::Layer> root_layer_; |
| 111 |
| 112 // The current InkDropHover. Lazily created using CreateInkDropHover(); |
| 113 scoped_ptr<InkDropHover> hover_; |
| 114 |
| 71 // The current InkDropAnimation. Created on demand using | 115 // The current InkDropAnimation. Created on demand using |
| 72 // CreateInkDropAnimation(). | 116 // CreateInkDropAnimation(). |
| 73 scoped_ptr<InkDropAnimation> ink_drop_animation_; | 117 scoped_ptr<InkDropAnimation> ink_drop_animation_; |
| 74 | 118 |
| 119 // Tracks whether the InkDropAnimation can be destroyed when a |
| 120 // InkDropState::HIDDEN animation completes. |
| 121 bool can_destroy_after_hidden_animation_; |
| 122 |
| 123 // The timer used to delay the hover fade in after an ink drop animation. |
| 124 scoped_ptr<base::OneShotTimer> hover_after_animation_timer_; |
| 125 |
| 75 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerImpl); | 126 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerImpl); |
| 76 }; | 127 }; |
| 77 | 128 |
| 78 } // namespace views | 129 } // namespace views |
| 79 | 130 |
| 80 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_IMPL_H_ | 131 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_IMPL_H_ |
| OLD | NEW |