Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ui / app_list / views / top_icon_animation_view.h
blobeea32db0c0f3cf590dce0392acdc6330dd4610df
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
3 // found in the LICENSE file.
5 #ifndef UI_APP_LIST_VIEWS_TOP_ICON_ANIMATION_VIEW_H_
6 #define UI_APP_LIST_VIEWS_TOP_ICON_ANIMATION_VIEW_H_
8 #include "base/observer_list.h"
9 #include "ui/compositor/layer_animation_observer.h"
10 #include "ui/views/view.h"
12 namespace views {
13 class ImageView;
16 namespace app_list {
18 // Observer for top icon animation completion.
19 class TopIconAnimationObserver {
20 public:
21 // Called when top icon animation completes.
22 virtual void OnTopIconAnimationsComplete() {}
24 protected:
25 TopIconAnimationObserver() {}
26 virtual ~TopIconAnimationObserver() {}
28 private:
29 DISALLOW_COPY_AND_ASSIGN(TopIconAnimationObserver);
32 // Transitional view used for top item icons animation when opening or closing
33 // a folder. Owns itself.
34 class TopIconAnimationView : public views::View,
35 public ui::ImplicitAnimationObserver {
36 public:
37 // |icon|: The icon image of the item icon of full scale size.
38 // |scaled_rect|: Bounds of the small icon inside folder icon.
39 // |open_folder|: Specify open/close folder animation to perform.
40 // The view will be self-cleaned by the end of animation.
41 TopIconAnimationView(const gfx::ImageSkia& icon,
42 const gfx::Rect& scaled_rect,
43 bool open_folder);
44 ~TopIconAnimationView() override;
46 void AddObserver(TopIconAnimationObserver* observer);
47 void RemoveObserver(TopIconAnimationObserver* observer);
49 // When opening a folder, transform the top item icon from the small icon
50 // inside folder icon to the full scale icon at the target location.
51 // When closing a folder, transform the full scale item icon from its
52 // location to the small icon inside the folder icon.
53 void TransformView();
55 private:
56 // views::View overrides:
57 gfx::Size GetPreferredSize() const override;
58 void Layout() override;
60 // ui::ImplicitAnimationObserver overrides:
61 void OnImplicitAnimationsCompleted() override;
62 bool RequiresNotificationWhenAnimatorDestroyed() const override;
64 gfx::Size icon_size_;
65 views::ImageView* icon_; // Owned by views hierarchy.
66 // Rect of the scaled down top item icon inside folder icon's ink bubble.
67 gfx::Rect scaled_rect_;
68 // true: opening folder; false: closing folder.
69 bool open_folder_;
71 base::ObserverList<TopIconAnimationObserver> observers_;
73 DISALLOW_COPY_AND_ASSIGN(TopIconAnimationView);
76 } // namespace app_list
78 #endif // UI_APP_LIST_VIEWS_TOP_ICON_ANIMATION_VIEW_H_