| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/app_list/views/top_icon_animation_view.h" | 5 #include "ui/app_list/views/top_icon_animation_view.h" |
| 6 | 6 |
| 7 #include "base/thread_task_runner_handle.h" | 7 #include "base/thread_task_runner_handle.h" |
| 8 #include "ui/app_list/app_list_constants.h" | 8 #include "ui/app_list/app_list_constants.h" |
| 9 #include "ui/compositor/scoped_layer_animation_settings.h" | 9 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 10 #include "ui/gfx/image/image_skia_operations.h" | 10 #include "ui/gfx/image/image_skia_operations.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 void TopIconAnimationView::RemoveObserver(TopIconAnimationObserver* observer) { | 43 void TopIconAnimationView::RemoveObserver(TopIconAnimationObserver* observer) { |
| 44 observers_.RemoveObserver(observer); | 44 observers_.RemoveObserver(observer); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void TopIconAnimationView::TransformView() { | 47 void TopIconAnimationView::TransformView() { |
| 48 // This view will delete itself on animation completion. | 48 // This view will delete itself on animation completion. |
| 49 set_owned_by_client(); | 49 set_owned_by_client(); |
| 50 | 50 |
| 51 // Transform used for scaling down the icon and move it back inside to the | 51 // Transform used for scaling down the icon and move it back inside to the |
| 52 // original folder icon. | 52 // original folder icon. The transform's origin is this view's origin. |
| 53 const float kIconTransformScale = 0.33333f; | |
| 54 gfx::Transform transform; | 53 gfx::Transform transform; |
| 55 transform.Translate(scaled_rect_.x() - layer()->bounds().x(), | 54 transform.Translate(scaled_rect_.x() - bounds().x(), |
| 56 scaled_rect_.y() - layer()->bounds().y()); | 55 scaled_rect_.y() - bounds().y()); |
| 57 transform.Scale(kIconTransformScale, kIconTransformScale); | 56 transform.Scale( |
| 57 static_cast<double>(scaled_rect_.width()) / bounds().width(), |
| 58 static_cast<double>(scaled_rect_.height()) / bounds().height()); |
| 58 | 59 |
| 59 if (open_folder_) { | 60 if (open_folder_) { |
| 60 // Transform to a scaled down icon inside the original folder icon. | 61 // Transform to a scaled down icon inside the original folder icon. |
| 61 layer()->SetTransform(transform); | 62 layer()->SetTransform(transform); |
| 62 } | 63 } |
| 63 | 64 |
| 64 // Animate the icon to its target location and scale when opening or | 65 // Animate the icon to its target location and scale when opening or |
| 65 // closing a folder. | 66 // closing a folder. |
| 66 ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator()); | 67 ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator()); |
| 67 settings.AddObserver(this); | 68 settings.AddObserver(this); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 85 observers_, | 86 observers_, |
| 86 OnTopIconAnimationsComplete()); | 87 OnTopIconAnimationsComplete()); |
| 87 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); | 88 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
| 88 } | 89 } |
| 89 | 90 |
| 90 bool TopIconAnimationView::RequiresNotificationWhenAnimatorDestroyed() const { | 91 bool TopIconAnimationView::RequiresNotificationWhenAnimatorDestroyed() const { |
| 91 return true; | 92 return true; |
| 92 } | 93 } |
| 93 | 94 |
| 94 } // namespace app_list | 95 } // namespace app_list |
| OLD | NEW |