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

Side by Side Diff: ui/app_list/views/top_icon_animation_view.cc

Issue 694743002: Fix folder icon animation in app list. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@launcher_page_api_do_actual_thing
Patch Set: add comment Created 6 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698