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

Unified 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 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 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());
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.
+
+ // 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

Powered by Google App Engine
This is Rietveld 408576698