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

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: 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 | ui/gfx/transform_util.h » ('j') | ui/gfx/transform_util.h » ('J')
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"
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
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
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
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/transform_util.h » ('j') | ui/gfx/transform_util.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698