| 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_host.h" | 10 #include "ui/views/animation/ink_drop_host.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 DestroyInkDropRipple(); | 66 DestroyInkDropRipple(); |
| 67 DestroyInkDropHover(); | 67 DestroyInkDropHover(); |
| 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 bool InkDropImpl::IsVisible() const { | |
| 77 return ink_drop_ripple_ && ink_drop_ripple_->IsVisible(); | |
| 78 } | |
| 79 | |
| 80 void InkDropImpl::AnimateToState(InkDropState ink_drop_state) { | 76 void InkDropImpl::AnimateToState(InkDropState ink_drop_state) { |
| 81 DestroyHiddenTargetedAnimations(); | 77 DestroyHiddenTargetedAnimations(); |
| 82 if (!ink_drop_ripple_) | 78 if (!ink_drop_ripple_) |
| 83 CreateInkDropRipple(); | 79 CreateInkDropRipple(); |
| 84 | 80 |
| 85 if (ink_drop_state != views::InkDropState::HIDDEN) { | 81 if (ink_drop_state != views::InkDropState::HIDDEN) { |
| 86 SetHighlight(false, base::TimeDelta::FromMilliseconds( | 82 SetHighlight(false, base::TimeDelta::FromMilliseconds( |
| 87 kHoverFadeOutBeforeRippleDurationInMs), | 83 kHoverFadeOutBeforeRippleDurationInMs), |
| 88 true); | 84 true); |
| 89 } | 85 } |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 void InkDropImpl::SetHighlight(bool should_highlight, | 213 void InkDropImpl::SetHighlight(bool should_highlight, |
| 218 base::TimeDelta animation_duration, | 214 base::TimeDelta animation_duration, |
| 219 bool explode) { | 215 bool explode) { |
| 220 StopHoverAfterRippleTimer(); | 216 StopHoverAfterRippleTimer(); |
| 221 | 217 |
| 222 if (IsHoverFadingInOrVisible() == should_highlight) | 218 if (IsHoverFadingInOrVisible() == should_highlight) |
| 223 return; | 219 return; |
| 224 | 220 |
| 225 if (should_highlight) { | 221 if (should_highlight) { |
| 226 CreateInkDropHover(); | 222 CreateInkDropHover(); |
| 227 if (hover_ && !IsVisible()) | 223 if (hover_ && !(ink_drop_ripple_ && ink_drop_ripple_->IsVisible())) |
| 228 hover_->FadeIn(animation_duration); | 224 hover_->FadeIn(animation_duration); |
| 229 } else { | 225 } else { |
| 230 hover_->FadeOut(animation_duration, explode); | 226 hover_->FadeOut(animation_duration, explode); |
| 231 } | 227 } |
| 232 } | 228 } |
| 233 | 229 |
| 234 bool InkDropImpl::ShouldHighlight() const { | 230 bool InkDropImpl::ShouldHighlight() const { |
| 235 return is_focused_ || is_hovered_; | 231 return is_focused_ || is_hovered_; |
| 236 } | 232 } |
| 237 | 233 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 254 } | 250 } |
| 255 | 251 |
| 256 void InkDropImpl::HoverAfterRippleTimerFired() { | 252 void InkDropImpl::HoverAfterRippleTimerFired() { |
| 257 SetHighlight(true, base::TimeDelta::FromMilliseconds( | 253 SetHighlight(true, base::TimeDelta::FromMilliseconds( |
| 258 kHoverFadeInAfterRippleDurationInMs), | 254 kHoverFadeInAfterRippleDurationInMs), |
| 259 true); | 255 true); |
| 260 hover_after_ripple_timer_.reset(); | 256 hover_after_ripple_timer_.reset(); |
| 261 } | 257 } |
| 262 | 258 |
| 263 } // namespace views | 259 } // namespace views |
| OLD | NEW |