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

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

Issue 1298513003: Implemented prototype for new ink drop specs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed pkasting@'s nits from patch set 9. Created 5 years, 3 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 "ui/views/animation/ink_drop_animation.h" 7 #include "ui/views/animation/ink_drop_animation.h"
8 #include "ui/views/animation/ink_drop_host.h" 8 #include "ui/views/animation/ink_drop_host.h"
9 9
10 namespace views { 10 namespace views {
11 11
12 InkDropAnimationControllerImpl::InkDropAnimationControllerImpl( 12 InkDropAnimationControllerImpl::InkDropAnimationControllerImpl(
13 InkDropHost* ink_drop_host) 13 InkDropHost* ink_drop_host)
14 : ink_drop_host_(ink_drop_host), 14 : ink_drop_host_(ink_drop_host) {}
15 ink_drop_animation_(new InkDropAnimation()) { 15
16 // TODO(bruthig): Change this to only be called before the ink drop becomes 16 InkDropAnimationControllerImpl::~InkDropAnimationControllerImpl() {
17 // active. See www.crbug.com/522175. 17 if (ink_drop_animation_) {
18 // TODO(bruthig): Change this to be called when the ink drop becomes hidden.
19 // See www.crbug.com/522175.
20 ink_drop_host_->RemoveInkDropLayer(ink_drop_animation_->root_layer());
21 }
22 }
23
24 InkDropState InkDropAnimationControllerImpl::GetInkDropState() const {
25 if (!ink_drop_animation_)
26 return InkDropState::HIDDEN;
27 return ink_drop_animation_->ink_drop_state();
28 }
29
30 void InkDropAnimationControllerImpl::AnimateToState(InkDropState state) {
31 if (!ink_drop_animation_)
32 CreateInkDropAnimation();
33 ink_drop_animation_->AnimateToState(state);
34 }
35
36 gfx::Size InkDropAnimationControllerImpl::GetInkDropLargeSize() const {
37 return ink_drop_large_size_;
38 }
39
40 void InkDropAnimationControllerImpl::SetInkDropSize(const gfx::Size& large_size,
41 int large_corner_radius,
42 const gfx::Size& small_size,
43 int small_corner_radius) {
44 // TODO(bruthig): Fix the ink drop animations to work for non-square sizes.
45 DCHECK_EQ(large_size.width(), large_size.height())
46 << "The ink drop animation does not currently support non-square sizes.";
47 DCHECK_EQ(small_size.width(), small_size.height())
48 << "The ink drop animation does not currently support non-square sizes.";
49 ink_drop_large_size_ = large_size;
50 ink_drop_large_corner_radius_ = large_corner_radius;
51 ink_drop_small_size_ = small_size;
52 ink_drop_small_corner_radius_ = small_corner_radius;
53 ink_drop_animation_.reset();
54 }
55
56 void InkDropAnimationControllerImpl::SetInkDropCenter(
57 const gfx::Point& center_point) {
58 ink_drop_center_ = center_point;
59 if (ink_drop_animation_)
60 ink_drop_animation_->SetCenterPoint(ink_drop_center_);
61 }
62
63 void InkDropAnimationControllerImpl::CreateInkDropAnimation() {
64 if (ink_drop_animation_)
65 ink_drop_host_->RemoveInkDropLayer(ink_drop_animation_->root_layer());
sadrul 2015/09/14 20:05:41 I guess it's a bit unfortunate that you need to re
bruthig 2015/09/15 19:47:09 It was intentional that the InkDropAnimation doesn
sadrul 2015/09/16 11:19:05 OK. Sounds good.
66
67 // TODO(bruthig): It will be expensive to maintain InkDropAnimation instances
68 // when they are not actually being used. Consider creating InkDropAnimations
69 // on an as-needed basis and if construction is also expensive then consider
70 // creating an InkDropAnimationPool. See www.crbug.com/522175.
71 ink_drop_animation_.reset(new InkDropAnimation(
72 ink_drop_large_size_, ink_drop_large_corner_radius_, ink_drop_small_size_,
73 ink_drop_small_corner_radius_));
74
75 ink_drop_animation_->SetCenterPoint(ink_drop_center_);
18 ink_drop_host_->AddInkDropLayer(ink_drop_animation_->root_layer()); 76 ink_drop_host_->AddInkDropLayer(ink_drop_animation_->root_layer());
19 } 77 }
20 78
21 InkDropAnimationControllerImpl::~InkDropAnimationControllerImpl() {
22 // TODO(bruthig): Change this to be called when the ink drop becomes hidden.
23 // See www.crbug.com/522175.
24 ink_drop_host_->RemoveInkDropLayer(ink_drop_animation_->root_layer());
25 }
26
27 void InkDropAnimationControllerImpl::AnimateToState(InkDropState state) {
28 ink_drop_animation_->AnimateToState(state);
29 }
30
31 void InkDropAnimationControllerImpl::SetInkDropSize(const gfx::Size& size) {
32 ink_drop_animation_->SetInkDropSize(size);
33 }
34
35 gfx::Rect InkDropAnimationControllerImpl::GetInkDropBounds() const {
36 return ink_drop_animation_->GetInkDropBounds();
37 }
38
39 void InkDropAnimationControllerImpl::SetInkDropBounds(const gfx::Rect& bounds) {
40 ink_drop_animation_->SetInkDropBounds(bounds);
41 }
42
43 } // namespace views 79 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698