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

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: Working prototype. Created 5 years, 4 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 9ca67341f1dcdee3ca85d15d920b2603a09308ca..dd2b864a0a5c377e9e2279f72504aca7b5789fd9 100644
--- a/ui/views/animation/ink_drop_animation_controller_impl.cc
+++ b/ui/views/animation/ink_drop_animation_controller_impl.cc
@@ -11,33 +11,73 @@ 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_->GetRootLayer());
-}
+ : 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_->GetRootLayer());
+ 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_->GetRootLayer());
+ }
+}
+
+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_;
+}
+
+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();
}
-gfx::Rect InkDropAnimationControllerImpl::GetInkDropBounds() const {
- return ink_drop_animation_->GetInkDropBounds();
+gfx::Point InkDropAnimationControllerImpl::GetInkDropOrigin() const {
+ return ink_drop_origin_;
}
-void InkDropAnimationControllerImpl::SetInkDropBounds(const gfx::Rect& bounds) {
- ink_drop_animation_->SetInkDropBounds(bounds);
+void InkDropAnimationControllerImpl::SetInkDropOrigin(
+ const gfx::Point& origin) {
+ ink_drop_origin_ = origin;
+ if (ink_drop_animation_)
+ ink_drop_animation_->SetOrigin(ink_drop_origin_);
+}
+
+void InkDropAnimationControllerImpl::CreateInkDropAnimation() {
+ if (ink_drop_animation_)
+ ink_drop_host_->RemoveInkDropLayer(ink_drop_animation_->GetRootLayer());
+
+ // 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_->SetOrigin(ink_drop_origin_);
+ ink_drop_host_->AddInkDropLayer(ink_drop_animation_->GetRootLayer());
}
} // namespace views

Powered by Google App Engine
This is Rietveld 408576698