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

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

Issue 1422593003: Made material design ink drop QUICK_ACTION animation more visible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added varkha@'s behavioural changes Created 5 years, 1 month 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 6fe08545ddf3060ed7954ca503681ec381f5ae28..880e8ff46ea537f29043ba4339281df4fbdaac9b 100644
--- a/ui/views/animation/ink_drop_animation_controller_impl.cc
+++ b/ui/views/animation/ink_drop_animation_controller_impl.cc
@@ -4,6 +4,7 @@
#include "ui/views/animation/ink_drop_animation_controller_impl.h"
+#include "base/auto_reset.h"
#include "ui/compositor/layer.h"
#include "ui/views/animation/ink_drop_animation.h"
#include "ui/views/animation/ink_drop_host.h"
@@ -26,7 +27,8 @@ InkDropAnimationControllerImpl::InkDropAnimationControllerImpl(
: ink_drop_host_(ink_drop_host),
ink_drop_large_corner_radius_(0),
ink_drop_small_corner_radius_(0),
- root_layer_(new ui::Layer(ui::LAYER_NOT_DRAWN)) {
+ root_layer_(new ui::Layer(ui::LAYER_NOT_DRAWN)),
+ can_destroy_after_hidden_animation_(true) {
ink_drop_host_->AddInkDropLayer(root_layer_.get());
}
@@ -46,9 +48,34 @@ void InkDropAnimationControllerImpl::AnimateToState(
InkDropState ink_drop_state) {
if (!ink_drop_animation_)
CreateInkDropAnimation();
+
+ // The InkDropAnimationObserver::InkDropAnimationEnded() callback needs to
+ // know if it is safe to destroy the |ink_drop_animation_| and it is not safe
+ // when the notification is raised within a call to
+ // InkDropAnimation::AnimateToState().
+ base::AutoReset<bool> auto_reset_can_destroy_after_hidden_animation(
+ &can_destroy_after_hidden_animation_, false);
+
+ // Make sure the ink drop completes its full state transitions if it was going
+ // to auto transition to the HIDDEN state.
+ if (WillAutoAnimateToHidden())
+ ink_drop_animation_->AnimateToState(views::InkDropState::HIDDEN);
ink_drop_animation_->AnimateToState(ink_drop_state);
}
+bool InkDropAnimationControllerImpl::WillAutoAnimateToHidden() const {
varkha 2015/11/06 00:00:27 nit: Maybe ShouldAutoAnimateToHidden? It is not re
bruthig 2015/11/11 18:11:20 From the perspective of the InkDropAnimationContro
+ if (!ink_drop_animation_)
+ return false;
+ switch (ink_drop_animation_->ink_drop_state()) {
+ case views::InkDropState::QUICK_ACTION:
+ case views::InkDropState::SLOW_ACTION:
+ case views::InkDropState::DEACTIVATED:
+ return true;
+ default:
+ return false;
+ }
+}
+
void InkDropAnimationControllerImpl::SetHovered(bool is_hovered) {
if (IsHovered() == is_hovered)
return;
@@ -161,20 +188,14 @@ void InkDropAnimationControllerImpl::InkDropAnimationEnded(
InkDropAnimationEndedReason reason) {
if (reason != SUCCESS)
return;
- switch (ink_drop_state) {
- case views::InkDropState::QUICK_ACTION:
- case views::InkDropState::SLOW_ACTION:
- case views::InkDropState::DEACTIVATED:
- ink_drop_animation_->AnimateToState(views::InkDropState::HIDDEN);
- break;
- case views::InkDropState::HIDDEN:
+ if (WillAutoAnimateToHidden())
+ ink_drop_animation_->AnimateToState(views::InkDropState::HIDDEN);
+ else if (ink_drop_state == views::InkDropState::HIDDEN &&
+ can_destroy_after_hidden_animation_) {
// TODO(bruthig): Investigate whether creating and destroying
// InkDropAnimations is expensive and consider creating an
// InkDropAnimationPool. See www.crbug.com/522175.
DestroyInkDropAnimation();
- break;
- default:
- break;
}
}

Powered by Google App Engine
This is Rietveld 408576698