| 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 08e3888394d5b92533525b258786586a0fce4b0e..0b014bd8b5caf3cd853f0a190cde8323dc713873 100644
|
| --- a/ui/views/animation/ink_drop_animation_controller_impl.cc
|
| +++ b/ui/views/animation/ink_drop_animation_controller_impl.cc
|
| @@ -11,33 +11,69 @@ namespace views {
|
|
|
| InkDropAnimationControllerImpl::InkDropAnimationControllerImpl(
|
| InkDropHost* ink_drop_host)
|
| - : ink_drop_host_(ink_drop_host),
|
| - ink_drop_animation_(new InkDropAnimation()) {
|
| - // TODO(bruthig): Change this to only be called before the ink drop becomes
|
| - // active. See www.crbug.com/522175.
|
| - ink_drop_host_->AddInkDropLayer(ink_drop_animation_->root_layer());
|
| -}
|
| + : ink_drop_host_(ink_drop_host) {}
|
|
|
| InkDropAnimationControllerImpl::~InkDropAnimationControllerImpl() {
|
| - // TODO(bruthig): Change this to be called when the ink drop becomes hidden.
|
| - // See www.crbug.com/522175.
|
| - ink_drop_host_->RemoveInkDropLayer(ink_drop_animation_->root_layer());
|
| + if (ink_drop_animation_) {
|
| + // TODO(bruthig): Change this to be called when the ink drop becomes hidden.
|
| + // See www.crbug.com/522175.
|
| + ink_drop_host_->RemoveInkDropLayer(ink_drop_animation_->root_layer());
|
| + }
|
| +}
|
| +
|
| +InkDropState InkDropAnimationControllerImpl::GetInkDropState() const {
|
| + if (!ink_drop_animation_)
|
| + return InkDropState::HIDDEN;
|
| + return ink_drop_animation_->ink_drop_state();
|
| }
|
|
|
| void InkDropAnimationControllerImpl::AnimateToState(InkDropState state) {
|
| + if (!ink_drop_animation_)
|
| + CreateInkDropAnimation();
|
| ink_drop_animation_->AnimateToState(state);
|
| }
|
|
|
| -void InkDropAnimationControllerImpl::SetInkDropSize(const gfx::Size& size) {
|
| - ink_drop_animation_->SetInkDropSize(size);
|
| +gfx::Size InkDropAnimationControllerImpl::GetInkDropLargeSize() const {
|
| + return ink_drop_large_size_;
|
| }
|
|
|
| -gfx::Rect InkDropAnimationControllerImpl::GetInkDropBounds() const {
|
| - return ink_drop_animation_->GetInkDropBounds();
|
| +void InkDropAnimationControllerImpl::SetInkDropSize(const gfx::Size& large_size,
|
| + int large_corner_radius,
|
| + const gfx::Size& small_size,
|
| + int small_corner_radius) {
|
| + // TODO(bruthig): Fix the ink drop animations to work for non-square sizes.
|
| + DCHECK_EQ(large_size.width(), large_size.height())
|
| + << "The ink drop animation does not currently support non-square sizes.";
|
| + DCHECK_EQ(small_size.width(), small_size.height())
|
| + << "The ink drop animation does not currently support non-square sizes.";
|
| + ink_drop_large_size_ = large_size;
|
| + ink_drop_large_corner_radius_ = large_corner_radius;
|
| + ink_drop_small_size_ = small_size;
|
| + ink_drop_small_corner_radius_ = small_corner_radius;
|
| + ink_drop_animation_.reset();
|
| }
|
|
|
| -void InkDropAnimationControllerImpl::SetInkDropBounds(const gfx::Rect& bounds) {
|
| - ink_drop_animation_->SetInkDropBounds(bounds);
|
| +void InkDropAnimationControllerImpl::SetInkDropCenter(
|
| + const gfx::Point& center_point) {
|
| + ink_drop_center_ = center_point;
|
| + if (ink_drop_animation_)
|
| + ink_drop_animation_->SetCenterPoint(ink_drop_center_);
|
| +}
|
| +
|
| +void InkDropAnimationControllerImpl::CreateInkDropAnimation() {
|
| + if (ink_drop_animation_)
|
| + ink_drop_host_->RemoveInkDropLayer(ink_drop_animation_->root_layer());
|
| +
|
| + // TODO(bruthig): It will be expensive to maintain InkDropAnimation instances
|
| + // when they are not actually being used. Consider creating InkDropAnimations
|
| + // on an as-needed basis and if construction is also expensive then consider
|
| + // creating an InkDropAnimationPool. See www.crbug.com/522175.
|
| + ink_drop_animation_.reset(new InkDropAnimation(
|
| + ink_drop_large_size_, ink_drop_large_corner_radius_, ink_drop_small_size_,
|
| + ink_drop_small_corner_radius_));
|
| +
|
| + ink_drop_animation_->SetCenterPoint(ink_drop_center_);
|
| + ink_drop_host_->AddInkDropLayer(ink_drop_animation_->root_layer());
|
| }
|
|
|
| } // namespace views
|
|
|