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

Side by Side Diff: ui/views/animation/ink_drop_animation_controller_impl.cc

Issue 1832963002: MD - add ripples to DL shelf items (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix another TODO 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 unified diff | Download patch
OLDNEW
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_animation_controller_impl.h" 5 #include "ui/views/animation/ink_drop_animation_controller_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 21 matching lines...) Expand all
32 const int kHoverFadeOutBeforeAnimationDurationInMs = 300; 32 const int kHoverFadeOutBeforeAnimationDurationInMs = 300;
33 33
34 // The amount of time in milliseconds that |hover_| should delay after a ripple 34 // The amount of time in milliseconds that |hover_| should delay after a ripple
35 // animation before fading in. 35 // animation before fading in.
36 const int kHoverFadeInAfterAnimationDelayInMs = 1000; 36 const int kHoverFadeInAfterAnimationDelayInMs = 1000;
37 37
38 // Returns true if an ink drop with the given |ink_drop_state| should 38 // Returns true if an ink drop with the given |ink_drop_state| should
39 // automatically transition to the InkDropState::HIDDEN state. 39 // automatically transition to the InkDropState::HIDDEN state.
40 bool ShouldAnimateToHidden(InkDropState ink_drop_state) { 40 bool ShouldAnimateToHidden(InkDropState ink_drop_state) {
41 switch (ink_drop_state) { 41 switch (ink_drop_state) {
42 case views::InkDropState::QUICK_ACTION: 42 case views::InkDropState::ACTION_TRIGGERED:
43 case views::InkDropState::SLOW_ACTION: 43 case views::InkDropState::ALTERNATE_ACTION_TRIGGERED:
44 case views::InkDropState::DEACTIVATED: 44 case views::InkDropState::DEACTIVATED:
45 return true; 45 return true;
46 default: 46 default:
47 return false; 47 return false;
48 } 48 }
49 } 49 }
50 50
51 } // namespace 51 } // namespace
52 52
53 InkDropAnimationControllerImpl::InkDropAnimationControllerImpl( 53 InkDropAnimationControllerImpl::InkDropAnimationControllerImpl(
(...skipping 18 matching lines...) Expand all
72 return InkDropState::HIDDEN; 72 return InkDropState::HIDDEN;
73 return ink_drop_animation_->target_ink_drop_state(); 73 return ink_drop_animation_->target_ink_drop_state();
74 } 74 }
75 75
76 bool InkDropAnimationControllerImpl::IsVisible() const { 76 bool InkDropAnimationControllerImpl::IsVisible() const {
77 return ink_drop_animation_ && ink_drop_animation_->IsVisible(); 77 return ink_drop_animation_ && ink_drop_animation_->IsVisible();
78 } 78 }
79 79
80 void InkDropAnimationControllerImpl::AnimateToState( 80 void InkDropAnimationControllerImpl::AnimateToState(
81 InkDropState ink_drop_state) { 81 InkDropState ink_drop_state) {
82 DestroyHiddenTargetedAnimations();
82 if (!ink_drop_animation_) 83 if (!ink_drop_animation_)
83 CreateInkDropAnimation(); 84 CreateInkDropAnimation();
84 85
85 if (ink_drop_state != views::InkDropState::HIDDEN) { 86 if (ink_drop_state != views::InkDropState::HIDDEN) {
86 SetHoveredInternal(false, base::TimeDelta::FromMilliseconds( 87 SetHoveredInternal(false, base::TimeDelta::FromMilliseconds(
87 kHoverFadeOutBeforeAnimationDurationInMs)); 88 kHoverFadeOutBeforeAnimationDurationInMs));
88 } 89 }
89 90
90 CompleteHiddenTargetedAnimations();
91 ink_drop_animation_->AnimateToState(ink_drop_state); 91 ink_drop_animation_->AnimateToState(ink_drop_state);
92 } 92 }
93 93
94 void InkDropAnimationControllerImpl::SnapToActivated() { 94 void InkDropAnimationControllerImpl::SnapToActivated() {
95 DestroyHiddenTargetedAnimations();
95 if (!ink_drop_animation_) 96 if (!ink_drop_animation_)
96 CreateInkDropAnimation(); 97 CreateInkDropAnimation();
97 98
98 SetHoveredInternal(false, base::TimeDelta()); 99 SetHoveredInternal(false, base::TimeDelta());
99 100
100 CompleteHiddenTargetedAnimations();
101 ink_drop_animation_->SnapToActivated(); 101 ink_drop_animation_->SnapToActivated();
102 } 102 }
103 103
104 void InkDropAnimationControllerImpl::SetHovered(bool is_hovered) { 104 void InkDropAnimationControllerImpl::SetHovered(bool is_hovered) {
105 is_hovered_ = is_hovered; 105 is_hovered_ = is_hovered;
106 SetHoveredInternal(is_hovered, 106 SetHoveredInternal(is_hovered,
107 is_hovered ? base::TimeDelta::FromMilliseconds( 107 is_hovered ? base::TimeDelta::FromMilliseconds(
108 kHoverFadeInFromUserInputDurationInMs) 108 kHoverFadeInFromUserInputDurationInMs)
109 : base::TimeDelta::FromMilliseconds( 109 : base::TimeDelta::FromMilliseconds(
110 kHoverFadeOutFromUserInputDurationInMs)); 110 kHoverFadeOutFromUserInputDurationInMs));
111 } 111 }
112 112
113 void InkDropAnimationControllerImpl::CompleteHiddenTargetedAnimations() { 113 void InkDropAnimationControllerImpl::DestroyHiddenTargetedAnimations() {
114 if (ink_drop_animation_->target_ink_drop_state() == InkDropState::HIDDEN || 114 if (ink_drop_animation_ &&
115 ShouldAnimateToHidden(ink_drop_animation_->target_ink_drop_state())) { 115 (ink_drop_animation_->target_ink_drop_state() == InkDropState::HIDDEN ||
116 ink_drop_animation_->HideImmediately(); 116 ShouldAnimateToHidden(ink_drop_animation_->target_ink_drop_state()))) {
117 DestroyInkDropAnimation();
117 } 118 }
118 } 119 }
119 120
120 void InkDropAnimationControllerImpl::CreateInkDropAnimation() { 121 void InkDropAnimationControllerImpl::CreateInkDropAnimation() {
121 DestroyInkDropAnimation(); 122 DestroyInkDropAnimation();
122 ink_drop_animation_ = ink_drop_host_->CreateInkDropAnimation(); 123 ink_drop_animation_ = ink_drop_host_->CreateInkDropAnimation();
123 ink_drop_animation_->set_observer(this); 124 ink_drop_animation_->set_observer(this);
124 root_layer_->Add(ink_drop_animation_->GetRootLayer()); 125 root_layer_->Add(ink_drop_animation_->GetRootLayer());
125 } 126 }
126 127
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 hover_after_animation_timer_.reset(); 208 hover_after_animation_timer_.reset();
208 } 209 }
209 210
210 void InkDropAnimationControllerImpl::HoverAfterAnimationTimerFired() { 211 void InkDropAnimationControllerImpl::HoverAfterAnimationTimerFired() {
211 SetHoveredInternal(true, base::TimeDelta::FromMilliseconds( 212 SetHoveredInternal(true, base::TimeDelta::FromMilliseconds(
212 kHoverFadeInAfterAnimationDurationInMs)); 213 kHoverFadeInAfterAnimationDurationInMs));
213 hover_after_animation_timer_.reset(); 214 hover_after_animation_timer_.reset();
214 } 215 }
215 216
216 } // namespace views 217 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698