Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Unified Diff: ui/views/animation/ink_drop_animation_controller_impl.cc

Issue 1757993004: Added ink drop hover/ripple to menu hosting bookmark buttons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed sky@ & varkha@ comments. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/animation/ink_drop_animation_controller_impl.cc
diff --git a/ui/views/animation/ink_drop_animation_controller_impl.cc b/ui/views/animation/ink_drop_animation_controller_impl.cc
index f7dbd12a561c76773bee532e1073d2055fca0392..def6df3bb6f0b75a9938766ca38dabad570b65b3 100644
--- a/ui/views/animation/ink_drop_animation_controller_impl.cc
+++ b/ui/views/animation/ink_drop_animation_controller_impl.cc
@@ -54,6 +54,7 @@ InkDropAnimationControllerImpl::InkDropAnimationControllerImpl(
InkDropHost* ink_drop_host)
: ink_drop_host_(ink_drop_host),
root_layer_(new ui::Layer(ui::LAYER_NOT_DRAWN)),
+ is_hovered_(false),
hover_after_animation_timer_(nullptr) {
root_layer_->set_name("InkDropAnimationControllerImpl:RootLayer");
ink_drop_host_->AddInkDropLayer(root_layer_.get());
@@ -86,16 +87,22 @@ void InkDropAnimationControllerImpl::AnimateToState(
kHoverFadeOutBeforeAnimationDurationInMs));
}
- // Make sure the ink drop starts from the HIDDEN state it was going to auto
- // transition to it.
- if (ink_drop_animation_->target_ink_drop_state() == InkDropState::HIDDEN ||
- ShouldAnimateToHidden(ink_drop_animation_->target_ink_drop_state())) {
- ink_drop_animation_->HideImmediately();
- }
+ CompleteHiddenTargetedAnimations();
ink_drop_animation_->AnimateToState(ink_drop_state);
}
+void InkDropAnimationControllerImpl::SnapToActivated() {
+ if (!ink_drop_animation_)
+ CreateInkDropAnimation();
+
+ SetHoveredInternal(false, base::TimeDelta());
+
+ CompleteHiddenTargetedAnimations();
+ ink_drop_animation_->SnapToActivated();
+}
+
void InkDropAnimationControllerImpl::SetHovered(bool is_hovered) {
+ is_hovered_ = is_hovered;
SetHoveredInternal(is_hovered,
is_hovered ? base::TimeDelta::FromMilliseconds(
kHoverFadeInFromUserInputDurationInMs)
@@ -103,6 +110,13 @@ void InkDropAnimationControllerImpl::SetHovered(bool is_hovered) {
kHoverFadeOutFromUserInputDurationInMs));
}
+void InkDropAnimationControllerImpl::CompleteHiddenTargetedAnimations() {
+ if (ink_drop_animation_->target_ink_drop_state() == InkDropState::HIDDEN ||
+ ShouldAnimateToHidden(ink_drop_animation_->target_ink_drop_state())) {
+ ink_drop_animation_->HideImmediately();
+ }
+}
+
void InkDropAnimationControllerImpl::CreateInkDropAnimation() {
DestroyInkDropAnimation();
ink_drop_animation_ = ink_drop_host_->CreateInkDropAnimation();
@@ -149,7 +163,8 @@ void InkDropAnimationControllerImpl::InkDropAnimationEnded(
if (ShouldAnimateToHidden(ink_drop_state)) {
ink_drop_animation_->AnimateToState(views::InkDropState::HIDDEN);
} else if (ink_drop_state == views::InkDropState::HIDDEN) {
- StartHoverAfterAnimationTimer();
+ if (is_hovered_)
+ StartHoverAfterAnimationTimer();
// TODO(bruthig): Investigate whether creating and destroying
// InkDropAnimations is expensive and consider creating an
// InkDropAnimationPool. See www.crbug.com/522175.

Powered by Google App Engine
This is Rietveld 408576698