| 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_IMPL_H_ | 5 #ifndef UI_VIEWS_ANIMATION_INK_DROP_IMPL_H_ |
| 6 #define UI_VIEWS_ANIMATION_INK_DROP_IMPL_H_ | 6 #define UI_VIEWS_ANIMATION_INK_DROP_IMPL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 // |ink_drop_host|. | 38 // |ink_drop_host|. |
| 39 explicit InkDropImpl(InkDropHost* ink_drop_host); | 39 explicit InkDropImpl(InkDropHost* ink_drop_host); |
| 40 ~InkDropImpl() override; | 40 ~InkDropImpl() override; |
| 41 | 41 |
| 42 // InkDrop: | 42 // InkDrop: |
| 43 InkDropState GetTargetInkDropState() const override; | 43 InkDropState GetTargetInkDropState() const override; |
| 44 bool IsVisible() const override; | 44 bool IsVisible() const override; |
| 45 void AnimateToState(InkDropState ink_drop_state) override; | 45 void AnimateToState(InkDropState ink_drop_state) override; |
| 46 void SnapToActivated() override; | 46 void SnapToActivated() override; |
| 47 void SetHovered(bool is_hovered) override; | 47 void SetHovered(bool is_hovered) override; |
| 48 void SetFocused(bool is_focused) override; |
| 48 | 49 |
| 49 private: | 50 private: |
| 50 friend class test::InkDropImplTestApi; | 51 friend class test::InkDropImplTestApi; |
| 51 | 52 |
| 52 // Destroys |ink_drop_ripple_| if it's targeted to the HIDDEN state. | 53 // Destroys |ink_drop_ripple_| if it's targeted to the HIDDEN state. |
| 53 void DestroyHiddenTargetedAnimations(); | 54 void DestroyHiddenTargetedAnimations(); |
| 54 | 55 |
| 55 // Creates a new InkDropRipple and sets it to |ink_drop_ripple_|. If | 56 // Creates a new InkDropRipple and sets it to |ink_drop_ripple_|. If |
| 56 // |ink_drop_ripple_| wasn't null then it will be destroyed using | 57 // |ink_drop_ripple_| wasn't null then it will be destroyed using |
| 57 // DestroyInkDropRipple(). | 58 // DestroyInkDropRipple(). |
| (...skipping 24 matching lines...) Expand all Loading... |
| 82 // views::InkDropRippleObserver: | 83 // views::InkDropRippleObserver: |
| 83 void AnimationStarted(InkDropState ink_drop_state) override; | 84 void AnimationStarted(InkDropState ink_drop_state) override; |
| 84 void AnimationEnded(InkDropState ink_drop_state, | 85 void AnimationEnded(InkDropState ink_drop_state, |
| 85 InkDropAnimationEndedReason reason) override; | 86 InkDropAnimationEndedReason reason) override; |
| 86 | 87 |
| 87 // views::InkDropHoverObserver: | 88 // views::InkDropHoverObserver: |
| 88 void AnimationStarted(InkDropHover::AnimationType animation_type) override; | 89 void AnimationStarted(InkDropHover::AnimationType animation_type) override; |
| 89 void AnimationEnded(InkDropHover::AnimationType animation_type, | 90 void AnimationEnded(InkDropHover::AnimationType animation_type, |
| 90 InkDropAnimationEndedReason reason) override; | 91 InkDropAnimationEndedReason reason) override; |
| 91 | 92 |
| 92 // Enables or disables the hover state based on |is_hovered| and if an | 93 // Enables or disables the hover state based on |should_highlight| and if an |
| 93 // animation is triggered it will be scheduled to have the given | 94 // animation is triggered it will be scheduled to have the given |
| 94 // |animation_duration|. If |explode| is true the hover will expand as it | 95 // |animation_duration|. If |explode| is true the hover will expand as it |
| 95 // fades out. |explode| is ignored when |is_hovered| is true. | 96 // fades out. |explode| is ignored when |should_higlight| is true. |
| 96 void SetHoveredInternal(bool is_hovered, | 97 void SetHighlight(bool should_highlight, |
| 97 base::TimeDelta animation_duration, | 98 base::TimeDelta animation_duration, |
| 98 bool explode); | 99 bool explode); |
| 100 |
| 101 // Returns true if this ink drop is hovered or focused. |
| 102 bool ShouldHighlight() const; |
| 99 | 103 |
| 100 // Starts the |hover_after_ripple_timer_| timer. This will stop the current | 104 // Starts the |hover_after_ripple_timer_| timer. This will stop the current |
| 101 // |hover_after_ripple_timer_| instance if it exists. | 105 // |hover_after_ripple_timer_| instance if it exists. |
| 102 void StartHoverAfterRippleTimer(); | 106 void StartHoverAfterRippleTimer(); |
| 103 | 107 |
| 104 // Stops and destroys the current |hover_after_ripple_timer_| instance. | 108 // Stops and destroys the current |hover_after_ripple_timer_| instance. |
| 105 void StopHoverAfterRippleTimer(); | 109 void StopHoverAfterRippleTimer(); |
| 106 | 110 |
| 107 // Callback for when the |hover_after_ripple_timer_| fires. | 111 // Callback for when the |hover_after_ripple_timer_| fires. |
| 108 void HoverAfterRippleTimerFired(); | 112 void HoverAfterRippleTimerFired(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 119 // True when the |root_layer_| has been added to the |ink_drop_host_|. | 123 // True when the |root_layer_| has been added to the |ink_drop_host_|. |
| 120 bool root_layer_added_to_host_; | 124 bool root_layer_added_to_host_; |
| 121 | 125 |
| 122 // The current InkDropHover. Lazily created using CreateInkDropHover(); | 126 // The current InkDropHover. Lazily created using CreateInkDropHover(); |
| 123 std::unique_ptr<InkDropHover> hover_; | 127 std::unique_ptr<InkDropHover> hover_; |
| 124 | 128 |
| 125 // Tracks the logical hovered state of |this| as manipulated by the public | 129 // Tracks the logical hovered state of |this| as manipulated by the public |
| 126 // SetHovered() function. | 130 // SetHovered() function. |
| 127 bool is_hovered_; | 131 bool is_hovered_; |
| 128 | 132 |
| 133 // Tracks the logical focused state of |this| as manipulated by the public |
| 134 // SetFocused() function. |
| 135 bool is_focused_; |
| 136 |
| 129 // The current InkDropRipple. Created on demand using CreateInkDropRipple(). | 137 // The current InkDropRipple. Created on demand using CreateInkDropRipple(). |
| 130 std::unique_ptr<InkDropRipple> ink_drop_ripple_; | 138 std::unique_ptr<InkDropRipple> ink_drop_ripple_; |
| 131 | 139 |
| 132 // The timer used to delay the hover fade in after an ink drop ripple | 140 // The timer used to delay the hover fade in after an ink drop ripple |
| 133 // animation. | 141 // animation. |
| 134 std::unique_ptr<base::Timer> hover_after_ripple_timer_; | 142 std::unique_ptr<base::Timer> hover_after_ripple_timer_; |
| 135 | 143 |
| 136 DISALLOW_COPY_AND_ASSIGN(InkDropImpl); | 144 DISALLOW_COPY_AND_ASSIGN(InkDropImpl); |
| 137 }; | 145 }; |
| 138 | 146 |
| 139 } // namespace views | 147 } // namespace views |
| 140 | 148 |
| 141 #endif // UI_VIEWS_ANIMATION_INK_DROP_IMPL_H_ | 149 #endif // UI_VIEWS_ANIMATION_INK_DROP_IMPL_H_ |
| OLD | NEW |