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" |
| 11 #include "ui/gfx/transform_util.h" |
11 #include "ui/views/controls/image_view.h" | 12 #include "ui/views/controls/image_view.h" |
12 | 13 |
13 namespace app_list { | 14 namespace app_list { |
14 | 15 |
15 TopIconAnimationView::TopIconAnimationView(const gfx::ImageSkia& icon, | 16 TopIconAnimationView::TopIconAnimationView(const gfx::ImageSkia& icon, |
16 const gfx::Rect& scaled_rect, | 17 const gfx::Rect& scaled_rect, |
17 bool open_folder) | 18 bool open_folder) |
18 : icon_size_(kGridIconDimension, kGridIconDimension), | 19 : icon_size_(kGridIconDimension, kGridIconDimension), |
19 icon_(new views::ImageView), | 20 icon_(new views::ImageView), |
20 scaled_rect_(scaled_rect), | 21 scaled_rect_(scaled_rect), |
(...skipping 22 matching lines...) Expand all Loading... |
43 void TopIconAnimationView::RemoveObserver(TopIconAnimationObserver* observer) { | 44 void TopIconAnimationView::RemoveObserver(TopIconAnimationObserver* observer) { |
44 observers_.RemoveObserver(observer); | 45 observers_.RemoveObserver(observer); |
45 } | 46 } |
46 | 47 |
47 void TopIconAnimationView::TransformView() { | 48 void TopIconAnimationView::TransformView() { |
48 // This view will delete itself on animation completion. | 49 // This view will delete itself on animation completion. |
49 set_owned_by_client(); | 50 set_owned_by_client(); |
50 | 51 |
51 // Transform used for scaling down the icon and move it back inside to the | 52 // Transform used for scaling down the icon and move it back inside to the |
52 // original folder icon. | 53 // original folder icon. |
53 const float kIconTransformScale = 0.33333f; | 54 gfx::Transform transform = gfx::GetRectTransform(bounds(), scaled_rect_); |
54 gfx::Transform transform; | |
55 transform.Translate(scaled_rect_.x() - layer()->bounds().x(), | |
56 scaled_rect_.y() - layer()->bounds().y()); | |
57 transform.Scale(kIconTransformScale, kIconTransformScale); | |
58 | 55 |
59 if (open_folder_) { | 56 if (open_folder_) { |
60 // Transform to a scaled down icon inside the original folder icon. | 57 // Transform to a scaled down icon inside the original folder icon. |
61 layer()->SetTransform(transform); | 58 layer()->SetTransform(transform); |
62 } | 59 } |
63 | 60 |
64 // Animate the icon to its target location and scale when opening or | 61 // Animate the icon to its target location and scale when opening or |
65 // closing a folder. | 62 // closing a folder. |
66 ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator()); | 63 ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator()); |
67 settings.AddObserver(this); | 64 settings.AddObserver(this); |
(...skipping 17 matching lines...) Expand all Loading... |
85 observers_, | 82 observers_, |
86 OnTopIconAnimationsComplete()); | 83 OnTopIconAnimationsComplete()); |
87 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); | 84 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
88 } | 85 } |
89 | 86 |
90 bool TopIconAnimationView::RequiresNotificationWhenAnimatorDestroyed() const { | 87 bool TopIconAnimationView::RequiresNotificationWhenAnimatorDestroyed() const { |
91 return true; | 88 return true; |
92 } | 89 } |
93 | 90 |
94 } // namespace app_list | 91 } // namespace app_list |
OLD | NEW |