| 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 views { | 15 namespace views { |
| 16 class InkDropAnimation; | 16 class InkDropAnimation; |
| 17 class InkDropHost; | 17 class InkDropHost; |
| 18 class InkDropHover; |
| 18 | 19 |
| 19 // A functional implementation of an InkDropAnimationController. | 20 // A functional implementation of an InkDropAnimationController. |
| 20 class VIEWS_EXPORT InkDropAnimationControllerImpl | 21 class VIEWS_EXPORT InkDropAnimationControllerImpl |
| 21 : public InkDropAnimationController, | 22 : public InkDropAnimationController, |
| 22 public InkDropAnimationObserver { | 23 public InkDropAnimationObserver { |
| 23 public: | 24 public: |
| 24 // Constructs an ink drop controller that will attach the ink drop to the | 25 // Constructs an ink drop controller that will attach the ink drop to the |
| 25 // given |ink_drop_host|. | 26 // given |ink_drop_host|. |
| 26 explicit InkDropAnimationControllerImpl(InkDropHost* ink_drop_host); | 27 explicit InkDropAnimationControllerImpl(InkDropHost* ink_drop_host); |
| 27 ~InkDropAnimationControllerImpl() override; | 28 ~InkDropAnimationControllerImpl() override; |
| 28 | 29 |
| 29 // InkDropAnimationController: | 30 // InkDropAnimationController: |
| 30 InkDropState GetInkDropState() const override; | 31 InkDropState GetInkDropState() const override; |
| 31 void AnimateToState(InkDropState ink_drop_state) override; | 32 void AnimateToState(InkDropState ink_drop_state) override; |
| 33 void SetHovered(bool is_hovered) override; |
| 34 bool IsHovered() const override; |
| 32 gfx::Size GetInkDropLargeSize() const override; | 35 gfx::Size GetInkDropLargeSize() const override; |
| 33 void SetInkDropSize(const gfx::Size& large_size, | 36 void SetInkDropSize(const gfx::Size& large_size, |
| 34 int large_corner_radius, | 37 int large_corner_radius, |
| 35 const gfx::Size& small_size, | 38 const gfx::Size& small_size, |
| 36 int small_corner_radius) override; | 39 int small_corner_radius) override; |
| 37 void SetInkDropCenter(const gfx::Point& center_point) override; | 40 void SetInkDropCenter(const gfx::Point& center_point) override; |
| 38 | 41 |
| 39 private: | 42 private: |
| 40 // Creates a new InkDropAnimation and sets it to |ink_drop_animation_|. If | 43 // 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 | 44 // |ink_drop_animation_| wasn't null then it will be destroyed using |
| 42 // DestroyInkDropAnimation(). | 45 // DestroyInkDropAnimation(). |
| 43 void CreateInkDropAnimation(); | 46 void CreateInkDropAnimation(); |
| 44 | 47 |
| 45 // Destroys the current |ink_drop_animation_|. | 48 // Destroys the current |ink_drop_animation_|. |
| 46 void DestroyInkDropAnimation(); | 49 void DestroyInkDropAnimation(); |
| 47 | 50 |
| 51 // Creates a new InkDropHover and sets it to |hover_|. If |hover_| wasn't null |
| 52 // then it will be destroyed using DestroyInkDropHover(). |
| 53 void CreateInkDropHover(); |
| 54 |
| 55 // Destroys the current |hover_|. |
| 56 void DestroyInkDropHover(); |
| 57 |
| 48 // views::InkDropAnimationObserver: | 58 // views::InkDropAnimationObserver: |
| 49 void InkDropAnimationStarted(InkDropState ink_drop_state) override; | 59 void InkDropAnimationStarted(InkDropState ink_drop_state) override; |
| 50 void InkDropAnimationEnded(InkDropState ink_drop_state, | 60 void InkDropAnimationEnded(InkDropState ink_drop_state, |
| 51 InkDropAnimationEndedReason reason) override; | 61 InkDropAnimationEndedReason reason) override; |
| 52 | 62 |
| 53 // The host of the ink drop. | 63 // The host of the ink drop. |
| 54 InkDropHost* ink_drop_host_; | 64 InkDropHost* ink_drop_host_; |
| 55 | 65 |
| 56 // Cached size for the ink drop's large size animations. | 66 // Cached size for the ink drop's large size animations. |
| 57 gfx::Size ink_drop_large_size_; | 67 gfx::Size ink_drop_large_size_; |
| 58 | 68 |
| 59 // Cached corner radius for the ink drop's large size animations. | 69 // Cached corner radius for the ink drop's large size animations. |
| 60 int ink_drop_large_corner_radius_; | 70 int ink_drop_large_corner_radius_; |
| 61 | 71 |
| 62 // Cached size for the ink drop's small size animations. | 72 // Cached size for the ink drop's small size animations. |
| 63 gfx::Size ink_drop_small_size_; | 73 gfx::Size ink_drop_small_size_; |
| 64 | 74 |
| 65 // Cached corner radius for the ink drop's small size animations. | 75 // Cached corner radius for the ink drop's small size animations. |
| 66 int ink_drop_small_corner_radius_; | 76 int ink_drop_small_corner_radius_; |
| 67 | 77 |
| 68 // Cached center point for the ink drop. | 78 // Cached center point for the ink drop. |
| 69 gfx::Point ink_drop_center_; | 79 gfx::Point ink_drop_center_; |
| 70 | 80 |
| 81 // The root Layer that parents the InkDropAnimation layers and the |
| 82 // InkDropHover layers. The |root_layer_| is the one that is added and removed |
| 83 // from the InkDropHost. |
| 84 scoped_ptr<ui::Layer> root_layer_; |
| 85 |
| 86 // The current InkDropHover. Lazily created using CreateInkDropHover(); |
| 87 scoped_ptr<InkDropHover> hover_; |
| 88 |
| 89 // Tracks whether the ink drop is currently in a hover state or not. Note this |
| 90 // will not always have the same value as |hover_|->is_hovered() because the |
| 91 // hover layer is faded out when the ink drop ripple is active. |
| 92 bool is_hovered_; |
| 93 |
| 71 // The current InkDropAnimation. Created on demand using | 94 // The current InkDropAnimation. Created on demand using |
| 72 // CreateInkDropAnimation(). | 95 // CreateInkDropAnimation(). |
| 73 scoped_ptr<InkDropAnimation> ink_drop_animation_; | 96 scoped_ptr<InkDropAnimation> ink_drop_animation_; |
| 74 | 97 |
| 75 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerImpl); | 98 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerImpl); |
| 76 }; | 99 }; |
| 77 | 100 |
| 78 } // namespace views | 101 } // namespace views |
| 79 | 102 |
| 80 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_IMPL_H_ | 103 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_IMPL_H_ |
| OLD | NEW |