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

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

Issue 1951593002: Add MD Ink Drop to host only when a ripple/hover is active. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Replaced unique_ptr with scoped_ptr. Created 4 years, 8 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
« no previous file with comments | « ui/views/animation/ink_drop_hover.h ('k') | ui/views/animation/ink_drop_hover_observer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/animation/ink_drop_hover.cc
diff --git a/ui/views/animation/ink_drop_hover.cc b/ui/views/animation/ink_drop_hover.cc
index f53a95a0284184c0d1aa1ab8a1a171cdc6d110b3..af98e614f5978c893fd276d1663a8fe4ff5c6ede 100644
--- a/ui/views/animation/ink_drop_hover.cc
+++ b/ui/views/animation/ink_drop_hover.cc
@@ -9,6 +9,7 @@
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_sequence.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
+#include "ui/views/animation/ink_drop_hover_observer.h"
#include "ui/views/animation/ink_drop_painted_layer_delegates.h"
namespace views {
@@ -33,7 +34,8 @@ InkDropHover::InkDropHover(const gfx::Size& size,
last_animation_initiated_was_fade_in_(false),
layer_delegate_(
new RoundedRectangleLayerDelegate(color, size, corner_radius)),
- layer_(new ui::Layer()) {
+ layer_(new ui::Layer()),
+ observer_(nullptr) {
layer_->SetBounds(gfx::Rect(size));
layer_->SetFillsBoundsOpaquely(false);
layer_->set_delegate(layer_delegate_.get());
@@ -63,7 +65,7 @@ test::InkDropHoverTestApi* InkDropHover::GetTestApi() {
return nullptr;
}
-void InkDropHover::AnimateFade(HoverAnimationType animation_type,
+void InkDropHover::AnimateFade(AnimationType animation_type,
const base::TimeDelta& duration,
const gfx::Size& initial_size,
const gfx::Size& target_size) {
@@ -75,6 +77,8 @@ void InkDropHover::AnimateFade(HoverAnimationType animation_type,
// AnimationStartedCallback() returns true.
ui::CallbackLayerAnimationObserver* animation_observer =
new ui::CallbackLayerAnimationObserver(
+ base::Bind(&InkDropHover::AnimationStartedCallback,
+ base::Unretained(this), animation_type),
base::Bind(&InkDropHover::AnimationEndedCallback,
base::Unretained(this), animation_type));
@@ -115,13 +119,27 @@ gfx::Transform InkDropHover::CalculateTransform(const gfx::Size& size) const {
return transform;
}
+void InkDropHover::AnimationStartedCallback(
+ AnimationType animation_type,
+ const ui::CallbackLayerAnimationObserver& observer) {
+ if (observer_)
+ observer_->AnimationStarted(animation_type);
+}
+
bool InkDropHover::AnimationEndedCallback(
- HoverAnimationType animation_type,
+ AnimationType animation_type,
const ui::CallbackLayerAnimationObserver& observer) {
// AnimationEndedCallback() may be invoked when this is being destroyed and
// |layer_| may be null.
if (animation_type == FADE_OUT && layer_)
layer_->SetVisible(false);
+
+ if (observer_) {
+ observer_->AnimationEnded(animation_type,
+ observer.aborted_count()
+ ? InkDropAnimationEndedReason::PRE_EMPTED
+ : InkDropAnimationEndedReason::SUCCESS);
+ }
return true;
}
« no previous file with comments | « ui/views/animation/ink_drop_hover.h ('k') | ui/views/animation/ink_drop_hover_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698