| 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 #include "ui/views/animation/ink_drop_impl.h" | 5 #include "ui/views/animation/ink_drop_impl.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/timer/timer.h" | 8 #include "base/timer/timer.h" |
| 9 #include "ui/compositor/layer.h" | 9 #include "ui/compositor/layer.h" |
| 10 #include "ui/views/animation/ink_drop_highlight.h" | 10 #include "ui/views/animation/ink_drop_highlight.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 DestroyInkDropHighlight(); | 67 DestroyInkDropHighlight(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 InkDropState InkDropImpl::GetTargetInkDropState() const { | 70 InkDropState InkDropImpl::GetTargetInkDropState() const { |
| 71 if (!ink_drop_ripple_) | 71 if (!ink_drop_ripple_) |
| 72 return InkDropState::HIDDEN; | 72 return InkDropState::HIDDEN; |
| 73 return ink_drop_ripple_->target_ink_drop_state(); | 73 return ink_drop_ripple_->target_ink_drop_state(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void InkDropImpl::AnimateToState(InkDropState ink_drop_state) { | 76 void InkDropImpl::AnimateToState(InkDropState ink_drop_state) { |
| 77 // Never animate hidden -> hidden, since that will add layers which may never |
| 78 // be needed. Other same-state transitions may restart animations. |
| 79 if (ink_drop_state == InkDropState::HIDDEN && |
| 80 GetTargetInkDropState() == InkDropState::HIDDEN) |
| 81 return; |
| 82 |
| 77 DestroyHiddenTargetedAnimations(); | 83 DestroyHiddenTargetedAnimations(); |
| 78 if (!ink_drop_ripple_) | 84 if (!ink_drop_ripple_) |
| 79 CreateInkDropRipple(); | 85 CreateInkDropRipple(); |
| 80 | 86 |
| 81 if (ink_drop_ripple_->OverridesHighlight()) { | 87 if (ink_drop_ripple_->OverridesHighlight()) { |
| 82 // When deactivating and the host is focused, snap back to the highlight | 88 // When deactivating and the host is focused, snap back to the highlight |
| 83 // state. (In the case of highlighting due to hover, we'll animate the | 89 // state. (In the case of highlighting due to hover, we'll animate the |
| 84 // highlight back in after a delay.) | 90 // highlight back in after a delay.) |
| 85 if (ink_drop_state == views::InkDropState::DEACTIVATED && is_focused_) { | 91 if (ink_drop_state == views::InkDropState::DEACTIVATED && is_focused_) { |
| 86 ink_drop_ripple_->HideImmediately(); | 92 ink_drop_ripple_->HideImmediately(); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 } | 271 } |
| 266 | 272 |
| 267 void InkDropImpl::HighlightAfterRippleTimerFired() { | 273 void InkDropImpl::HighlightAfterRippleTimerFired() { |
| 268 SetHighlight(true, base::TimeDelta::FromMilliseconds( | 274 SetHighlight(true, base::TimeDelta::FromMilliseconds( |
| 269 kHighlightFadeInAfterRippleDurationMs), | 275 kHighlightFadeInAfterRippleDurationMs), |
| 270 true); | 276 true); |
| 271 highlight_after_ripple_timer_.reset(); | 277 highlight_after_ripple_timer_.reset(); |
| 272 } | 278 } |
| 273 | 279 |
| 274 } // namespace views | 280 } // namespace views |
| OLD | NEW |